2014-06-14 21:48:43 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
feature Lodging do
|
2014-08-12 15:48:29 +03:00
|
|
|
let!(:conference) { create(:conference) }
|
|
|
|
|
let!(:organizer_role) { create(:organizer_role, resource: conference) }
|
|
|
|
|
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
|
2014-06-14 21:48:43 +05:30
|
|
|
|
2014-11-12 12:00:03 +01:00
|
|
|
scenario 'Add a lodging', feature: true, js: true do
|
|
|
|
|
path = "#{Rails.root}/app/assets/images/rails.png"
|
|
|
|
|
|
|
|
|
|
sign_in organizer
|
|
|
|
|
visit admin_conference_lodgings_path(
|
|
|
|
|
conference_id: conference.short_title)
|
|
|
|
|
# Add lodging
|
|
|
|
|
click_link 'Add Lodging'
|
|
|
|
|
|
|
|
|
|
fill_in 'lodging_name', with: 'New lodging'
|
|
|
|
|
fill_in 'lodging_website_link', with: 'http:\\www.google.com'
|
|
|
|
|
attach_file 'Photo', path
|
|
|
|
|
|
|
|
|
|
click_button 'Create Lodging'
|
|
|
|
|
|
|
|
|
|
# Validations
|
|
|
|
|
expect(flash).to eq('Lodging successfully created.')
|
|
|
|
|
expect(page.has_content?('New lodging')).to be true
|
|
|
|
|
expect(Lodging.count).to eq(1)
|
2014-06-14 21:48:43 +05:30
|
|
|
end
|
|
|
|
|
|
2014-11-12 12:00:03 +01:00
|
|
|
scenario 'Update a lodging', feature: true, js: true do
|
|
|
|
|
path = "#{Rails.root}/app/assets/images/rails.png"
|
|
|
|
|
|
2014-11-20 14:57:03 +01:00
|
|
|
lodging = create(:lodging, conference: conference)
|
2014-11-12 12:00:03 +01:00
|
|
|
|
|
|
|
|
sign_in organizer
|
|
|
|
|
visit admin_conference_lodgings_path(
|
|
|
|
|
conference_id: conference.short_title)
|
|
|
|
|
|
|
|
|
|
expect(page.has_content?('Example Hotel')).to be true
|
|
|
|
|
|
|
|
|
|
# Add lodging
|
|
|
|
|
click_link 'Edit'
|
|
|
|
|
|
|
|
|
|
fill_in 'lodging_name', with: 'New lodging'
|
|
|
|
|
fill_in 'lodging_website_link', with: 'http:\\www.google.com'
|
|
|
|
|
attach_file 'Photo', path
|
|
|
|
|
|
|
|
|
|
click_button 'Update Lodging'
|
|
|
|
|
|
|
|
|
|
# Validations
|
|
|
|
|
expect(flash).to eq('Lodging successfully updated.')
|
|
|
|
|
expect(page.has_content?('New lodging')).to be true
|
|
|
|
|
lodging.reload
|
|
|
|
|
expect(lodging.name).to eq('New lodging')
|
2014-11-20 14:57:03 +01:00
|
|
|
expect(lodging.description).to eq('Lorem Ipsum Dolor')
|
2014-11-12 12:00:03 +01:00
|
|
|
expect(lodging.website_link).to eq('http:\\www.google.com')
|
|
|
|
|
expect(Lodging.count).to eq(1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'Delete a lodging', feature: true, js: true do
|
2014-11-20 14:57:03 +01:00
|
|
|
conference.lodgings << create(:lodging)
|
2014-11-12 12:00:03 +01:00
|
|
|
|
|
|
|
|
sign_in organizer
|
|
|
|
|
visit admin_conference_lodgings_path(
|
|
|
|
|
conference_id: conference.short_title)
|
|
|
|
|
|
|
|
|
|
expect(page.has_content?('Example Hotel')).to be true
|
|
|
|
|
|
|
|
|
|
# Add lodging
|
|
|
|
|
click_link 'Delete'
|
|
|
|
|
|
|
|
|
|
# Validations
|
|
|
|
|
expect(flash).to eq('Lodging successfully deleted.')
|
|
|
|
|
expect(page.has_content?('Example Hotel')).to be false
|
|
|
|
|
expect(Lodging.count).to eq(0)
|
2014-06-14 21:48:43 +05:30
|
|
|
end
|
|
|
|
|
end
|