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
Kazuhiko Shiozaki
gitlab-ce
Commits
84366282
Commit
84366282
authored
Jan 13, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move `BroadcastMessage#status` to a helper since it's presentational
parent
c13b5acb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
31 deletions
+31
-31
app/helpers/broadcast_messages_helper.rb
app/helpers/broadcast_messages_helper.rb
+10
-0
app/models/broadcast_message.rb
app/models/broadcast_message.rb
+0
-10
app/views/admin/broadcast_messages/index.html.haml
app/views/admin/broadcast_messages/index.html.haml
+1
-1
spec/helpers/broadcast_messages_helper_spec.rb
spec/helpers/broadcast_messages_helper_spec.rb
+20
-0
spec/models/broadcast_message_spec.rb
spec/models/broadcast_message_spec.rb
+0
-20
No files found.
app/helpers/broadcast_messages_helper.rb
View file @
84366282
...
@@ -21,4 +21,14 @@ module BroadcastMessagesHelper
...
@@ -21,4 +21,14 @@ module BroadcastMessagesHelper
style
style
end
end
def
broadcast_message_status
(
broadcast_message
)
if
broadcast_message
.
active?
'Active'
elsif
broadcast_message
.
ended?
'Expired'
else
'Pending'
end
end
end
end
app/models/broadcast_message.rb
View file @
84366282
...
@@ -40,14 +40,4 @@ class BroadcastMessage < ActiveRecord::Base
...
@@ -40,14 +40,4 @@ class BroadcastMessage < ActiveRecord::Base
def
ended?
def
ended?
ends_at
<
Time
.
zone
.
now
ends_at
<
Time
.
zone
.
now
end
end
def
status
if
active?
'Active'
elsif
ended?
'Expired'
else
'Pending'
end
end
end
end
app/views/admin/broadcast_messages/index.html.haml
View file @
84366282
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
-
@broadcast_messages
.
each
do
|
message
|
-
@broadcast_messages
.
each
do
|
message
|
%tr
%tr
%td
%td
=
message
.
status
=
broadcast_message_status
(
message
)
%td
%td
=
broadcast_message
(
message
)
=
broadcast_message
(
message
)
%td
%td
...
...
spec/helpers/broadcast_messages_helper_spec.rb
View file @
84366282
...
@@ -37,4 +37,24 @@ describe BroadcastMessagesHelper do
...
@@ -37,4 +37,24 @@ describe BroadcastMessagesHelper do
to
match
(
'background-color: #f2dede; color: #b94a48'
)
to
match
(
'background-color: #f2dede; color: #b94a48'
)
end
end
end
end
describe
'broadcast_message_status'
do
it
'returns Active'
do
message
=
build
(
:broadcast_message
)
expect
(
helper
.
broadcast_message_status
(
message
)).
to
eq
'Active'
end
it
'returns Expired'
do
message
=
build
(
:broadcast_message
,
:expired
)
expect
(
helper
.
broadcast_message_status
(
message
)).
to
eq
'Expired'
end
it
'returns Pending'
do
message
=
build
(
:broadcast_message
,
:future
)
expect
(
helper
.
broadcast_message_status
(
message
)).
to
eq
'Pending'
end
end
end
end
spec/models/broadcast_message_spec.rb
View file @
84366282
...
@@ -111,24 +111,4 @@ describe BroadcastMessage, models: true do
...
@@ -111,24 +111,4 @@ describe BroadcastMessage, models: true do
end
end
end
end
end
end
describe
'#status'
do
it
'returns Active'
do
message
=
build
(
:broadcast_message
)
expect
(
message
.
status
).
to
eq
'Active'
end
it
'returns Expired'
do
message
=
build
(
:broadcast_message
,
:expired
)
expect
(
message
.
status
).
to
eq
'Expired'
end
it
'returns Pending'
do
message
=
build
(
:broadcast_message
,
:future
)
expect
(
message
.
status
).
to
eq
'Pending'
end
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