Refactoring Conference/Event media to new media object

close #420
This commit is contained in:
Chrisbr 2014-08-05 18:23:42 +02:00
parent 850beb72e1
commit 2a731e8350
31 changed files with 491 additions and 57 deletions

View file

@ -0,0 +1,71 @@
require 'spec_helper'
feature Commercial do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
shared_examples 'adds and updates a commercial' do |user|
scenario 'of a conference',
feature: true, js: true do
conference = create(:conference)
expected_count = conference.commercials.count + 1
sign_in create(user)
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 'admin' do
it_behaves_like 'adds and updates a commercial', :admin
end
describe 'organizer' do
it_behaves_like 'adds and updates a commercial', :organizer
end
end

View file

@ -1,6 +1,6 @@
require 'spec_helper'
feature Event do
feature EmailSettings do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }

View file

@ -33,12 +33,11 @@ feature Event do
fill_in 'event_abstract', with: 'Lorem ipsum abstract'
fill_in 'event_description', with: 'Lorem ipsum description'
select('YouTube', from: 'event[media_type]')
fill_in 'event_media_id', with: '123456'
fill_in 'user_biography', with: 'Lorem ipsum biography'
click_button 'Create Event'
expect(flash).to eq('Event was successfully submitted. You should register for the conference now.')
expect(current_path).to eq(register_conference_path(conference.short_title))
expect(Event.count).to eq(expected_count)
@ -48,6 +47,57 @@ feature Event do
visit conference_proposal_index_path(conference.short_title)
expect(page.has_content?('Example Proposal')).to be true
expected_count_commercial = Commercial.count + 1
# Add a invalid commercial
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(flash).to eq("A error prohibited this Commercial from being saved: Commercial can't be blank.")
expect(event.commercials.count).to eq(expected_count_commercial - 1)
# Add a valid commercial
visit edit_conference_proposal_path(conference.short_title, event.id)
click_link 'Commercials'
click_link 'Add 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(event.commercials.count).to eq(expected_count_commercial)
# Edit an invalid commercial
click_link 'Commercials'
click_link 'Edit'
select('SlideShare', 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(event.commercials.count).to eq(expected_count_commercial)
# Edit a valid commercial
select('SlideShare', from: 'commercial_commercial_type')
fill_in 'commercial_commercial_id', with: '56789'
click_button 'Update Commercial'
expect(flash).to eq('Commercial was successfully updated.')
expect(event.commercials.count).to eq(expected_count_commercial)
# Delete a commercial
click_link 'Commercials'
click_link 'Delete'
expect(flash).to eq('Commercial was successfully destroyed.')
expect(event.commercials.count).to eq(expected_count_commercial - 1)
sign_out
sign_in admin