diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-26 00:08:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-26 00:08:06 +0300 |
commit | e1549c75843d235607aebac9ed64f2fd10e549ed (patch) | |
tree | d6b4213b87b57b323464c7e5c1b75091212f3373 /spec/features | |
parent | 5d75b2b9a9d11c20667895e6aa68ea4e76658c5d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/broadcast_messages_spec.rb | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/spec/features/broadcast_messages_spec.rb b/spec/features/broadcast_messages_spec.rb index 41e8e969610..c770e6e4f81 100644 --- a/spec/features/broadcast_messages_spec.rb +++ b/spec/features/broadcast_messages_spec.rb @@ -3,12 +3,23 @@ require 'spec_helper' describe 'Broadcast Messages' do - shared_examples 'a Broadcast Messages' do + let_it_be(:user) { create(:user) } + + shared_examples 'a Broadcast Messages' do |type| it 'shows broadcast message' do visit root_path expect(page).to have_content 'SampleMessage' end + + it 'renders styled links' do + create(:broadcast_message, type, message: "<a href='gitlab.com' style='color: purple'>click me</a>") + + visit root_path + + expected_html = "<p><a href=\"gitlab.com\" style=\"color: purple\">click me</a></p>" + expect(page.body).to include(expected_html) + end end shared_examples 'a dismissable Broadcast Messages' do @@ -35,11 +46,21 @@ describe 'Broadcast Messages' do it_behaves_like 'a Broadcast Messages' - it 'shows broadcast message' do + it 'is not dismissable' do visit root_path expect(page).not_to have_selector('.js-dismiss-current-broadcast-notification') end + + it 'does not replace placeholders' do + create(:broadcast_message, message: 'Hi {{name}}') + + sign_in(user) + + visit root_path + + expect(page).to have_content 'Hi {{name}}' + end end describe 'dismissable banner type' do @@ -51,33 +72,20 @@ describe 'Broadcast Messages' do end describe 'notification type' do - let!(:broadcast_message) { create(:broadcast_message, broadcast_type: 'notification', message: 'SampleMessage') } + let!(:broadcast_message) { create(:broadcast_message, :notification, message: 'SampleMessage') } - it_behaves_like 'a Broadcast Messages' + it_behaves_like 'a Broadcast Messages', :notification it_behaves_like 'a dismissable Broadcast Messages' - end - - it 'renders broadcast message with placeholders' do - create(:broadcast_message, broadcast_type: 'notification', message: 'Hi {{name}}') - user = create(:user) - sign_in(user) + it 'replaces placeholders' do + create(:broadcast_message, :notification, message: 'Hi {{name}}') - visit root_path + sign_in(user) - expect(page).to have_content "Hi #{user.name}" - end - - it 'renders broadcast message with placeholders and styled links' do - create(:broadcast_message, broadcast_type: 'notification', message: "Hi {{name}} <a href='gitlab.com' style='color: purple'>click</a>") - - user = create(:user) - sign_in(user) - - visit root_path + visit root_path - expected_html = "<p>Hi #{user.name} <a href=\"gitlab.com\" style=\"color: purple\">click</a></p>" - expect(page.body).to include(expected_html) + expect(page).to have_content "Hi #{user.name}" + end end end |