Implement simplified commercials workflow

It's now possible to simply enter the url of the third party provider to enter a commercial.
This commit is contained in:
chrisbr 2015-04-22 21:30:32 +02:00 committed by Christian Bruckmayer
parent fb7ebab5a0
commit 23664119bd
25 changed files with 220 additions and 194 deletions

View file

@ -172,7 +172,7 @@ feature 'Has correct abilities' do
expect(current_path).to eq(root_path)
visit admin_conference_commercials_path(conference2.short_title)
expect(current_path).to eq(admin_conference_commercials_path(conference2.short_title))
expect(current_path).to eq(root_path)
end
scenario 'when user is info desk' do
@ -244,6 +244,6 @@ feature 'Has correct abilities' do
expect(current_path).to eq(admin_conference_questions_path(conference3.short_title))
visit admin_conference_commercials_path(conference3.short_title)
expect(current_path).to eq(admin_conference_commercials_path(conference3.short_title))
expect(current_path).to eq(root_path)
end
end

View file

@ -14,41 +14,24 @@ feature Commercial do
sign_in organizer
visit admin_conference_commercials_path(conference.short_title)
click_link 'Add Commercial'
# Create without an commercial id
select('SlideShare', from: 'commercial_commercial_type')
click_button 'Create Commercial'
expect(flash).to eq("An error prohibited this Commercial from being saved: Commercial can't be blank.")
expect(conference.commercials.count).to eq(expected_count - 1)
# Workaround to enable the 'Create Commercial' button
page.execute_script("$('#commercial_submit_action').prop('disabled', false)")
# Create valid commercial
select('SlideShare', from: 'commercial_commercial_type')
fill_in 'commercial_commercial_id', with: '12345'
fill_in 'commercial_url', with: 'https://www.youtube.com/watch?v=M9bq_alk-sw'
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'
commercial = conference.commercials.where(url: 'https://www.youtube.com/watch?v=M9bq_alk-sw').first
fill_in "commercial_url_#{commercial.id}", with: 'https://www.youtube.com/watch?v=VNkDJk5_9eU'
click_button 'Update'
# 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("An 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)
commercial.reload
expect(commercial.url).to eq 'https://www.youtube.com/watch?v=VNkDJk5_9eU'
# Delete commercial
click_link 'Delete'
@ -75,59 +58,34 @@ feature Commercial do
sign_out
end
scenario 'adds a valid commercial to an event', feature: true, js: true do
scenario 'adds a commercial of an event', feature: true, js: true do
visit edit_conference_proposal_path(conference.short_title, event.id)
click_link 'Commercials'
click_link 'Add Commercial'
fill_in 'commercial_url', with: 'https://www.youtube.com/watch?v=M9bq_alk-sw'
select('SlideShare', from: 'commercial_commercial_type')
fill_in 'commercial_commercial_id', with: '12345'
# Workaround to enable the 'Create Commercial' button
page.execute_script("$('#commercial_submit_action').prop('disabled', false)")
click_button 'Create Commercial'
expect(flash).to eq('Commercial was successfully created.')
expect(event.commercials.count).to eq(@expected_count)
end
scenario 'adds an invalid commercial to an event', feature: true, js: true do
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_proposal_path(conference.short_title, event.id)
click_link 'Commercials'
click_link 'Add Commercial'
select('SlideShare', from: 'commercial_commercial_type')
click_button 'Create Commercial'
expect(event.commercials.count).to eq(@expected_count - 1)
end
scenario 'updates a valid commercial to an event', feature: true, js: true do
create(:commercial,
commercialable_id: event.id,
commercialable_type: 'Event')
visit edit_conference_proposal_path(conference.short_title, event.id)
click_link 'Commercials'
click_link 'Edit'
select('SlideShare', from: 'commercial_commercial_type')
fill_in 'commercial_commercial_id', with: '56789'
click_button 'Update Commercial'
fill_in "commercial_url_#{commercial.id}", with: 'https://www.youtube.com/watch?v=M9bq_alk-sw'
click_button 'Update'
expect(flash).to eq('Commercial was successfully updated.')
expect(event.commercials.count).to eq(@expected_count)
commercial.reload
expect(commercial.url).to eq('https://www.youtube.com/watch?v=M9bq_alk-sw')
end
scenario 'updates a invalid commercial to an event', feature: true, js: true do
create(:commercial,
commercialable_id: event.id,
commercialable_type: 'Event')
visit edit_conference_proposal_path(conference.short_title, event.id)
click_link 'Commercials'
click_link 'Edit'
select('SlideShare', from: 'commercial_commercial_type')
fill_in 'commercial_commercial_id', with: ''
click_button 'Update Commercial'
expect(event.commercials.count).to eq(@expected_count)
end
scenario 'deletes a commercial to an event', feature: true, js: true do
scenario 'deletes a commercial of an event', feature: true, js: true do
create(:commercial,
commercialable_id: event.id,
commercialable_type: 'Event')