2014-05-14 15:56:22 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
feature Conference do
|
|
|
|
|
|
2014-08-12 15:48:29 +03:00
|
|
|
let!(:conference) { create(:conference) }
|
2015-01-12 23:13:10 +02:00
|
|
|
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
2014-08-12 15:48:29 +03:00
|
|
|
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
|
2014-05-14 15:56:22 +02:00
|
|
|
|
2014-08-12 15:48:29 +03:00
|
|
|
shared_examples 'add and update cfp' do
|
2014-05-14 15:56:22 +02:00
|
|
|
scenario 'adds a new cfp', feature: true, js: true do
|
2015-10-25 13:29:02 +02:00
|
|
|
expected_count = Cfp.count + 1
|
2014-08-12 15:48:29 +03:00
|
|
|
|
|
|
|
|
sign_in organizer
|
2014-05-14 15:56:22 +02:00
|
|
|
|
2015-10-25 13:29:02 +02:00
|
|
|
visit new_admin_conference_program_cfp_path(conference.short_title)
|
2014-05-14 15:56:22 +02:00
|
|
|
|
2015-10-25 13:29:02 +02:00
|
|
|
click_button 'Create Cfp'
|
2014-05-14 15:56:22 +02:00
|
|
|
|
2017-04-06 23:19:58 -04:00
|
|
|
expect(flash)
|
|
|
|
|
.to eq('Creating the call for papers failed. ' +
|
2014-06-04 16:47:50 +02:00
|
|
|
"Start date can't be blank. End date can't be blank.")
|
2014-05-14 15:56:22 +02:00
|
|
|
|
|
|
|
|
today = Date.today - 1
|
|
|
|
|
page.execute_script(
|
2016-06-15 20:46:30 +05:30
|
|
|
"$('#registration-period-start-datepicker').val('#{today.strftime('%d/%m/%Y')}')")
|
2014-05-14 15:56:22 +02:00
|
|
|
page.execute_script(
|
2016-06-15 20:46:30 +05:30
|
|
|
"$('#registration-period-end-datepicker').val('#{(today + 6).strftime('%d/%m/%Y')}')")
|
2014-05-14 15:56:22 +02:00
|
|
|
|
2015-10-25 13:29:02 +02:00
|
|
|
click_button 'Create Cfp'
|
2014-05-14 15:56:22 +02:00
|
|
|
|
|
|
|
|
# Validations
|
2017-04-06 23:19:58 -04:00
|
|
|
expect(flash)
|
|
|
|
|
.to eq('Call for papers successfully created.')
|
2014-11-25 10:47:18 +01:00
|
|
|
expect(find('#start_date').text).to eq(today.strftime('%A, %B %-d. %Y'))
|
2014-11-29 20:00:26 +02:00
|
|
|
expect(find('#end_date').text).to eq((today + 6).strftime('%A, %B %-d. %Y'))
|
2014-11-25 10:47:18 +01:00
|
|
|
|
2015-10-25 13:29:02 +02:00
|
|
|
expect(Cfp.count).to eq(expected_count)
|
2014-05-14 15:56:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'update cfp', feature: true, js: true do
|
2015-10-25 13:29:02 +02:00
|
|
|
conference.program.cfp = create(:cfp)
|
|
|
|
|
expected_count = Cfp.count
|
2014-05-14 15:56:22 +02:00
|
|
|
|
2014-08-12 15:48:29 +03:00
|
|
|
sign_in organizer
|
2015-10-25 13:29:02 +02:00
|
|
|
visit admin_conference_program_cfp_path(conference.short_title)
|
2014-11-25 10:47:18 +01:00
|
|
|
click_link 'Edit'
|
2014-05-14 15:56:22 +02:00
|
|
|
|
|
|
|
|
# Validate update with empty start date will not saved
|
|
|
|
|
page.execute_script(
|
2016-06-15 20:46:30 +05:30
|
|
|
"$('#registration-period-start-datepicker').val('')")
|
2015-10-25 13:29:02 +02:00
|
|
|
click_button 'Update Cfp'
|
2017-04-06 23:19:58 -04:00
|
|
|
expect(flash)
|
|
|
|
|
.to eq('Updating call for papers failed. ' +
|
2014-05-14 15:56:22 +02:00
|
|
|
"Start date can't be blank.")
|
|
|
|
|
|
|
|
|
|
# Fill in date
|
2014-11-29 20:00:26 +02:00
|
|
|
today = Date.today - 9
|
2014-05-14 15:56:22 +02:00
|
|
|
page.execute_script(
|
2016-06-15 20:46:30 +05:30
|
|
|
"$('#registration-period-start-datepicker').val('#{today.strftime('%d/%m/%Y')}')")
|
2014-05-14 15:56:22 +02:00
|
|
|
page.execute_script(
|
2016-06-15 20:46:30 +05:30
|
|
|
"$('#registration-period-end-datepicker').val('#{(today + 14).strftime('%d/%m/%Y')}')")
|
2014-05-14 15:56:22 +02:00
|
|
|
|
2015-10-25 13:29:02 +02:00
|
|
|
click_button 'Update Cfp'
|
2014-05-14 15:56:22 +02:00
|
|
|
|
|
|
|
|
# Validations
|
2017-04-06 23:19:58 -04:00
|
|
|
expect(flash)
|
|
|
|
|
.to eq('Call for papers successfully updated.')
|
2014-11-25 10:47:18 +01:00
|
|
|
expect(find('#start_date').text).to eq(today.strftime('%A, %B %-d. %Y'))
|
|
|
|
|
expect(find('#end_date').text).to eq((today + 14).strftime('%A, %B %-d. %Y'))
|
2015-10-25 13:29:02 +02:00
|
|
|
expect(Cfp.count).to eq(expected_count)
|
2014-05-14 15:56:22 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2014-08-12 11:51:59 +03:00
|
|
|
describe 'organizer' do
|
2014-08-12 15:48:29 +03:00
|
|
|
it_behaves_like 'add and update cfp'
|
2014-05-14 15:56:22 +02:00
|
|
|
end
|
|
|
|
|
end
|