Skip to content

Commit a9094ab

Browse files
Replace view spec with request spec
1 parent bdcbde1 commit a9094ab

File tree

2 files changed

+69
-61
lines changed

2 files changed

+69
-61
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#-- copyright
2+
# OpenProject is an open source project management software.
3+
# Copyright (C) the OpenProject GmbH
4+
#
5+
# This program is free software; you can redistribute it and/or
6+
# modify it under the terms of the GNU General Public License version 3.
7+
#
8+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
9+
# Copyright (C) 2006-2013 Jean-Philippe Lang
10+
# Copyright (C) 2010-2013 the ChiliProject Team
11+
#
12+
# This program is free software; you can redistribute it and/or
13+
# modify it under the terms of the GNU General Public License
14+
# as published by the Free Software Foundation; either version 2
15+
# of the License, or (at your option) any later version.
16+
#
17+
# This program is distributed in the hope that it will be useful,
18+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
# GNU General Public License for more details.
21+
#
22+
# You should have received a copy of the GNU General Public License
23+
# along with this program; if not, write to the Free Software
24+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25+
#
26+
# See COPYRIGHT and LICENSE files for more details.
27+
#++
28+
29+
require "spec_helper"
30+
31+
RSpec.describe "Authentication Settings",
32+
:skip_csrf,
33+
type: :rails_request do
34+
let(:admin) { create(:admin) }
35+
36+
before do
37+
login_as(admin)
38+
end
39+
40+
describe "GET /admin/settings/authentication?tab=passwords" do
41+
context "with password login enabled" do
42+
before do
43+
allow(OpenProject::Configuration).to receive(:disable_password_login?).and_return(false)
44+
get "/admin/settings/authentication.html?tab=passwords"
45+
end
46+
47+
it "shows password settings" do
48+
expect(response).to have_http_status(:success)
49+
50+
expect(page).to have_field(I18n.t(:setting_lost_password), disabled: false)
51+
expect(page).to have_field(I18n.t(:setting_brute_force_block_after_failed_logins), disabled: false)
52+
end
53+
end
54+
55+
context "with password login disabled" do
56+
before do
57+
allow(OpenProject::Configuration).to receive(:disable_password_login?).and_return(true)
58+
get "/admin/settings/authentication.html?tab=passwords"
59+
end
60+
61+
it "disables password settings" do
62+
expect(response).to have_http_status(:success)
63+
64+
expect(page).to have_field(I18n.t(:setting_lost_password), disabled: true)
65+
expect(page).to have_field(I18n.t(:setting_brute_force_block_after_failed_logins), disabled: true)
66+
end
67+
end
68+
end
69+
end

spec/views/admin/settings/authentication/show.html.erb_spec.rb

-61
This file was deleted.

0 commit comments

Comments
 (0)