Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/broadcast_message_spec.rb')
-rw-r--r--spec/models/broadcast_message_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb
index 020ada3c47a..b06fa845777 100644
--- a/spec/models/broadcast_message_spec.rb
+++ b/spec/models/broadcast_message_spec.rb
@@ -88,6 +88,42 @@ describe BroadcastMessage do
expect(Rails.cache).not_to receive(:delete).with(described_class::CACHE_KEY)
expect(described_class.current.length).to eq(0)
end
+
+ it 'returns message if it matches the target path' do
+ message = create(:broadcast_message, target_path: "*/onboarding_completed")
+
+ expect(described_class.current('/users/onboarding_completed')).to include(message)
+ end
+
+ it 'returns message if part of the target path matches' do
+ create(:broadcast_message, target_path: "/users/*/issues")
+
+ expect(described_class.current('/users/name/issues').length).to eq(1)
+ end
+
+ it 'returns the message for empty target path' do
+ create(:broadcast_message, target_path: "")
+
+ expect(described_class.current('/users/name/issues').length).to eq(1)
+ end
+
+ it 'returns the message if target path is nil' do
+ create(:broadcast_message, target_path: nil)
+
+ expect(described_class.current('/users/name/issues').length).to eq(1)
+ end
+
+ it 'does not return message if target path does not match' do
+ create(:broadcast_message, target_path: "/onboarding_completed")
+
+ expect(described_class.current('/welcome').length).to eq(0)
+ end
+
+ it 'does not return message if target path does not match when using wildcard' do
+ create(:broadcast_message, target_path: "/users/*/issues")
+
+ expect(described_class.current('/group/groupname/issues').length).to eq(0)
+ end
end
describe '#attributes' do