summaryrefslogtreecommitdiff
path: root/spec/models/broadcast_message_spec.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-11-12 15:08:20 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-11-12 15:08:20 +0200
commitc5b667351abcda4b5ac134873007a0ce47976e88 (patch)
treed72c2d04658447ec9d2d2d119e1b7d19635f0488 /spec/models/broadcast_message_spec.rb
parent963a31144b0d69af7b08e1912965a920636ce600 (diff)
downloadgitlab-ce-c5b667351abcda4b5ac134873007a0ce47976e88.tar.gz
Show broadcast message to users
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/models/broadcast_message_spec.rb')
-rw-r--r--spec/models/broadcast_message_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb
index 09f79f4d627..daaac73739d 100644
--- a/spec/models/broadcast_message_spec.rb
+++ b/spec/models/broadcast_message_spec.rb
@@ -4,4 +4,21 @@ describe BroadcastMessage do
subject { create(:broadcast_message) }
it { should be_valid }
+
+ describe :current do
+ it "should return last message if time match" do
+ broadcast_message = create(:broadcast_message, starts_at: Time.now.yesterday, ends_at: Time.now.tomorrow)
+ BroadcastMessage.current.should == broadcast_message
+ end
+
+ it "should return nil if time not come" do
+ broadcast_message = create(:broadcast_message, starts_at: Time.now.tomorrow, ends_at: Time.now + 2.days)
+ BroadcastMessage.current.should be_nil
+ end
+
+ it "should return nil if time has passed" do
+ broadcast_message = create(:broadcast_message, starts_at: Time.now - 2.days, ends_at: Time.now.yesterday)
+ BroadcastMessage.current.should be_nil
+ end
+ end
end