This commit is contained in:
Gopesh Tulsyan 2014-06-11 10:34:56 +00:00
commit 78d5bd670d
28 changed files with 333 additions and 22 deletions

View file

@ -9,5 +9,6 @@ FactoryGirl.define do
contact_email 'admin@example.com'
start_date Date.today
end_date Date.tomorrow
venue
end
end

View file

@ -0,0 +1,10 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :lodging do
name 'Example Hotel'
description 'Lorem Ipsum Dolor'
website_link 'http://www.example.com'
venue
end
end

View file

@ -4,5 +4,6 @@ FactoryGirl.define do
name 'Suse Office'
address 'Maxfeldstrasse 5 \n90409 Nuremberg'
website 'www.opensuse.org'
description 'Lorem Ipsum Dolor'
end
end

View file

@ -0,0 +1,59 @@
require 'spec_helper'
feature Lodging do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
shared_examples 'lodgings' do |user|
scenario 'adds and updates lodgings', feature: true, js: true do
path = "#{Rails.root}/app/assets/images/rails.png"
conference = create(:conference)
conference.venue = create(:venue)
sign_in create(user)
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')
attach_file 'Photo', path
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(4) input').
set('http://www.example.com')
click_button 'Update Venue'
# Validations
expect(flash).to eq('Lodgings were successfully updated.')
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
value).to eq('Example Hotel')
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea').
value).to eq('Lorem Ipsum Dolor')
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(4) input').
value).to eq('http://www.example.com')
expect(page).to have_selector("img[src*='rails.png']")
# 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 'admin' do
it_behaves_like 'lodgings', :admin
end
describe 'organizer' do
it_behaves_like 'lodgings', :organizer
end
end

View file

@ -0,0 +1,5 @@
require 'spec_helper'
describe Lodging do
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -0,0 +1,14 @@
require 'spec_helper'
describe 'admin/lodgings/index' do
it 'renders lodgings list' do
@conference = create(:conference)
@conference.venue = create(:venue)
@conference.venue.lodgings << create(:lodging, venue: @conference.venue)
assign :venue, @conference.venue
render
expect(rendered).to include('Example Hotel')
expect(rendered).to include('Lorem Ipsum Dolor')
expect(rendered).to include('http://www.example.com')
end
end

View file

@ -5,13 +5,15 @@ describe 'conference/show.html.haml' do
registration_start_date: Date.today,
registration_end_date: Date.tomorrow,
description: 'Lorem Ipsum')
@conference.venue = create(:venue)
@conference.venue.lodgings << create(:lodging, venue: @conference.venue)
@conference.call_for_papers = create(:call_for_papers, conference: @conference)
assign :conference, @conference
render
end
it 'renders program partial' do
expect(render).to include("#{@conference.description}")
expect(rendered).to include("#{@conference.description}")
expect(view).to render_template(partial: 'conference/_program')
end
@ -21,6 +23,22 @@ describe 'conference/show.html.haml' do
end
it 'renders call_for_papers partial' do
expect(render).to include("#{@conference.call_for_papers.description}")
expect(view).to render_template(partial: 'conference/_call_for_papers')
expect(rendered).to include("#{@conference.call_for_papers.description}")
end
it 'renders location partial' do
expect(view).to render_template(partial: 'conference/_location')
expect(rendered).to include('Suse Office')
expect(rendered).to include('Maxfeldstrasse 5 \n90409 Nuremberg')
expect(rendered).to include('www.opensuse.org')
expect(rendered).to include('Lorem Ipsum Dolor')
end
it 'renders lodging partial' do
expect(view).to render_template(partial: 'conference/_lodging')
expect(rendered).to include('Example Hotel')
expect(rendered).to include('Lorem Ipsum Dolor')
expect(rendered).to include('http://www.example.com')
end
end