osem-fcy/spec/features/lodgings_spec.rb

79 lines
2.3 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
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) { create(:organizer, resource: conference) }
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'
2016-05-02 17:39:06 +02:00
fill_in 'lodging_website_link', with: 'http://www.google.com'
2016-04-27 17:34:17 +02:00
attach_file 'Picture', path
2014-11-12 12:00:03 +01:00
click_button 'Create Lodging'
page.find('#flash')
2014-11-12 12:00:03 +01:00
# 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"
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)
2016-05-02 17:39:06 +02:00
expect(page.has_content?(CGI.escapeHTML(lodging.name))).to be true
2014-11-12 12:00:03 +01:00
# Add lodging
click_link 'Edit'
fill_in 'lodging_name', with: 'New lodging'
2016-05-02 15:25:18 +02:00
fill_in 'lodging_website_link', with: 'http://www.google.com'
2016-04-27 17:34:17 +02:00
attach_file 'Picture', path
2014-11-12 12:00:03 +01:00
click_button 'Update Lodging'
page.find('#flash')
2014-11-12 12:00:03 +01:00
# 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')
2016-05-02 17:39:06 +02:00
expect(lodging.description).to eq(CGI.escapeHTML(lodging.description))
2016-05-02 15:25:18 +02:00
expect(lodging.website_link).to eq('http://www.google.com')
2014-11-12 12:00:03 +01:00
expect(Lodging.count).to eq(1)
end
scenario 'Delete a lodging', feature: true, js: true do
2016-05-02 15:25:18 +02: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)
2016-05-02 15:25:18 +02:00
expect(page.has_content?(lodging.name)).to be true
2014-11-12 12:00:03 +01:00
page.accept_alert do
click_link 'Delete'
end
page.find('#flash')
2014-11-12 12:00:03 +01:00
# Validations
expect(flash).to eq('Lodging successfully deleted.')
2016-05-02 17:39:06 +02:00
expect(page.has_content?(CGI.escapeHTML(lodging.name))).to be false
2014-11-12 12:00:03 +01:00
expect(Lodging.count).to eq(0)
2014-06-14 21:48:43 +05:30
end
end