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) }
|
|
|
|
|
let!(:organizer_role) { create(:organizer_role, resource: conference) }
|
|
|
|
|
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
|
2014-11-25 10:47:18 +01:00
|
|
|
expected_count = CallForPaper.count + 1
|
2014-08-12 15:48:29 +03:00
|
|
|
|
|
|
|
|
sign_in organizer
|
2014-05-14 15:56:22 +02:00
|
|
|
|
2014-11-25 10:47:18 +01:00
|
|
|
visit new_admin_conference_call_for_paper_path(conference.short_title)
|
2014-05-14 15:56:22 +02:00
|
|
|
|
2014-11-25 10:47:18 +01:00
|
|
|
click_button 'Create Call for paper'
|
2014-05-14 15:56:22 +02: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(
|
|
|
|
|
"$('#conference-start-datepicker').val('#{today.strftime('%d/%m/%Y')}')")
|
|
|
|
|
page.execute_script(
|
|
|
|
|
"$('#conference-end-datepicker').val('#{(today + 7).strftime('%d/%m/%Y')}')")
|
|
|
|
|
|
2014-11-25 10:47:18 +01:00
|
|
|
fill_in 'call_for_paper_rating', with: '4'
|
2014-05-14 15:56:22 +02:00
|
|
|
|
2014-11-25 10:47:18 +01:00
|
|
|
click_button 'Create Call for paper'
|
2014-05-14 15:56:22 +02:00
|
|
|
|
|
|
|
|
# Validations
|
|
|
|
|
expect(flash).
|
2014-11-25 10:47:18 +01:00
|
|
|
to eq('Call for papers successfully created.')
|
|
|
|
|
expect(find('#start_date').text).to eq(today.strftime('%A, %B %-d. %Y'))
|
|
|
|
|
expect(find('#end_date').text).to eq((today + 7).strftime('%A, %B %-d. %Y'))
|
|
|
|
|
expect(find('#rating').text).to eq('4')
|
|
|
|
|
|
|
|
|
|
expect(CallForPaper.count).to eq(expected_count)
|
2014-05-14 15:56:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'update cfp', feature: true, js: true do
|
2014-11-25 10:47:18 +01:00
|
|
|
conference.call_for_paper = create(:call_for_paper)
|
|
|
|
|
expected_count = CallForPaper.count
|
2014-05-14 15:56:22 +02:00
|
|
|
|
2014-08-12 15:48:29 +03:00
|
|
|
sign_in organizer
|
2014-11-25 10:47:18 +01:00
|
|
|
visit admin_conference_call_for_paper_path(conference.short_title)
|
|
|
|
|
click_link 'Edit'
|
2014-05-14 15:56:22 +02:00
|
|
|
|
|
|
|
|
# Validate update with empty start date will not saved
|
|
|
|
|
page.execute_script(
|
|
|
|
|
"$('#conference-start-datepicker').val('')")
|
2014-11-25 10:47:18 +01:00
|
|
|
click_button 'Update Call for paper'
|
2014-05-14 15:56:22 +02:00
|
|
|
expect(flash).
|
|
|
|
|
to eq('Updating call for papers failed. ' +
|
|
|
|
|
"Start date can't be blank.")
|
|
|
|
|
|
|
|
|
|
# Fill in date
|
|
|
|
|
today = Date.today - 7
|
|
|
|
|
page.execute_script(
|
|
|
|
|
"$('#conference-start-datepicker').val('#{today.strftime('%d/%m/%Y')}')")
|
|
|
|
|
page.execute_script(
|
|
|
|
|
"$('#conference-end-datepicker').val('#{(today + 14).strftime('%d/%m/%Y')}')")
|
|
|
|
|
|
2014-11-25 10:47:18 +01:00
|
|
|
fill_in 'call_for_paper_rating', with: '0'
|
|
|
|
|
click_button 'Update Call for paper'
|
2014-05-14 15:56:22 +02:00
|
|
|
|
|
|
|
|
# Validations
|
|
|
|
|
expect(flash).
|
2014-11-25 10:47:18 +01:00
|
|
|
to eq('Call for papers successfully updated.')
|
|
|
|
|
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'))
|
|
|
|
|
expect(find('#rating').text).to eq('0')
|
|
|
|
|
expect(CallForPaper.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
|