2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe BroadcastMessagesHelper do
|
2016-01-19 16:12:03 +05:30
|
|
|
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
|
2016-11-03 12:29:30 +05:30
|
|
|
current = BroadcastMessage.new(message: 'Current Message')
|
2016-01-19 16:12:03 +05:30
|
|
|
|
|
|
|
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
|
2016-11-03 12:29:30 +05:30
|
|
|
current = BroadcastMessage.new(message: 'Current Message')
|
2016-01-19 16:12:03 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
expect(helper.broadcast_message_style(broadcast_message)).to eq ''
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows custom style' do
|
|
|
|
broadcast_message = double(color: '#f2dede', font: '#b94a48')
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(helper.broadcast_message_style(broadcast_message))
|
|
|
|
.to match('background-color: #f2dede; color: #b94a48')
|
2016-01-19 16:12:03 +05:30
|
|
|
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)
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2016-01-19 16:12:03 +05:30
|
|
|
expect(helper.broadcast_message_status(message)).to eq 'Expired'
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2016-01-19 16:12:03 +05:30
|
|
|
it 'returns Pending' do
|
|
|
|
message = build(:broadcast_message, :future)
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2016-01-19 16:12:03 +05:30
|
|
|
expect(helper.broadcast_message_status(message)).to eq 'Pending'
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|