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.

Pavel Balashou0054a8673aa5
diff --git a/spec/controllers/members_controller_spec.rb b/spec/controllers/members_controller_spec.rb
index b9149e28b1d..81904bd628b 100644
--- a/spec/controllers/members_controller_spec.rb
+++ b/spec/controllers/members_controller_spec.rb
@@ -39,18 +39,12 @@ RSpec.describe MembersController do
roles: [role])
end
- before do
- allow(User).to receive(:current).and_return(admin)
- end
+ before { login_as(admin) }
describe 'create' do
shared_let(:admin) { create(:admin) }
let(:project_2) { create(:project) }
- before do
- allow(User).to receive(:current).and_return(admin)
- end
-
it 'works for multiple users' do
post :create,
params: {
@@ -88,10 +82,6 @@ RSpec.describe MembersController do
)
end
- before do
- allow(User).to receive(:current).and_return(admin)
- end
-
it 'however,s allow roles to be updated through mass assignment' do
put 'update',
params: {
@@ -110,9 +100,7 @@ RSpec.describe MembersController do
describe '#autocomplete_for_member' do
let(:params) { { 'project_id' => project.identifier.to_s } }
- before do
- login_as(user)
- end
+ before { login_as(user) }
describe "WHEN the user is authorized
WHEN a project is provided" do
diff --git a/spec/features/auth/consent_auth_stage_spec.rb b/spec/features/auth/consent_auth_stage_spec.rb
index 8dd5eb4f60e..faa081cc51f 100644
--- a/spec/features/auth/consent_auth_stage_spec.rb
+++ b/spec/features/auth/consent_auth_stage_spec.rb
@@ -100,18 +100,26 @@ RSpec.describe 'Authentication Stages' do
consent_required: true,
consent_info: { de: '# Einwilligung', en: '# Consent header!' }
} do
- around do |example|
- Capybara.current_session.driver.header('Accept-Language', 'de')
- example.call
- ensure
- Capybara.current_session.driver.header('Accept-Language', 'en')
+ context 'users language is en' do
+ let(:language) { 'en' }
+
+ it 'shows consent en' do
+ login_with user.login, user_password
+
+ expect(page).to have_css('.account-consent')
+ expect(page).to have_css('h1', text: 'Consent header!')
+ end
end
- it 'shows localized consent as defined by the accept language header (ignoring users language)' do
- login_with user.login, user_password
+ context 'users language is de' do
+ let(:language) { 'de' }
- expect(page).to have_css('.account-consent')
- expect(page).to have_css('h1', text: 'Einwilligung')
+ it 'shows consent in de' do
+ login_with user.login, user_password
+
+ expect(page).to have_css('.account-consent')
+ expect(page).to have_css('h1', text: 'Einwilligung')
+ end
end
end
diff --git a/spec/support/authentication_helpers.rb b/spec/support/authentication_helpers.rb
index 3c669bdb2e7..43ce2386c5d 100644
--- a/spec/support/authentication_helpers.rb
+++ b/spec/support/authentication_helpers.rb
@@ -49,7 +49,8 @@ module AuthenticationHelpers
end
end
- allow(User).to receive(:current).and_return(user)
+ allow(RequestStore).to receive(:[]).and_call_original
+ allow(RequestStore).to receive(:[]).with(:current_user).and_return(user)
end
def login_with(login, password, autologin: false, visit_signin_path: true)