osem-fcy/spec/features/conference_spec.rb

77 lines
2.4 KiB
Ruby
Raw Normal View History

require 'spec_helper'
feature Conference do
2014-08-12 15:48:29 +03:00
let!(:user) { create(:admin) }
2014-08-12 15:48:29 +03:00
shared_examples 'add and update conference' do
scenario 'adds a new conference', feature: true, js: true do
expected_count = Conference.count + 1
2014-08-12 15:48:29 +03:00
sign_in user
visit new_admin_conference_path
fill_in 'conference_title', with: 'Example Con'
fill_in 'conference_short_title', with: 'ExCon'
2014-05-10 18:47:16 +02:00
select('(GMT+01:00) Berlin', from: 'conference[timezone]')
2014-05-14 17:27:42 +02:00
today = Date.today - 1
2017-04-06 23:19:58 -04:00
page
.execute_script("$('#conference-start-datepicker').val('" +
2014-05-14 17:27:42 +02:00
"#{today.strftime('%d/%m/%Y')}')")
2017-04-06 23:19:58 -04:00
page
.execute_script("$('#conference-end-datepicker').val('" +
2014-05-14 17:27:42 +02:00
"#{(today + 7).strftime('%d/%m/%Y')}')")
click_button 'Create Conference'
2017-04-06 23:19:58 -04:00
expect(flash)
.to eq('Conference was successfully created.')
expect(Conference.count).to eq(expected_count)
2014-08-12 15:48:29 +03:00
expect(user.has_role? :organizer, Conference.last).to eq(true)
end
scenario 'update conference', feature: true, js: true do
conference = create(:conference)
organizer_role = Role.find_by(name: 'organizer', resource: conference)
2014-08-12 15:48:29 +03:00
organizer = create(:user, role_ids: [organizer_role.id])
expected_count = Conference.count
2014-08-12 15:48:29 +03:00
sign_in organizer
visit edit_admin_conference_path(conference.short_title)
2014-08-07 21:33:08 +02:00
fill_in 'conference_title', with: 'New Con'
fill_in 'conference_short_title', with: ''
click_button 'Update Conference'
2017-04-06 23:19:58 -04:00
expect(flash)
.to eq("Updating conference failed. Short title can't be blank.")
2014-08-07 21:33:08 +02:00
fill_in 'conference_title', with: 'New Con'
fill_in 'conference_short_title', with: 'NewCon'
day = Date.today + 10
2017-04-06 23:19:58 -04:00
page
.execute_script("$('#conference-start-datepicker').val('" +
"#{day.strftime('%d/%m/%Y')}')")
2017-04-06 23:19:58 -04:00
page
.execute_script("$('#conference-end-datepicker').val('" +
"#{(day + 7).strftime('%d/%m/%Y')}')")
click_button 'Update Conference'
2017-04-06 23:19:58 -04:00
expect(flash)
.to eq('Conference was successfully updated.')
conference.reload
expect(conference.title).to eq('New Con')
expect(conference.short_title).to eq('NewCon')
expect(Conference.count).to eq(expected_count)
end
end
describe 'admin' do
2014-08-12 15:48:29 +03:00
it_behaves_like 'add and update conference'
end
end