osem-fcy/spec/features/commercials_spec.rb

67 lines
2.3 KiB
Ruby
Raw Normal View History

require 'spec_helper'
feature Commercial do
# It is necessary to use bang version of let to build roles before user
2014-08-12 11:51:59 +03:00
let!(:conference) { create(:conference) }
2014-08-12 15:48:29 +03:00
let!(:organizer_role) { create(:organizer_role, resource: conference) }
2014-08-12 11:51:59 +03:00
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
2014-08-12 11:51:59 +03:00
shared_examples 'adds and updates a commercial' do
scenario 'of a conference',
feature: true, js: true do
expected_count = conference.commercials.count + 1
2014-08-12 11:51:59 +03:00
sign_in organizer
visit admin_conference_commercials_path(conference.short_title)
click_link 'New Commercial'
# Create without an commercial id
select('SlideShare', from: 'commercial_commercial_type')
click_button 'Create Commercial'
expect(flash).to eq("A error prohibited this Commercial from being saved: Commercial can't be blank.")
expect(conference.commercials.count).to eq(expected_count - 1)
# Create valid commercial
select('SlideShare', from: 'commercial_commercial_type')
fill_in 'commercial_commercial_id', with: '12345'
click_button 'Create Commercial'
expect(flash).to eq('Commercial was successfully created.')
expect(conference.commercials.count).to eq(expected_count)
expect(page.has_content?('SlideShare')).to be true
click_link 'Edit'
# Update without an commercial id
select('YouTube', from: 'commercial_commercial_type')
fill_in 'commercial_commercial_id', with: ''
click_button 'Update Commercial'
expect(flash).to eq("A error prohibited this Commercial from being saved: Commercial can't be blank.")
expect(conference.commercials.count).to eq(expected_count)
# Update valid commercial
select('YouTube', from: 'commercial_commercial_type')
fill_in 'commercial_commercial_id', with: '678910'
click_button 'Update Commercial'
expect(flash).to eq('Commercial was successfully updated.')
expect(conference.commercials.count).to eq(expected_count)
# Delete commercial
click_link 'Delete'
expect(flash).to eq('Commercial was successfully destroyed.')
expect(conference.commercials.count).to eq(expected_count - 1)
end
end
describe 'organizer' do
2014-08-12 11:51:59 +03:00
it_behaves_like 'adds and updates a commercial'
end
end