Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
c5b66735
Commit
c5b66735
authored
Nov 12, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show broadcast message to users
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
963a3114
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
0 deletions
+38
-0
app/assets/stylesheets/common.scss
app/assets/stylesheets/common.scss
+7
-0
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+4
-0
app/models/broadcast_message.rb
app/models/broadcast_message.rb
+4
-0
app/views/layouts/_broadcast.html.haml
app/views/layouts/_broadcast.html.haml
+4
-0
app/views/layouts/application.html.haml
app/views/layouts/application.html.haml
+1
-0
app/views/layouts/projects.html.haml
app/views/layouts/projects.html.haml
+1
-0
spec/models/broadcast_message_spec.rb
spec/models/broadcast_message_spec.rb
+17
-0
No files found.
app/assets/stylesheets/common.scss
View file @
c5b66735
...
...
@@ -351,3 +351,10 @@ table {
@extend
.btn-new
;
padding
:
5px
15px
;
}
.broadcast-message
{
padding
:
10px
;
text-align
:
center
;
background
:
#555
;
color
:
#BBB
;
}
app/helpers/application_helper.rb
View file @
c5b66735
...
...
@@ -208,4 +208,8 @@ module ApplicationHelper
line
+=
"..."
if
lines
.
size
>
1
line
end
def
broadcast_message
BroadcastMessage
.
current
end
end
app/models/broadcast_message.rb
View file @
c5b66735
...
...
@@ -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
app/views/layouts/_broadcast.html.haml
0 → 100644
View file @
c5b66735
-
if
broadcast_message
.
present?
.broadcast-message
%i
.icon-bullhorn
=
broadcast_message
.
message
app/views/layouts/application.html.haml
View file @
c5b66735
...
...
@@ -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
...
...
app/views/layouts/projects.html.haml
View file @
c5b66735
...
...
@@ -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"
...
...
spec/models/broadcast_message_spec.rb
View file @
c5b66735
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment