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

Revert "Change auth_stages feature specs to verify the missing http status code instead of a raised exception."

Dombi Attiladac7f0015212
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 2cd4fe6b039..347ec874ab2 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -62,7 +62,7 @@ Rails.application.configure do
config.cache_store = :null_store
# Render exception templates for rescuable exceptions and raise for other exceptions.
- config.action_dispatch.show_exceptions = :rescuable
+ config.action_dispatch.show_exceptions = :none
# Enable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = true
diff --git a/spec/features/auth/auth_stages_spec.rb b/spec/features/auth/auth_stages_spec.rb
index 4cea293ee2f..8efca2075d9 100644
--- a/spec/features/auth/auth_stages_spec.rb
+++ b/spec/features/auth/auth_stages_spec.rb
@@ -97,9 +97,7 @@ RSpec.describe 'Authentication Stages', :skip_2fa_stage do
fill_in "user_password_confirmation", with: "hansihansi"
end
- click_on("Create")
-
- expect(page).to have_http_status(:missing)
+ expect { click_on("Create") }.to raise_error(ActionController::RoutingError, /\/activation\/stage_test/)
expect(current_path).to eql "/activation/stage_test"
# after the stage is finished it must redirect to the complete endpoint
@@ -119,9 +117,7 @@ RSpec.describe 'Authentication Stages', :skip_2fa_stage do
fill_in "last_name", with: "Apfel"
fill_in "email", with: "[email protected]"
- click_on("Sign In")
-
- expect(page).to have_http_status(:missing)
+ expect { click_on("Sign In") }.to raise_error(ActionController::RoutingError, /\/activation\/stage_test/)
expect(current_path).to eql "/activation/stage_test"
# after the stage is finished it must redirect to the complete endpoint
@@ -136,9 +132,8 @@ RSpec.describe 'Authentication Stages', :skip_2fa_stage do
end
it 'redirects to registered authentication stage before actual login if successful' do
- login!
+ expect { login! }.to raise_error(ActionController::RoutingError, /\/login\/stage_test/)
- expect(page).to have_http_status(:missing)
expect(current_path).to eql "/login/stage_test"
# after the stage is finished it must redirect to the complete endpoint
@@ -152,9 +147,8 @@ RSpec.describe 'Authentication Stages', :skip_2fa_stage do
end
it 'redirects to the login page and shows an error on verification failure' do
- login!
+ expect { login! }.to raise_error(ActionController::RoutingError, /\/login\/stage_test/)
- expect(page).to have_http_status(:missing)
expect(current_path).to eql "/login/stage_test"
# after the stage is finished it can redirect to the failure endpoint if something went wrong
@@ -169,9 +163,8 @@ RSpec.describe 'Authentication Stages', :skip_2fa_stage do
end
it 'redirects to the login page and shows an error on authentication stage failure' do
- login!
+ expect { login! }.to raise_error(ActionController::RoutingError, /\/login\/stage_test/)
- expect(page).to have_http_status(:missing)
expect(current_path).to eql "/login/stage_test"
# after the stage is finished it can redirect to the failure endpoint if something went wrong
@@ -186,9 +179,8 @@ RSpec.describe 'Authentication Stages', :skip_2fa_stage do
end
it 'redirects to the login page and shows an error on returning to the wrong stage' do
- login!
+ expect { login! }.to raise_error(ActionController::RoutingError, /\/login\/stage_test/)
- expect(page).to have_http_status(:missing)
expect(current_path).to eql "/login/stage_test"
visit "/login/foobar/success" # redirect to wrong stage endpoint
@@ -205,13 +197,15 @@ RSpec.describe 'Authentication Stages', :skip_2fa_stage do
it 'redirects to the referer if there is one' do
visit "/projects"
- within('#login-form') do
- fill_in('username', with: user.login)
- fill_in('password', with: user_password)
- click_link_or_button I18n.t(:button_login)
+ expect do
+ within('#login-form') do
+ fill_in('username', with: user.login)
+ fill_in('password', with: user_password)
+ click_link_or_button I18n.t(:button_login)
+ end
end
+ .to raise_error(ActionController::RoutingError, /\/login\/stage_test/)
- expect(page).to have_http_status(:missing)
expect(current_path).to eql "/login/stage_test"
# after the stage is finished it must redirect to the complete endpoint
@@ -237,13 +231,12 @@ RSpec.describe 'Authentication Stages', :skip_2fa_stage do
end
it 'redirects to both registered authentication stages before actual login if successful' do
- login!
+ expect { login! }.to raise_error(ActionController::RoutingError, /\/login\/stage_test/)
- expect(page).to have_http_status(:missing)
expect(current_path).to eql "/login/stage_test"
- visit "/login/dummy_step/success"
- expect(page).to have_http_status(:missing)
+ expect { visit "/login/dummy_step/success" }
+ .to raise_error(ActionController::RoutingError, /\/login\/stage_test_2/)
# after the stage is finished it must redirect to the complete endpoint
visit "/login/two_step/success"