Use dynamic fake data in the spec
This commit is contained in:
parent
4d38305110
commit
73ce49de25
14 changed files with 36 additions and 36 deletions
|
|
@ -58,7 +58,7 @@ describe Admin::ConferenceController do
|
||||||
conference.reload
|
conference.reload
|
||||||
expect(flash[:error]).
|
expect(flash[:error]).
|
||||||
to eq("Updating conference failed. Short title can't be blank.")
|
to eq("Updating conference failed. Short title can't be blank.")
|
||||||
expect(conference.title).to eq('The dog and pony show')
|
expect(conference.title).to eq("#{conference.title}")
|
||||||
expect(conference.short_title).to eq("#{conference.short_title}")
|
expect(conference.short_title).to eq("#{conference.short_title}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ describe ConferenceRegistrationsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows error in flash message' do
|
it 'shows error in flash message' do
|
||||||
expect(flash[:error]).to match "Could not update your registration for The dog and pony show: #{@registration.errors.full_messages.join('. ')}."
|
expect(flash[:error]).to match "Could not update your registration for #{conference.title}: #{@registration.errors.full_messages.join('. ')}."
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not update the registration' do
|
it 'does not update the registration' do
|
||||||
|
|
@ -139,7 +139,7 @@ describe ConferenceRegistrationsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows success message in flash notice', run: true do
|
it 'shows success message in flash notice', run: true do
|
||||||
expect(flash[:notice]).to match('You are not registered for The dog and pony show anymore!')
|
expect(flash[:notice]).to match("You are not registered for #{conference.title} anymore!")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deletes the registration' do
|
it 'deletes the registration' do
|
||||||
|
|
@ -160,7 +160,7 @@ describe ConferenceRegistrationsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows error in flash message' do
|
it 'shows error in flash message' do
|
||||||
expect(flash[:error]).to match "Could not delete your registration for The dog and pony show: #{@registration.errors.full_messages.join('. ')}."
|
expect(flash[:error]).to match "Could not delete your registration for #{conference.title}: #{@registration.errors.full_messages.join('. ')}."
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not delete the registration' do
|
it 'does not delete the registration' do
|
||||||
|
|
|
||||||
|
|
@ -35,13 +35,13 @@ feature Lodging do
|
||||||
visit admin_conference_lodgings_path(
|
visit admin_conference_lodgings_path(
|
||||||
conference_id: conference.short_title)
|
conference_id: conference.short_title)
|
||||||
|
|
||||||
expect(page.has_content?('Example Hotel')).to be true
|
expect(page.has_content?(lodging.name)).to be true
|
||||||
|
|
||||||
# Add lodging
|
# Add lodging
|
||||||
click_link 'Edit'
|
click_link 'Edit'
|
||||||
|
|
||||||
fill_in 'lodging_name', with: 'New lodging'
|
fill_in 'lodging_name', with: 'New lodging'
|
||||||
fill_in 'lodging_website_link', with: 'http:\\www.google.com'
|
fill_in 'lodging_website_link', with: 'http://www.google.com'
|
||||||
attach_file 'Picture', path
|
attach_file 'Picture', path
|
||||||
|
|
||||||
click_button 'Update Lodging'
|
click_button 'Update Lodging'
|
||||||
|
|
@ -51,26 +51,26 @@ feature Lodging do
|
||||||
expect(page.has_content?('New lodging')).to be true
|
expect(page.has_content?('New lodging')).to be true
|
||||||
lodging.reload
|
lodging.reload
|
||||||
expect(lodging.name).to eq('New lodging')
|
expect(lodging.name).to eq('New lodging')
|
||||||
expect(lodging.description).to eq('Lorem Ipsum Dolor')
|
expect(lodging.description).to eq(lodging.description)
|
||||||
expect(lodging.website_link).to eq('http:\\www.google.com')
|
expect(lodging.website_link).to eq('http://www.google.com')
|
||||||
expect(Lodging.count).to eq(1)
|
expect(Lodging.count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Delete a lodging', feature: true, js: true do
|
scenario 'Delete a lodging', feature: true, js: true do
|
||||||
conference.lodgings << create(:lodging)
|
lodging = create(:lodging, conference: conference)
|
||||||
|
|
||||||
sign_in organizer
|
sign_in organizer
|
||||||
visit admin_conference_lodgings_path(
|
visit admin_conference_lodgings_path(
|
||||||
conference_id: conference.short_title)
|
conference_id: conference.short_title)
|
||||||
|
|
||||||
expect(page.has_content?('Example Hotel')).to be true
|
expect(page.has_content?(lodging.name)).to be true
|
||||||
|
|
||||||
# Add lodging
|
# Add lodging
|
||||||
click_link 'Delete'
|
click_link 'Delete'
|
||||||
|
|
||||||
# Validations
|
# Validations
|
||||||
expect(flash).to eq('Lodging successfully deleted.')
|
expect(flash).to eq('Lodging successfully deleted.')
|
||||||
expect(page.has_content?('Example Hotel')).to be false
|
expect(page.has_content?(lodging.name)).to be false
|
||||||
expect(Lodging.count).to eq(0)
|
expect(Lodging.count).to eq(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ feature Sponsor do
|
||||||
fill_in 'sponsor_description', with: 'The original provider of the enterprise Linux distribution'
|
fill_in 'sponsor_description', with: 'The original provider of the enterprise Linux distribution'
|
||||||
attach_file 'Picture', path
|
attach_file 'Picture', path
|
||||||
fill_in 'sponsor_website_url', with: 'http://www.suse.com'
|
fill_in 'sponsor_website_url', with: 'http://www.suse.com'
|
||||||
select('Platin', from: 'sponsor_sponsorship_level_id')
|
select(conference.sponsorship_levels.first.title, from: 'sponsor_sponsorship_level_id')
|
||||||
|
|
||||||
click_button 'Create Sponsor'
|
click_button 'Create Sponsor'
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ feature Sponsor do
|
||||||
expect(page.has_content?('SUSE')).to be true
|
expect(page.has_content?('SUSE')).to be true
|
||||||
expect(page.has_content?('The original provider')).to be true
|
expect(page.has_content?('The original provider')).to be true
|
||||||
expect(page.has_content?('http://www.suse.com')).to be true
|
expect(page.has_content?('http://www.suse.com')).to be true
|
||||||
expect(page.has_content?('Platin')).to be true
|
expect(page.has_content?(conference.sponsorship_levels.first.title)).to be true
|
||||||
expect(page).to have_selector("img[src*='rails.png']")
|
expect(page).to have_selector("img[src*='rails.png']")
|
||||||
expect(page.assert_selector('tr', count: 2)).to be true
|
expect(page.assert_selector('tr', count: 2)).to be true
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ feature Registration do
|
||||||
expect(current_path).to eq(conference_conference_registrations_path(conference.short_title))
|
expect(current_path).to eq(conference_conference_registrations_path(conference.short_title))
|
||||||
expect(flash).
|
expect(flash).
|
||||||
to eq("Thank you for supporting #{conference.title} by purchasing a ticket.")
|
to eq("Thank you for supporting #{conference.title} by purchasing a ticket.")
|
||||||
expect(page.has_content?('2 Business Ticket Tickets for 10')).to be true
|
expect(page.has_content?("2 #{ticket.title} Tickets for 10")).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'deletes a purchased ticket', feature: true, js: true do
|
scenario 'deletes a purchased ticket', feature: true, js: true do
|
||||||
|
|
@ -41,7 +41,7 @@ feature Registration do
|
||||||
create(:ticket_purchase, conference: conference, user: participant, ticket: ticket, quantity: 4)
|
create(:ticket_purchase, conference: conference, user: participant, ticket: ticket, quantity: 4)
|
||||||
|
|
||||||
visit conference_conference_registrations_path(conference.short_title)
|
visit conference_conference_registrations_path(conference.short_title)
|
||||||
expect(page.has_content?('4 Business Ticket Tickets for 10')).to be true
|
expect(page.has_content?("4 #{ticket.title} Tickets for 10")).to be true
|
||||||
|
|
||||||
click_link "ticket-#{ticket.id}-delete"
|
click_link "ticket-#{ticket.id}-delete"
|
||||||
expect(flash).to eq('Ticket successfully deleted.')
|
expect(flash).to eq('Ticket successfully deleted.')
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ describe SponsorsHelper, type: :helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns correct url' do
|
it 'returns correct url' do
|
||||||
expect(get_logo(sponsor)).to match %r{.*(\bfirst/rails.png\b)}
|
expect(get_logo(sponsor)).to match %r{.*(\bfirst/#{sponsor.logo_file_name}\b)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@ describe SponsorsHelper, type: :helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns correct url' do
|
it 'returns correct url' do
|
||||||
expect(get_logo(sponsor)).to match %r{.*(\bsecond/rails.png\b)}
|
expect(get_logo(sponsor)).to match %r{.*(\bsecond/#{sponsor.logo_file_name}\b)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -33,7 +33,7 @@ describe SponsorsHelper, type: :helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns correct url' do
|
it 'returns correct url' do
|
||||||
expect(get_logo(sponsor)).to match %r{.*(\bothers/rails.png\b)}
|
expect(get_logo(sponsor)).to match %r{.*(\bothers/#{sponsor.logo_file_name}\b)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ describe EmailSettings do
|
||||||
{
|
{
|
||||||
'email' => 'john@doe.com',
|
'email' => 'john@doe.com',
|
||||||
'name' => 'John Doe',
|
'name' => 'John Doe',
|
||||||
'conference' => 'The dog and pony show',
|
'conference' => conference.title,
|
||||||
'conference_start_date' => Date.new(2014, 05, 01),
|
'conference_start_date' => Date.new(2014, 05, 01),
|
||||||
'conference_end_date' => Date.new(2014, 05, 06),
|
'conference_end_date' => Date.new(2014, 05, 06),
|
||||||
'registrationlink' => 'http://localhost:3000/conference/goto/register',
|
'registrationlink' => 'http://localhost:3000/conference/goto/register',
|
||||||
|
|
@ -62,7 +62,7 @@ describe EmailSettings do
|
||||||
context 'conference has venue' do
|
context 'conference has venue' do
|
||||||
before do
|
before do
|
||||||
conference.update_attributes(venue: create(:venue))
|
conference.update_attributes(venue: create(:venue))
|
||||||
venue_hash = { 'venue' => 'Suse Office', 'venue_address' => 'Maxfeldstrasse 5, Nuremberg, Germany' }
|
venue_hash = { 'venue' => conference.venue.name, 'venue_address' => conference.venue.address }
|
||||||
expected_hash.merge!(venue_hash)
|
expected_hash.merge!(venue_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -105,7 +105,7 @@ describe EmailSettings do
|
||||||
|
|
||||||
it 'replaces fillers in template' do
|
it 'replaces fillers in template' do
|
||||||
expected_text = "Dear John Doe\n\nWe are very pleased" \
|
expected_text = "Dear John Doe\n\nWe are very pleased" \
|
||||||
'to inform you that your submission Talk about talks has been accepted for the conference The dog and pony show.'
|
"to inform you that your submission Talk about talks has been accepted for the conference #{conference.title}."
|
||||||
expect(conference.email_settings.generate_event_mail(event, event_template)).to eq expected_text
|
expect(conference.email_settings.generate_event_mail(event, event_template)).to eq expected_text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -114,7 +114,7 @@ describe EmailSettings do
|
||||||
let(:conf_update_template) { "Dear {name},\n\nThank you for Registering for the conference {conference}." }
|
let(:conf_update_template) { "Dear {name},\n\nThank you for Registering for the conference {conference}." }
|
||||||
|
|
||||||
it 'replaces fillers in template' do
|
it 'replaces fillers in template' do
|
||||||
expected_text = "Dear John Doe,\n\nThank you for Registering for the conference The dog and pony show."
|
expected_text = "Dear John Doe,\n\nThank you for Registering for the conference #{conference.title}."
|
||||||
expect(conference.email_settings.generate_email_on_conf_updates(conference, user, conf_update_template)).to eq expected_text
|
expect(conference.email_settings.generate_email_on_conf_updates(conference, user, conf_update_template)).to eq expected_text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,7 @@ describe Event do
|
||||||
describe '#abstract_word_count' do
|
describe '#abstract_word_count' do
|
||||||
it 'counts words in abstract' do
|
it 'counts words in abstract' do
|
||||||
event = build(:event)
|
event = build(:event)
|
||||||
expect(event.abstract_word_count).to eq(233)
|
expect(event.abstract_word_count).to eq(event.abstract.to_s.split.size)
|
||||||
event.update_attributes!(abstract: 'abstract.')
|
event.update_attributes!(abstract: 'abstract.')
|
||||||
expect(event.abstract_word_count).to eq(1)
|
expect(event.abstract_word_count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ describe ConferenceSerializer, type: :serializer do
|
||||||
{
|
{
|
||||||
conference: {
|
conference: {
|
||||||
short_title: 'goto',
|
short_title: 'goto',
|
||||||
title: 'The dog and pony show',
|
title: conference.title,
|
||||||
description: 'Lorem ipsum dolor sit',
|
description: 'Lorem ipsum dolor sit',
|
||||||
start_date: '2014-03-04',
|
start_date: '2014-03-04',
|
||||||
end_date: '2014-03-10',
|
end_date: '2014-03-10',
|
||||||
|
|
@ -61,7 +61,7 @@ describe ConferenceSerializer, type: :serializer do
|
||||||
before do
|
before do
|
||||||
venue = create(:venue, conference: conference)
|
venue = create(:venue, conference: conference)
|
||||||
_room = create(:room, venue: venue)
|
_room = create(:room, venue: venue)
|
||||||
_track = create(:track, program: conference.program)
|
track = create(:track, program: conference.program)
|
||||||
|
|
||||||
room_hash = {
|
room_hash = {
|
||||||
rooms: [{
|
rooms: [{
|
||||||
|
|
@ -74,8 +74,8 @@ describe ConferenceSerializer, type: :serializer do
|
||||||
track_hash = {
|
track_hash = {
|
||||||
tracks: [{
|
tracks: [{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Example Track',
|
name: track.name,
|
||||||
description: 'Lorem Ipsum dolsum'
|
description: track.description
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ describe RoomSerializer, type: :serializer do
|
||||||
expected_json = {
|
expected_json = {
|
||||||
room: {
|
room: {
|
||||||
guid: room.guid,
|
guid: room.guid,
|
||||||
name: 'Example Room',
|
name: room.name,
|
||||||
description: ''
|
description: ''
|
||||||
}
|
}
|
||||||
}.to_json
|
}.to_json
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ describe TrackSerializer, type: :serializer do
|
||||||
expected_json = {
|
expected_json = {
|
||||||
track: {
|
track: {
|
||||||
guid: track.guid,
|
guid: track.guid,
|
||||||
name: 'Example Track',
|
name: track.name,
|
||||||
color: '#ffffff'
|
color: track.color
|
||||||
}
|
}
|
||||||
}.to_json
|
}.to_json
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@ describe 'admin/lodgings/index' do
|
||||||
@conference.lodgings << create(:lodging)
|
@conference.lodgings << create(:lodging)
|
||||||
assign :venue, @conference.venue
|
assign :venue, @conference.venue
|
||||||
render
|
render
|
||||||
expect(rendered).to include('Example Hotel')
|
expect(rendered).to include(@conference.lodgings.first.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ describe 'admin/sponsors/index' do
|
||||||
)
|
)
|
||||||
assign :conference, @conference
|
assign :conference, @conference
|
||||||
render
|
render
|
||||||
expect(rendered).to include('Example sponsor')
|
expect(rendered).to include(@conference.sponsors.first.name)
|
||||||
expect(rendered).to include('http://www.example.com')
|
expect(rendered).to include(@conference.sponsors.first.website_url)
|
||||||
expect(rendered).to include('Lorem Ipsum Dolor')
|
expect(rendered).to include(truncate(@conference.sponsors.first.description))
|
||||||
expect(rendered).to include('Platin')
|
expect(rendered).to include(@conference.sponsorship_levels.first.title)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,6 @@ describe 'admin/sponsorship_levels/index' do
|
||||||
@sponsorship_level = create(:sponsorship_level)
|
@sponsorship_level = create(:sponsorship_level)
|
||||||
assign :conference, @sponsorship_level.conference
|
assign :conference, @sponsorship_level.conference
|
||||||
render
|
render
|
||||||
expect(rendered).to include('Platin')
|
expect(rendered).to include(@sponsorship_level.title)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue