diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-30 09:08:38 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-30 09:08:38 +0000 |
commit | 8ca437b79438e914b2eede563906e7889c81dc19 (patch) | |
tree | a736452eff9c2d6353498f9ad366b231103062ad /spec/views | |
parent | 142658ee280a72a0cb45b241c43ddc495d852814 (diff) | |
download | gitlab-ce-8ca437b79438e914b2eede563906e7889c81dc19.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/profiles/notifications/show.html.haml_spec.rb | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/spec/views/profiles/notifications/show.html.haml_spec.rb b/spec/views/profiles/notifications/show.html.haml_spec.rb index 9cdf8124fcf..1cfd8847bf8 100644 --- a/spec/views/profiles/notifications/show.html.haml_spec.rb +++ b/spec/views/profiles/notifications/show.html.haml_spec.rb @@ -5,6 +5,11 @@ require 'spec_helper' RSpec.describe 'profiles/notifications/show' do let(:groups) { GroupsFinder.new(user).execute.page(1) } let(:user) { create(:user) } + let(:option_default) { _('Use primary email (%{email})') % { email: user.email } } + let(:option_primary_email) { user.email } + let(:expected_primary_email_attr) { "[data-emails='#{[option_primary_email].to_json}']" } + let(:expected_default_attr) { "[data-empty-value-text='#{option_default}']" } + let(:expected_selector) { expected_primary_email_attr + expected_default_attr + expected_value_attr } before do assign(:group_notifications, []) @@ -16,14 +21,26 @@ RSpec.describe 'profiles/notifications/show' do end context 'when there is no database value for User#notification_email' do - let(:option_default) { _('Use primary email (%{email})') % { email: user.email } } - let(:option_primary_email) { user.email } - let(:options) { [option_default, option_primary_email] } + let(:expected_value_attr) { ":not([data-value])" } it 'displays the correct elements' do render - expect(rendered).to have_select('user_notification_email', options: options, selected: nil) + expect(rendered).to have_selector(expected_selector) + end + end + + context 'when there is a database value for User#notification_email' do + let(:expected_value_attr) { "[data-value='#{option_primary_email}']" } + + before do + user.notification_email = option_primary_email + end + + it 'displays the correct elements' do + render + + expect(rendered).to have_selector(expected_selector) end end end |