mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-13 14:46:05 +10:00
Update broadcast_message helper
Now it returns the fully-formatted message so we can be consistent about how it's shown.
This commit is contained in:
@@ -1,22 +1,40 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe BroadcastMessagesHelper do
|
||||
describe 'broadcast_styling' do
|
||||
let(:broadcast_message) { double(color: '', font: '') }
|
||||
|
||||
context "default style" do
|
||||
it "should have no style" do
|
||||
expect(broadcast_styling(broadcast_message)).to eq ''
|
||||
end
|
||||
describe 'broadcast_message' do
|
||||
it 'returns nil when no current message' do
|
||||
expect(helper.broadcast_message(nil)).to be_nil
|
||||
end
|
||||
|
||||
context "customized style" do
|
||||
let(:broadcast_message) { double(color: "#f2dede", font: '#b94a48') }
|
||||
it 'includes the current message' do
|
||||
current = double(message: 'Current Message')
|
||||
|
||||
it "should have a customized style" do
|
||||
expect(broadcast_styling(broadcast_message)).
|
||||
to match('background-color: #f2dede; color: #b94a48')
|
||||
end
|
||||
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
|
||||
|
||||
expect(helper.broadcast_message_style(broadcast_message)).to eq ''
|
||||
end
|
||||
|
||||
it 'allows custom style' do
|
||||
broadcast_message = double(color: '#f2dede', font: '#b94a48')
|
||||
|
||||
expect(helper.broadcast_message_style(broadcast_message)).
|
||||
to match('background-color: #f2dede; color: #b94a48')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user