mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
67 lines
2.1 KiB
Ruby
67 lines
2.1 KiB
Ruby
require 'spec_helper'
|
|
|
|
feature Conference do
|
|
|
|
# It is necessary to use bang version of let to build roles before user
|
|
let!(:participant_role) { create(:participant_role) }
|
|
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
|
|
|
|
shared_examples 'add and update conference' do |user|
|
|
scenario 'adds a new conference', feature: true, js: true do
|
|
expected_count = Conference.count + 1
|
|
sign_in create(user)
|
|
|
|
visit new_admin_conference_path
|
|
fill_in 'conference_title', with: 'Example Con'
|
|
fill_in 'conference_short_title', with: 'ExCon'
|
|
|
|
select('(GMT+01:00) Berlin', from: 'conference[timezone]')
|
|
|
|
today = Date.today - 1
|
|
page.
|
|
execute_script("$('#conference-start-datepicker').val('" +
|
|
"#{today.strftime('%d/%m/%Y')}')")
|
|
page.
|
|
execute_script("$('#conference-end-datepicker').val('" +
|
|
"#{(today + 7).strftime('%d/%m/%Y')}')")
|
|
|
|
click_button 'Create Conference'
|
|
|
|
expect(flash).
|
|
to eq('Conference was successfully created.')
|
|
expect(Conference.count).to eq(expected_count)
|
|
end
|
|
|
|
scenario 'update conference', feature: true, js: true do
|
|
conference = create(:conference)
|
|
expected_count = Conference.count
|
|
sign_in create(:organizer_conference_1)
|
|
|
|
visit edit_admin_conference_path(conference.short_title)
|
|
click_link 'Edit'
|
|
fill_in 'conference_title', with: 'New Con'
|
|
fill_in 'conference_short_title', with: ''
|
|
|
|
click_button 'Update Conference'
|
|
expect(flash).
|
|
to eq("Updating conference failed. Short title can't be blank.")
|
|
|
|
click_link 'Edit'
|
|
fill_in 'conference_title', with: 'New Con'
|
|
fill_in 'conference_short_title', with: 'NewCon'
|
|
|
|
click_button 'Update Conference'
|
|
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
|
|
it_behaves_like 'add and update conference', :admin
|
|
end
|
|
end
|