osem-fcy/spec/features/sponsor_spec.rb

57 lines
1.9 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'spec_helper'
feature Sponsor do
2014-08-12 15:48:29 +03:00
let!(:conference) { create(:conference) }
let!(:organizer) { create(:organizer, resource: conference) }
2014-08-12 15:48:29 +03:00
shared_examples 'sponsors' do
scenario 'adds and updates sponsors', feature: true, js: true do
path = "#{Rails.root}/app/assets/images/rails.png"
2014-08-12 15:48:29 +03:00
conference.sponsorship_levels << create(:sponsorship_level, conference: conference)
2014-08-12 15:48:29 +03:00
sign_in organizer
visit admin_conference_sponsors_path(
conference_id: conference.short_title)
# Add sponsors
click_link 'Add Sponsor'
fill_in 'sponsor_name', with: 'SUSE'
fill_in 'sponsor_description', with: 'The original provider of the enterprise Linux distribution'
2016-04-27 17:34:17 +02:00
attach_file 'Picture', path
fill_in 'sponsor_website_url', with: 'http://www.suse.com'
2016-05-02 15:25:18 +02:00
select(conference.sponsorship_levels.first.title, from: 'sponsor_sponsorship_level_id')
click_button 'Create Sponsor'
within('#flash') { expect(page).to have_text('Sponsor successfully created.') }
within('table#sponsors') do
expect(page.has_content?('SUSE')).to be true
expect(page.has_content?('The original provider')).to be true
expect(page.has_content?('http://www.suse.com')).to be true
2016-05-02 15:25:18 +02:00
expect(page.has_content?(conference.sponsorship_levels.first.title)).to be true
expect(page).to have_selector("img[src*='rails.png']")
expect(page.assert_selector('tr', count: 2)).to be true
end
# Remove sponsor
2017-10-12 14:06:02 -07:00
visit admin_conference_sponsors_path(
conference_id: conference.short_title
)
within('table#sponsors') do
page.accept_confirm do
click_link 'Delete'
end
end
within('#flash') { expect(page).to have_text('Sponsor successfully deleted.') }
expect(page).to have_no_selector('table#sponsors')
end
end
describe 'organizer' do
2014-08-12 15:48:29 +03:00
it_behaves_like 'sponsors'
end
end