Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix tests for admin controller

Klaus Zanders4af82939f42d
diff --git a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb
index 6f61cf1cf84..828d1e29bd7 100644
--- a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb
+++ b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe TwoFactorAuthentication::Users::TwoFactorDevicesController do
describe 'accessing' do
before do
- get :new, params: { id: user.id }
+ get :new, params: { id: user.id, type: :sms }
end
context 'when the same user' do
@@ -52,7 +52,7 @@ RSpec.describe TwoFactorAuthentication::Users::TwoFactorDevicesController do
it 'renders the page' do
expect(response).to be_successful
- expect(response).to render_template 'new_type'
+ expect(response).to render_template 'new'
end
context 'when no active strategies' do
@@ -74,9 +74,18 @@ RSpec.describe TwoFactorAuthentication::Users::TwoFactorDevicesController do
get :new, params: { id: user.id }
end
- it 'renders the new form' do
- expect(response).to be_successful
- expect(response).to render_template 'new_type'
+ it 'shows an error' do
+ expect(response).to have_http_status(:bad_request)
+ end
+ end
+
+ context 'with unsupported type' do
+ before do
+ get :new, params: { id: user.id, type: :totp }
+ end
+
+ it 'shows an error' do
+ expect(response).to have_http_status(:bad_request)
end
end