2014-05-15 12:47:54 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
feature SupporterLevel do
|
2014-08-12 11:51:59 +03:00
|
|
|
let!(:conference) { create(:conference) }
|
|
|
|
|
let!(:organizer_role) { create(:organizer_role, resource: conference) }
|
|
|
|
|
let!(:user) { create(:user, role_ids: [organizer_role.id]) }
|
2014-05-15 12:47:54 +02:00
|
|
|
|
2014-08-12 11:51:59 +03:00
|
|
|
shared_examples 'supporter levels' do
|
2014-05-15 12:47:54 +02:00
|
|
|
scenario 'adds and updates supporter level', feature: true, js: true do
|
2014-08-12 11:51:59 +03:00
|
|
|
sign_in user
|
|
|
|
|
visit admin_conference_supporter_levels_path(conference_id: conference.short_title)
|
2014-05-15 12:47:54 +02:00
|
|
|
|
|
|
|
|
# Add supporter level
|
|
|
|
|
click_link 'Add supporter_level'
|
|
|
|
|
expect(page.all('div.nested-fields').count == 1).to be true
|
|
|
|
|
|
|
|
|
|
page.
|
|
|
|
|
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
|
|
|
|
|
set('Example supporter level')
|
|
|
|
|
|
|
|
|
|
page.
|
|
|
|
|
find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) input').
|
|
|
|
|
set('http://www.google.de')
|
|
|
|
|
|
|
|
|
|
click_button 'Update Conference'
|
|
|
|
|
|
|
|
|
|
# Validations
|
|
|
|
|
expect(flash).to eq('Supporter levels were successfully updated.')
|
|
|
|
|
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
|
|
|
|
|
value).to eq('Example supporter level')
|
|
|
|
|
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) input').
|
|
|
|
|
value).to eq('http://www.google.de')
|
|
|
|
|
|
|
|
|
|
# Remove supporter level
|
|
|
|
|
click_link 'Remove supporter_level'
|
|
|
|
|
expect(page.all('div.nested-fields').count == 0).to be true
|
|
|
|
|
click_button 'Update Conference'
|
|
|
|
|
expect(flash).to eq('Supporter levels were successfully updated.')
|
|
|
|
|
expect(page.all('div.nested-fields').count == 0).to be true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'organizer' do
|
2014-08-12 11:51:59 +03:00
|
|
|
it_behaves_like 'supporter levels'
|
2014-05-15 12:47:54 +02:00
|
|
|
end
|
|
|
|
|
end
|