osem-fcy/spec/features/lodgings_spec.rb

62 lines
2 KiB
Ruby
Raw Normal View History

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-08-12 15:48:29 +03:00
shared_examples 'lodgings' do
2014-06-14 21:48:43 +05:30
scenario 'adds and updates lodgings', feature: true, js: true do
path = "#{Rails.root}/app/assets/images/rails.png"
2014-08-12 15:48:29 +03:00
2014-06-14 21:48:43 +05:30
conference.venue = create(:venue)
2014-08-12 15:48:29 +03:00
sign_in organizer
2014-06-14 21:48:43 +05:30
visit admin_conference_lodgings_path(
conference_id: conference.short_title)
# Add lodging
click_link 'Add lodging'
expect(page.all('div.nested-fields').count == 1).to be true
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
set('Example Hotel')
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea').
set('Lorem Ipsum Dolor')
2014-06-14 23:32:52 +05:30
2014-06-14 21:48:43 +05:30
attach_file 'Photo', path
2014-06-14 23:32:52 +05:30
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(4) input').
set('http://www.example.com')
2014-06-14 21:48:43 +05:30
click_button 'Update Venue'
# Validations
expect(flash).to eq('Lodgings were successfully updated.')
2014-06-14 23:32:52 +05:30
2014-06-14 21:48:43 +05:30
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
value).to eq('Example Hotel')
2014-06-14 23:32:52 +05:30
2014-06-14 21:48:43 +05:30
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea').
value).to eq('Lorem Ipsum Dolor')
2014-06-14 23:32:52 +05:30
2014-06-14 21:48:43 +05:30
expect(page).to have_selector("img[src*='rails.png']")
2014-06-14 23:32:52 +05:30
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(4) input').
value).to eq('http://www.example.com')
2014-06-14 21:48:43 +05:30
# Remove room
click_link 'Remove lodging'
expect(page.all('div.nested-fields').count == 0).to be true
click_button 'Update Venue'
expect(flash).to eq('Lodgings were successfully updated.')
expect(page.all('div.nested-fields').count == 0).to be true
end
end
describe 'organizer' do
2014-08-12 15:48:29 +03:00
it_behaves_like 'lodgings'
2014-06-14 21:48:43 +05:30
end
end