mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
55 lines
1.7 KiB
Ruby
55 lines
1.7 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe ApplicationHelper, type: :helper do
|
|
let(:conference) { create(:conference) }
|
|
let(:event) { create(:event, program: conference.program) }
|
|
|
|
describe 'format_datetme' do
|
|
it 'returns nothing if there is no parameter' do
|
|
expect(format_datetime(nil)).to eq nil
|
|
end
|
|
|
|
it 'returns formatted string' do
|
|
datetime = Time.zone.local(2016, 05, 04, 11, 30)
|
|
expect(format_datetime(datetime)).to eq '2016-05-04 11:30'
|
|
end
|
|
end
|
|
|
|
describe 'show_roles' do
|
|
it 'formats the hash passed' do
|
|
roles = { 'organizer' => ['oSC16', 'oSC15'], 'cfp' => ['oSC16'] }
|
|
expect(show_roles(roles)).to eq 'Organizer (oSC16, oSC15), Cfp (oSC16)'
|
|
end
|
|
end
|
|
|
|
describe 'markdown' do
|
|
it 'should return empty string for nil' do
|
|
expect(markdown(nil)).to eq ''
|
|
end
|
|
|
|
it 'should return HTML for header markdown' do
|
|
expect(Redcarpet::Markdown).to receive(:new).
|
|
with(Redcarpet::Render::HTML, autolink: true,
|
|
space_after_headers: true,
|
|
no_intra_emphasis: true).
|
|
and_call_original
|
|
|
|
expect(markdown('# this is my header')).to eq "<h1>this is my header</h1>\n"
|
|
end
|
|
end
|
|
|
|
describe '#registered_text' do
|
|
describe 'returns correct string' do
|
|
it 'when there are no registrations' do
|
|
expect(registered_text(event)).to eq 'Registered: 0'
|
|
end
|
|
|
|
it 'when there is 1 registration' do
|
|
event.require_registration = true
|
|
event.max_attendees = 3
|
|
event.registrations << create(:registration, user: event.submitter)
|
|
expect(registered_text(event)).to eq 'Registered: 1/3'
|
|
end
|
|
end
|
|
end
|
|
end
|