transactional db support for capybara tests!
This commit is contained in:
parent
1b9a12746d
commit
a9e8498abe
7 changed files with 43 additions and 30 deletions
|
|
@ -46,20 +46,15 @@ feature Commercial do
|
|||
|
||||
context 'in public area' do
|
||||
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
|
||||
|
||||
before(:each) do
|
||||
event.event_users = [create(:event_user,
|
||||
user_id: participant.id,
|
||||
event_id: event.id,
|
||||
event_role: 'submitter')]
|
||||
sign_in participant
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
sign_out
|
||||
end
|
||||
|
||||
scenario 'adds a valid commercial of an event', feature: true, versioning: true, js: true do
|
||||
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'
|
||||
|
|
@ -70,7 +65,6 @@ feature Commercial do
|
|||
click_button 'Create Commercial'
|
||||
page.find('#flash')
|
||||
expect(flash).to eq('Commercial was successfully created.')
|
||||
expect(event.commercials.count).to eq(1)
|
||||
end
|
||||
|
||||
scenario 'does not add an invalid commercial of an event', feature: true, js: true do
|
||||
|
|
@ -81,7 +75,7 @@ feature Commercial do
|
|||
expect(page).to have_css("button[type='submit']:disabled", text: 'Create Commercial')
|
||||
end
|
||||
|
||||
scenario 'updates a commercial of an event', feature: true, versioning: 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')
|
||||
|
|
@ -91,12 +85,13 @@ feature Commercial do
|
|||
click_button 'Update'
|
||||
page.find('#flash')
|
||||
expect(flash).to eq('Commercial was successfully updated.')
|
||||
TransactionalCapybara::AjaxHelpers.wait_for_ajax(page)
|
||||
expect(event.commercials.count).to eq(1)
|
||||
commercial.reload
|
||||
expect(commercial.url).to eq('https://www.youtube.com/watch?v=M9bq_alk-sw')
|
||||
end
|
||||
|
||||
scenario 'does not update a commercial of an event with invalid data', feature: true, versioning: true do
|
||||
scenario 'does not update a commercial of an event with invalid data', feature: true do
|
||||
commercial = create(:commercial,
|
||||
commercialable_id: event.id,
|
||||
commercialable_type: 'Event',
|
||||
|
|
@ -112,7 +107,7 @@ feature Commercial do
|
|||
expect(commercial.url).to eq('https://www.youtube.com/watch?v=BTTygyxuGj8')
|
||||
end
|
||||
|
||||
scenario 'deletes a commercial of an event', feature: true, versioning: 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')
|
||||
|
|
@ -123,6 +118,7 @@ feature Commercial do
|
|||
end
|
||||
page.find('#flash')
|
||||
expect(flash).to eq('Commercial was successfully destroyed.')
|
||||
TransactionalCapybara::AjaxHelpers.wait_for_ajax(page)
|
||||
expect(event.commercials.count).to eq(0)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -111,21 +111,19 @@ feature Event do
|
|||
scenario 'signed_in user submits a valid proposal', feature: true, js: true do
|
||||
sign_in participant_without_bio
|
||||
expected_count = Event.count + 1
|
||||
|
||||
visit conference_program_proposals_path(conference.short_title)
|
||||
click_link 'New Proposal'
|
||||
|
||||
fill_in 'event_title', with: 'Example Proposal'
|
||||
|
||||
select('Example Event Type', from: 'event[event_type_id]')
|
||||
|
||||
fill_in 'event_abstract', with: 'Lorem ipsum abstract'
|
||||
click_link 'description_link'
|
||||
fill_in 'event_description', with: 'Lorem ipsum description'
|
||||
|
||||
click_button 'Create Proposal'
|
||||
page.find('#flash')
|
||||
expect(page).to have_content 'Proposal was successfully submitted.'
|
||||
|
||||
TransactionalCapybara::AjaxHelpers.wait_for_ajax(page)
|
||||
expect(current_path).to eq(conference_program_proposals_path(conference.short_title))
|
||||
expect(Event.count).to eq(expected_count)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -319,16 +319,28 @@ feature 'Version' do
|
|||
expect(page).to have_text('created new organization New org')
|
||||
end
|
||||
|
||||
scenario 'display changes in users_role for organization role', feature: true, versioning: true, js: true do
|
||||
user = create(:user)
|
||||
role = Role.find_by(resource_id: conference.organization.id, resource_type: 'Organization')
|
||||
user.add_role :organization_admin, conference.organization
|
||||
user_role = UsersRole.find_by(user_id: user.id, role_id: role.id)
|
||||
user.remove_role :organization_admin, conference.organization
|
||||
context 'organization role', feature: true, versioning: true, js: true do
|
||||
let!(:user) { create(:user) }
|
||||
let!(:role) do
|
||||
Role.find_by(
|
||||
resource_id: conference.organization.id,
|
||||
resource_type: 'Organization'
|
||||
)
|
||||
end
|
||||
|
||||
visit admin_revision_history_path
|
||||
expect(page).to have_text("added role organization_admin with ID #{user_role.id} to user #{user.name} in organization #{conference.organization.name}")
|
||||
expect(page).to have_text("removed role organization_admin with ID #{user_role.id} from user #{user.name} in organization #{conference.organization.name}")
|
||||
setup do
|
||||
user.add_role :organization_admin, conference.organization
|
||||
user.remove_role :organization_admin, conference.organization
|
||||
visit admin_revision_history_path
|
||||
end
|
||||
|
||||
it 'is recorded to history when user is added' do
|
||||
expect(page).to have_text(/added role organization_admin with ID \d+ to user #{user.name} in organization #{conference.organization.name}/)
|
||||
end
|
||||
|
||||
it 'is recorded to history when user is removed' do
|
||||
expect(page).to have_text(/removed role organization_admin with ID \d+ from user #{user.name} in organization #{conference.organization.name}/)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'display changes in users_role for conference role', feature: true, versioning: true, js: true do
|
||||
|
|
@ -383,6 +395,7 @@ feature 'Version' do
|
|||
click_link 'Comments (0)'
|
||||
fill_in 'comment_body', with: 'Sample comment'
|
||||
click_button 'Add Comment'
|
||||
TransactionalCapybara::AjaxHelpers.wait_for_ajax(page)
|
||||
Comment.last.destroy
|
||||
PaperTrail::Version.last.reify.save
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue