osem-fcy/spec/features/volunteers_spec.rb

123 lines
5 KiB
Ruby
Raw Normal View History

2014-05-15 17:28:08 +05:30
require 'spec_helper'
feature Conference do
2014-08-12 15:48:29 +03:00
let!(:conference) { create(:conference) }
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-30 14:12:53 +05:30
2014-07-21 14:37:26 +02:00
shared_examples 'volunteer' do
2014-05-15 17:28:08 +05:30
scenario 'adds and updates vdays', feature: true, js: true do
2014-08-12 11:51:59 +03:00
sign_in(organizer)
2014-05-15 17:28:08 +05:30
visit admin_conference_volunteers_info_path(
conference_id: conference.short_title)
check('Enable Volunteering')
check('Use vdays')
2016-01-13 12:33:37 +02:00
# click_link 'Add vday'
# expect(page.all('div.nested-fields').count == 1).to be true
# page.
# find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)').
# select("#{Date.today.strftime('%Y')}")
# page.
# find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)').
# select("#{Date.today.strftime('%B')}")
# page.
# find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)').
# select("#{Date.today.strftime('%-d')}")
# page.
# find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea').
# set('Example Person')
2014-05-15 17:28:08 +05:30
click_button 'Update Conference'
2017-04-06 23:19:58 -04:00
expect(flash)
.to eq('Volunteering options were successfully updated.')
2014-05-15 17:28:08 +05:30
2016-01-13 12:33:37 +02:00
# # Validations
# expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)').
# value).to eq("#{Date.today.strftime('%Y')}")
# expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)').
# value).to eq("#{Date.today.month}")
# expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)').
# value).to eq("#{Date.today.strftime('%-d')}")
# expect(
# find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea').
# value).to eq('Example Person')
#
# # Remove vday
# click_link 'Remove vday'
# expect(page.all('div.nested-fields').count == 0).to be true
2014-05-15 17:28:08 +05:30
click_button 'Update Conference'
expect(flash).to eq('Volunteering options were successfully updated.')
expect(page.all('div.nested-fields').count == 0).to be true
sign_out
end
scenario 'adds and updates vpositions', feature: true, js: true do
2014-08-12 11:51:59 +03:00
sign_in(organizer)
2014-05-15 17:28:08 +05:30
visit admin_conference_volunteers_info_path(
conference_id: conference.short_title)
2014-05-30 14:12:53 +05:30
2014-05-15 17:28:08 +05:30
# Adding vday
check('Enable Volunteering')
check('Use vdays')
2016-01-13 12:33:37 +02:00
# click_link 'Add vday'
# expect(page.all('div.nested-fields').count == 1).to be true
# page.
# find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)').
# select("#{Date.today.strftime('%Y')}")
# page.
# find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)').
# select("#{Date.today.strftime('%B')}")
# page.
# find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)').
# select("#{Date.today.strftime('%-d')}")
# page.
# find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea').
# set('Example Person')
2014-05-15 17:28:08 +05:30
click_button 'Update Conference'
2017-04-06 23:19:58 -04:00
expect(flash)
.to eq('Volunteering options were successfully updated.')
2014-05-30 14:12:53 +05:30
2014-05-15 17:28:08 +05:30
# Add vposition
check('Use vpositions')
2016-01-13 12:33:37 +02:00
# click_link 'Add vposition'
# expect(page.all('div.nested-fields').count == 2).to be true
# page.find('div.vpositions div.nested-fields:nth-of-type(1)'\
# ' div:nth-of-type(1) input').
# set('Example Position')
# page.find('div.vpositions div.nested-fields:nth-of-type(1)'\
# ' div:nth-of-type(2) textarea').
# set('Example Description')
# find(:css, "select[id^='conference_vpositions_attributes_']"\
# "[id$='_vday_ids']").
# find(:option, "#{Date.today.strftime}").select_option
2014-05-15 17:28:08 +05:30
click_button 'Update Conference'
2017-04-06 23:19:58 -04:00
expect(flash)
.to eq('Volunteering options were successfully updated.')
2014-05-15 17:28:08 +05:30
# Validations
2016-01-13 12:33:37 +02:00
# expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\
# ' div:nth-of-type(1) input').
# value).to eq('Example Position')
# expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\
# ' div:nth-of-type(2) textarea').
# value).to eq('Example Description')
#
# expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\
# ' div:nth-of-type(3) select:nth-of-type(1)').find('option[selected]').
# text).to eq(Date.today.strftime)
2014-05-15 17:28:08 +05:30
# Remove vposition
2016-01-13 12:33:37 +02:00
# click_link 'Remove vposition'
# expect(page.all('div.nested-fields').count == 1).to be true
# click_button 'Update Conference'
2014-05-15 17:28:08 +05:30
expect(flash).to eq('Volunteering options were successfully updated.')
2016-01-13 12:33:37 +02:00
# click_link 'Remove vday'
# expect(page.all('div.nested-fields').count == 0).to be true
2014-05-15 17:28:08 +05:30
sign_out
end
end
2014-05-30 14:12:53 +05:30
2014-05-15 17:28:08 +05:30
describe 'organizer' do
it_behaves_like 'volunteer', :organizer
end
end