2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2014-08-05 18:23:42 +02:00
|
|
|
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) }
|
2018-10-18 12:01:42 -07:00
|
|
|
let!(:cfp) { create(:cfp, program: conference.program) }
|
2019-03-13 10:31:42 +01:00
|
|
|
let!(:organizer) { create(:organizer, resource: conference) }
|
2014-08-28 15:21:05 +02:00
|
|
|
let!(:participant) { create(:user) }
|
2022-02-23 17:52:16 +01:00
|
|
|
let!(:event) { create(:event, program: conference.program, title: 'Example Proposal') }
|
|
|
|
|
let!(:event_user) do
|
|
|
|
|
create(:event_user, user: participant, event: event, event_role: 'submitter')
|
|
|
|
|
end
|
2014-08-05 18:23:42 +02:00
|
|
|
|
2022-02-23 17:52:16 +01:00
|
|
|
before(:each) do
|
|
|
|
|
sign_in participant
|
|
|
|
|
end
|
2014-08-05 18:23:42 +02:00
|
|
|
|
2022-02-23 17:52:16 +01:00
|
|
|
scenario 'adds a valid commercial of an event', feature: true, js: true do
|
|
|
|
|
visit edit_conference_program_proposal_path(conference.short_title, event.id)
|
|
|
|
|
click_link 'Commercials'
|
|
|
|
|
fill_in 'commercial_url', with: 'https://www.youtube.com/watch?v=M9bq_alk-sw'
|
2018-10-25 16:16:56 -07:00
|
|
|
|
2022-02-23 17:52:16 +01:00
|
|
|
# Workaround to enable the 'Create Commercial' button
|
|
|
|
|
page.execute_script("$('#commercial_submit_action').prop('disabled', false)")
|
2014-08-05 18:23:42 +02:00
|
|
|
|
2022-02-23 17:52:16 +01:00
|
|
|
click_button 'Create Commercial'
|
2025-08-06 13:04:53 +02:00
|
|
|
within('#flash') { expect(page).to have_text('Commercial was successfully created.') }
|
2014-08-05 18:23:42 +02:00
|
|
|
end
|
|
|
|
|
|
2022-02-23 17:52:16 +01:00
|
|
|
scenario 'updates a commercial of an event', feature: true, js: true do
|
|
|
|
|
commercial = create(:commercial,
|
|
|
|
|
commercialable_id: event.id,
|
|
|
|
|
commercialable_type: 'Event')
|
|
|
|
|
visit edit_conference_program_proposal_path(conference.short_title, event.id)
|
|
|
|
|
click_link 'Commercials'
|
|
|
|
|
within('.thumbnail') do
|
2015-04-22 21:30:32 +02:00
|
|
|
fill_in 'commercial_url', with: 'https://www.youtube.com/watch?v=M9bq_alk-sw'
|
|
|
|
|
# Workaround to enable the 'Create Commercial' button
|
|
|
|
|
page.execute_script("$('#commercial_submit_action').prop('disabled', false)")
|
2022-02-23 17:52:16 +01:00
|
|
|
click_button 'Update Commercial'
|
2016-03-31 16:07:26 +05:30
|
|
|
end
|
2025-08-06 13:04:53 +02:00
|
|
|
within('#flash') { expect(page).to have_text('Commercial was successfully updated.') }
|
2022-02-23 17:52:16 +01:00
|
|
|
expect(event.commercials.count).to eq(1)
|
|
|
|
|
commercial.reload
|
|
|
|
|
expect(commercial.url).to eq('https://www.youtube.com/watch?v=M9bq_alk-sw')
|
|
|
|
|
end
|
2016-03-31 16:07:26 +05:30
|
|
|
|
2022-02-23 17:52:16 +01:00
|
|
|
scenario 'deletes a commercial of an event', feature: true, js: true do
|
|
|
|
|
create(:commercial,
|
|
|
|
|
commercialable_id: event.id,
|
|
|
|
|
commercialable_type: 'Event')
|
|
|
|
|
visit edit_conference_program_proposal_path(conference.short_title, event.id)
|
|
|
|
|
click_link 'Commercials'
|
|
|
|
|
page.accept_alert do
|
|
|
|
|
click_link 'Delete'
|
2014-08-28 15:21:05 +02:00
|
|
|
end
|
2025-08-06 13:04:53 +02:00
|
|
|
within('#flash') { expect(page).to have_text('Commercial was successfully destroyed.') }
|
2022-02-23 17:52:16 +01:00
|
|
|
expect(event.commercials.count).to eq(0)
|
2014-08-05 18:23:42 +02:00
|
|
|
end
|
|
|
|
|
end
|