Skip to content

Commit 457a01b

Browse files
committed
Adpat tests to new page structure on MyAccount > security
1 parent d509e32 commit 457a01b

5 files changed

Lines changed: 29 additions & 25 deletions

File tree

modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def request_token_for_device(device, locals)
9898
default_message = t("two_factor_authentication.devices.confirm_send_failed")
9999
flash[:error] = "#{default_message} #{error}"
100100

101-
redirect_to action: :index
101+
redirect_to index_path
102102
end
103103
end
104104

modules/two_factor_authentication/spec/controllers/two_factor_authentication/my/two_factor_devices_controller_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
describe "accessing" do
3131
before do
32-
get :index
32+
get :new
3333
end
3434

3535
context "when not logged in" do
@@ -38,7 +38,7 @@
3838

3939
it "does not give access" do
4040
expect(response).to be_redirect
41-
expect(response).to redirect_to signin_path(back_url: my_2fa_devices_url)
41+
expect(response).to redirect_to signin_path(back_url: new_my_2fa_device_url)
4242
end
4343
end
4444

@@ -51,9 +51,9 @@
5151
context "when logged in and active strategies" do
5252
let(:active_strategies) { [:developer] }
5353

54-
it "renders the index page" do
54+
it "renders the new type selection page" do
5555
expect(response).to be_successful
56-
expect(response).to render_template "index"
56+
expect(response).to render_template "new_type"
5757
end
5858
end
5959
end
@@ -149,7 +149,7 @@
149149
.and_return(ServiceResult.failure)
150150

151151
get :confirm, params: { device_id: device.id }
152-
expect(response).to redirect_to action: :index
152+
expect(response).to redirect_to my_security_path
153153
expect(flash[:error]).to include I18n.t("two_factor_authentication.devices.confirm_send_failed")
154154
end
155155
end
@@ -167,7 +167,7 @@
167167

168168
it "renders a 400 on missing token" do
169169
post :confirm, params: { device_id: device.id }
170-
expect(response).to redirect_to action: :index
170+
expect(response).to redirect_to my_security_path
171171
end
172172

173173
it "redirects to the confirmation on faulty entry" do
@@ -192,7 +192,7 @@
192192
.and_return(ServiceResult.success)
193193

194194
post :confirm, params: { device_id: device.id, otp: "1234" }
195-
expect(response).to redirect_to action: :index
195+
expect(response).to redirect_to my_security_path
196196
expect(flash[:notice]).to include I18n.t("two_factor_authentication.devices.registration_complete")
197197
device.reload
198198
expect(device.active).to be true
@@ -212,7 +212,7 @@
212212
# rubocop:enable RSpec/AnyInstance
213213

214214
post :confirm, params: { device_id: device.id, otp: "1234" }
215-
expect(response).to redirect_to action: :index
215+
expect(response).to redirect_to my_security_path
216216
expect(flash[:notice]).to include I18n.t("two_factor_authentication.devices.registration_complete")
217217
device.reload
218218
expect(device.active).to be true
@@ -241,7 +241,7 @@
241241

242242
it "deletes it" do
243243
delete :destroy, params: { device_id: device.id }
244-
expect(response).to redirect_to action: :index
244+
expect(response).to redirect_to my_security_path
245245
expect(user.otp_devices.reload).to eq []
246246
end
247247
end
@@ -251,7 +251,7 @@
251251

252252
it "deletes it" do
253253
delete :destroy, params: { device_id: device.id }
254-
expect(response).to redirect_to action: :index
254+
expect(response).to redirect_to my_security_path
255255
expect(user.otp_devices.reload).to eq []
256256
end
257257
end

modules/two_factor_authentication/spec/routing/two_factor_authentication/my/two_factor_devices_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
require "spec_helper"
3232

3333
RSpec.describe "users 2fa devices" do
34-
it "route to index" do
35-
expect(get("/my/two_factor_devices")).to route_to("two_factor_authentication/my/two_factor_devices#index")
36-
end
37-
3834
it "route to new" do
3935
expect(get("/my/two_factor_devices/new")).to route_to("two_factor_authentication/my/two_factor_devices#new")
4036
end

spec/controllers/my_controller_spec.rb

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@
3838
end
3939

4040
describe "password change" do
41+
describe "security" do
42+
render_views
43+
44+
before do
45+
get :security
46+
end
47+
48+
it "does render 'Change password' section" do
49+
expect(response.body).to have_css(".Subhead-heading", text: "Change password")
50+
end
51+
end
52+
4153
describe "#password" do
4254
before do
4355
get :password
@@ -112,8 +124,8 @@
112124
}
113125
end
114126

115-
it "redirects to the my password page" do
116-
expect(response).to redirect_to("/my/password")
127+
it "redirects to the security page" do
128+
expect(response).to redirect_to(my_security_path)
117129
end
118130

119131
it "allows the user to login with the new password" do
@@ -230,10 +242,6 @@
230242
it "renders editable custom fields" do
231243
expect(response.body).to have_content(custom_field.name)
232244
end
233-
234-
it "renders the 'Change password' menu entry" do
235-
expect(response.body).to have_css("#menu-sidebar li a", text: "Change password")
236-
end
237245
end
238246
end
239247

@@ -351,14 +359,14 @@
351359
before do
352360
allow(OpenProject::Configuration).to receive(:disable_password_login?).and_return(true)
353361
as_logged_in_user user do
354-
get :account
362+
get :security
355363
end
356364
end
357365

358366
render_views
359367

360-
it "does not render 'Change password' menu entry" do
361-
expect(response.body).to have_no_css("#menu-sidebar li a", text: "Change password")
368+
it "does not render 'Change password' section" do
369+
expect(response.body).to have_no_css(".Subhead-heading", text: "Change password")
362370
end
363371
end
364372

spec/lib/redmine/menu_manager_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
context "for the my_menu" do
107107
it "includes the expected items" do
108108
expect(described_class.items(:my_menu).map(&:name))
109-
.to include(:account, :locale, :password, :access_tokens, :notifications)
109+
.to include(:account, :locale, :security, :access_tokens, :notifications)
110110
end
111111
end
112112

0 commit comments

Comments
 (0)