BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
5a170679
Commit
5a170679
authored
Dec 31, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update broadcast_message helper
Now it returns the fully-formatted message so we can be consistent about how it's shown.
parent
8086b2bd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
26 deletions
+45
-26
application_helper.rb
app/helpers/application_helper.rb
+0
-4
broadcast_messages_helper.rb
app/helpers/broadcast_messages_helper.rb
+14
-6
_broadcast.html.haml
app/views/layouts/_broadcast.html.haml
+1
-4
broadcast_messages_helper_spec.rb
spec/helpers/broadcast_messages_helper_spec.rb
+30
-12
No files found.
app/helpers/application_helper.rb
View file @
5a170679
...
...
@@ -181,10 +181,6 @@ module ApplicationHelper
end
end
def
broadcast_message
BroadcastMessage
.
current
end
# Render a `time` element with Javascript-based relative date and tooltip
#
# time - Time object
...
...
app/helpers/broadcast_messages_helper.rb
View file @
5a170679
module
BroadcastMessagesHelper
def
broadcast_styling
(
broadcast_message
)
styling
=
''
def
broadcast_message
(
message
=
BroadcastMessage
.
current
)
return
unless
message
.
present?
content_tag
:div
,
class:
'broadcast-message'
,
style:
broadcast_message_style
(
message
)
do
icon
(
'bullhorn'
)
<<
' '
<<
message
.
message
end
end
def
broadcast_message_style
(
broadcast_message
)
style
=
''
if
broadcast_message
.
color
.
present?
styl
ing
<<
"background-color:
#{
broadcast_message
.
color
}
"
styl
ing
<<
'; '
if
broadcast_message
.
font
.
present?
styl
e
<<
"background-color:
#{
broadcast_message
.
color
}
"
styl
e
<<
'; '
if
broadcast_message
.
font
.
present?
end
if
broadcast_message
.
font
.
present?
styl
ing
<<
"color:
#{
broadcast_message
.
font
}
"
styl
e
<<
"color:
#{
broadcast_message
.
font
}
"
end
styl
ing
styl
e
end
end
app/views/layouts/_broadcast.html.haml
View file @
5a170679
-
if
broadcast_message
.
present?
.broadcast-message
{
style:
broadcast_styling
(
broadcast_message
)
}
=
icon
(
'bullhorn'
)
=
broadcast_message
.
message
=
broadcast_message
spec/helpers/broadcast_messages_helper_spec.rb
View file @
5a170679
require
'spec_helper'
describe
BroadcastMessagesHelper
do
describe
'broadcast_styling'
do
let
(
:broadcast_message
)
{
double
(
color:
''
,
font:
''
)
}
describe
'broadcast_message'
do
it
'returns nil when no current message'
do
expect
(
helper
.
broadcast_message
(
nil
)).
to
be_nil
end
it
'includes the current message'
do
current
=
double
(
message:
'Current Message'
)
allow
(
helper
).
to
receive
(
:broadcast_message_style
).
and_return
(
nil
)
expect
(
helper
.
broadcast_message
(
current
)).
to
include
'Current Message'
end
it
'includes custom style'
do
current
=
double
(
message:
'Current Message'
)
allow
(
helper
).
to
receive
(
:broadcast_message_style
).
and_return
(
'foo'
)
expect
(
helper
.
broadcast_message
(
current
)).
to
include
'style="foo"'
end
end
describe
'broadcast_message_style'
do
it
'defaults to no style'
do
broadcast_message
=
spy
context
"default style"
do
it
"should have no style"
do
expect
(
broadcast_styling
(
broadcast_message
)).
to
eq
''
end
expect
(
helper
.
broadcast_message_style
(
broadcast_message
)).
to
eq
''
end
context
"customized style"
do
let
(
:broadcast_message
)
{
double
(
color:
"#f2dede"
,
font:
'#b94a48'
)
}
it
'allows custom style'
do
broadcast_message
=
double
(
color:
'#f2dede'
,
font:
'#b94a48'
)
it
"should have a customized style"
do
expect
(
broadcast_styling
(
broadcast_message
)).
to
match
(
'background-color: #f2dede; color: #b94a48'
)
end
expect
(
helper
.
broadcast_message_style
(
broadcast_message
)).
to
match
(
'background-color: #f2dede; color: #b94a48'
)
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