Skip to content
Snippets Groups Projects
Unverified Commit c5b66735 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Show broadcast message to users

parent 963a3114
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -351,3 +351,10 @@ table {
@extend .btn-new;
padding: 5px 15px;
}
.broadcast-message {
padding: 10px;
text-align: center;
background: #555;
color: #BBB;
}
Loading
Loading
@@ -208,4 +208,8 @@ module ApplicationHelper
line += "..." if lines.size > 1
line
end
def broadcast_message
BroadcastMessage.current
end
end
Loading
Loading
@@ -4,4 +4,8 @@ class BroadcastMessage < ActiveRecord::Base
validates :message, presence: true
validates :starts_at, presence: true
validates :ends_at, presence: true
def self.current
where("ends_at > :now AND starts_at < :now", now: Time.zone.now).last
end
end
- if broadcast_message.present?
.broadcast-message
%i.icon-bullhorn
= broadcast_message.message
Loading
Loading
@@ -2,6 +2,7 @@
%html{ lang: "en"}
= render "layouts/head", title: "Dashboard"
%body{class: "#{app_theme} application", :'data-page' => body_data_page }
= render "layouts/broadcast"
= render "layouts/head_panel", title: "Dashboard"
= render "layouts/flash"
%nav.main-nav
Loading
Loading
Loading
Loading
@@ -2,6 +2,7 @@
%html{ lang: "en"}
= render "layouts/head", title: @project.name_with_namespace
%body{class: "#{app_theme} project", :'data-page' => body_data_page, :'data-project-id' => @project.id }
= render "layouts/broadcast"
= render "layouts/head_panel", title: project_title(@project)
= render "layouts/init_auto_complete"
= render "layouts/flash"
Loading
Loading
Loading
Loading
@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment