GitLab steht wegen Wartungsarbeiten am Montag, den 10. Mai, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Commit 84366282 authored by Robert Speicher's avatar Robert Speicher

Move `BroadcastMessage#status` to a helper since it's presentational

parent c13b5acb
......@@ -21,4 +21,14 @@ def broadcast_message_style(broadcast_message)
style
end
def broadcast_message_status(broadcast_message)
if broadcast_message.active?
'Active'
elsif broadcast_message.ended?
'Expired'
else
'Pending'
end
end
end
......@@ -40,14 +40,4 @@ def started?
def ended?
ends_at < Time.zone.now
end
def status
if active?
'Active'
elsif ended?
'Expired'
else
'Pending'
end
end
end
......@@ -23,7 +23,7 @@
- @broadcast_messages.each do |message|
%tr
%td
= message.status
= broadcast_message_status(message)
%td
= broadcast_message(message)
%td
......
......@@ -37,4 +37,24 @@
to match('background-color: #f2dede; color: #b94a48')
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
......@@ -111,24 +111,4 @@
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment