summaryrefslogtreecommitdiff
path: root/spec/models/broadcast_message_spec.rb
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-08-29 21:09:27 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-08-29 21:09:27 +0800
commit110d7fb78c0edf2e18c70ff3d9b60671f6935977 (patch)
treed05720cfd55e3b91e067aaeca5731572e5853e4e /spec/models/broadcast_message_spec.rb
parent00b440443808fba04fc55f7e77c61f79e29c21ea (diff)
parent01785533a5ba26e9dbed7972d9732a9b122ff3e0 (diff)
downloadgitlab-ce-110d7fb78c0edf2e18c70ff3d9b60671f6935977.tar.gz
Merge remote-tracking branch 'upstream/master' into perf.slow-issuable
* upstream/master: (206 commits) Resolve "Monitoring graph date formatting is wrong" Add styles for shorter code Update doc for dind using overlay2 Cleans merge_jid when possible on MergeService Rename MergeRequest#async_merge to merge_async Add changelog Track enqueued and ongoing MRs Remove locked? check when unlocking a merge request Update CHANGELOG.md for 9.5.2 Update rubocop-gitlab-security to 0.1.0 Fix spec Fix changelog Fix spec Add changelog Remove trigger_request.trigger.owner Reproduced bug Fix a transient failure in mini_pipeline_graph_spec fix typo fix spec Fix events error importing GitLab projects ...
Diffstat (limited to 'spec/models/broadcast_message_spec.rb')
-rw-r--r--spec/models/broadcast_message_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb
index 3369aef1d3e..461e754dc1f 100644
--- a/spec/models/broadcast_message_spec.rb
+++ b/spec/models/broadcast_message_spec.rb
@@ -53,6 +53,29 @@ describe BroadcastMessage do
2.times { described_class.current }
end
+
+ it 'includes messages that need to be displayed in the future' do
+ create(:broadcast_message)
+
+ future = create(
+ :broadcast_message,
+ starts_at: Time.now + 10.minutes,
+ ends_at: Time.now + 20.minutes
+ )
+
+ expect(described_class.current.length).to eq(1)
+
+ Timecop.travel(future.starts_at) do
+ expect(described_class.current.length).to eq(2)
+ end
+ end
+
+ it 'does not clear the cache if only a future message should be displayed' do
+ create(:broadcast_message, :future)
+
+ expect(Rails.cache).not_to receive(:delete)
+ expect(described_class.current.length).to eq(0)
+ end
end
describe '#active?' do