osem-fcy/spec/features/rooms_spec.rb

59 lines
1.7 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2014-05-15 13:18:31 +02:00
require 'spec_helper'
feature Room do
2014-08-12 15:48:29 +03:00
let!(:conference) { create(:conference) }
2015-11-07 11:43:36 +02:00
let!(:venue) { create(:venue, conference: conference) }
let!(:organizer) { create(:organizer, resource: conference) }
2014-05-15 13:18:31 +02:00
2014-08-12 15:48:29 +03:00
shared_examples 'rooms' do
2014-11-12 11:37:28 +01:00
scenario 'adds a room', feature: true, js: true do
2014-08-12 15:48:29 +03:00
sign_in organizer
2015-11-07 11:43:36 +02:00
visit admin_conference_venue_rooms_path(
2014-05-15 13:18:31 +02:00
conference_id: conference.short_title)
expect(page.has_no_table?('#rooms')).to be true
2014-11-12 11:37:28 +01:00
2014-05-15 13:18:31 +02:00
# Add room
click_link 'Add Room'
2014-11-12 11:37:28 +01:00
fill_in 'room_name', with: 'Auditorium'
2014-11-12 11:37:28 +01:00
fill_in 'room_size', with: '100'
2014-05-15 13:18:31 +02:00
2014-11-12 11:37:28 +01:00
click_button 'Create Room'
within('#flash') { expect(page).to have_text('Room successfully created.') }
within('table#rooms') do
expect(page.has_content?('Auditorium')).to be true
expect(page.assert_selector('tr', count: 2)).to be true
end
2014-11-12 11:37:28 +01:00
end
scenario 'updates a room', feature: true, js: true do
2015-11-07 11:43:36 +02:00
room = create(:room, venue: venue)
2014-11-12 11:37:28 +01:00
sign_in organizer
2015-11-07 11:43:36 +02:00
visit edit_admin_conference_venue_room_path(
2014-11-12 11:37:28 +01:00
conference_id: conference.short_title, id: room.id)
2014-05-15 13:18:31 +02:00
fill_in 'room_name', with: 'Auditorium'
2014-11-12 11:37:28 +01:00
fill_in 'room_size', with: '100'
2014-05-15 13:18:31 +02:00
2014-11-12 11:37:28 +01:00
click_button 'Update Room'
within('#flash') { expect(page).to have_text('Room successfully updated.') }
within('table#rooms') do
expect(page.has_content?('Auditorium')).to be true
expect(page.assert_selector('tr', count: 2)).to be true
end
2014-11-12 11:37:28 +01:00
room.reload
expect(room.name).to eq('Auditorium')
2014-11-12 11:37:28 +01:00
expect(room.size).to eq(100)
2014-05-15 13:18:31 +02:00
end
end
describe 'organizer' do
2014-08-12 15:48:29 +03:00
it_behaves_like 'rooms'
2014-05-15 13:18:31 +02:00
end
end