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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
WP 53330, added LDAP user tests to my_spec.rb (account and settings)
Richard "Virgo" Richter79acc78207ad
diff --git a/spec/features/users/my_spec.rb b/spec/features/users/my_spec.rbindex f0063f97b18..a8f0e33415f 100644--- a/spec/features/users/my_spec.rb+++ b/spec/features/users/my_spec.rb@@ -39,7 +39,7 @@ RSpec.describe 'my', :js, :with_cuprite doend##- # Expecations for a successful account change+ # Expectations for a successful account changedef expect_changed!expect(page).to have_content I18n.t(:notice_account_updated)expect(page).to have_content I18n.t(:notice_account_other_session_expired)@@ -62,6 +62,24 @@ RSpec.describe 'my', :js, :with_cuprite doexpect(Sessions::UserSession.for_user(user).where(session_id: 'other').count).to eq 1end+ shared_examples 'common tests for normal and LDAP user' do+ describe 'settings' do+ context 'with a default time zone', with_settings: { user_default_timezone: 'Asia/Tokyo' } do+ it 'can override a time zone' do+ expect(user.pref.time_zone).to eq 'Asia/Tokyo'+ visit my_settings_path++ expect(page).to have_select 'pref_time_zone', selected: '(UTC+09:00) Tokyo'+ select '(UTC+01:00) Paris', from: 'pref_time_zone'+ click_on 'Save'++ expect(page).to have_select 'pref_time_zone', selected: '(UTC+01:00) Paris'+ expect(user.pref.time_zone).to eq 'Europe/Paris'+ end+ end+ end+ end+context 'user' dodescribe '#account' dolet(:dialog) { Components::PasswordConfirmationDialog.new }@@ -108,21 +126,7 @@ RSpec.describe 'my', :js, :with_cuprite doendend- describe 'settings' do- context 'with a default time zone', with_settings: { user_default_timezone: 'Asia/Tokyo' } do- it 'can override a time zone' do- expect(user.pref.time_zone).to eq 'Asia/Tokyo'- visit my_settings_path-- expect(page).to have_select 'pref_time_zone', selected: '(UTC+09:00) Tokyo'- select '(UTC+01:00) Paris', from: 'pref_time_zone'- click_on 'Save'-- expect(page).to have_select 'pref_time_zone', selected: '(UTC+01:00) Paris'- expect(user.pref.time_zone).to eq 'Europe/Paris'- end- end- end+ include_examples 'common tests for normal and LDAP user'describe "API tokens" docontext 'when API access is disabled via global settings', with_settings: { rest_api_enabled: false } do@@ -415,4 +419,43 @@ RSpec.describe 'my', :js, :with_cuprite doendendend++ # Without password confirmation the test doesn't try to connect to the LDAP:+ context 'LDAP user', with_config: { internal_password_confirmation: false } do+ let(:ldap_auth_source) { create(:ldap_auth_source) }+ let(:user) do+ create(:user,+ mail: '[email protected]',+ login: 'bob',+ ldap_auth_source:)+ end++ describe '#account' do+ before do+ visit my_account_path+ end++ it 'does not allow change of name and email but hide email can be changed' do+ email_field = find_field('user[mail]', disabled: true)+ firstname_field = find_field('user[firstname]', disabled: true)+ lastname_field = find_field('user[lastname]', disabled: true)++ expect(email_field).to be_disabled+ expect(firstname_field).to be_disabled+ expect(lastname_field).to be_disabled++ expect(page).to have_text(I18n.t('user.text_change_disabled_for_ldap_login'), count: 3)++ uncheck 'pref[hide_mail]'+ click_on 'Save'++ expect(page).to have_content I18n.t(:notice_account_updated)++ user.reload+ expect(user.pref.hide_mail).to be false+ end+ end++ include_examples 'common tests for normal and LDAP user'+ endend