osem-fcy/spec/features/user_spec.rb

57 lines
2.7 KiB
Ruby
Raw Normal View History

2014-05-15 17:28:08 +05:30
require 'spec_helper'
2014-08-12 11:51:59 +03:00
2014-05-15 17:28:08 +05:30
feature User do
2016-03-03 14:28:14 +02:00
let(:user) { create(:user, name: 'My Name', biography: 'This is my biography!') }
2014-07-21 14:37:26 +02:00
2016-03-03 14:28:14 +02:00
describe 'users#show' do
let!(:conference) { create(:conference, title: 'My conference') }
let!(:unconfirmed_event) { create(:event, state: 'unconfirmed', title: 'This is my test event title!', program: conference.program) }
2016-03-03 14:28:14 +02:00
before :each do
unconfirmed_event.event_users = [create(:event_user, user: user, event_role: 'submitter')]
end
it 'shows user information' do
visit user_path(user)
expect(page).to have_content 'My Name'
expect(page).to have_content 'This is my biography!'
expect(page).to have_selector('img')
expect(page).to_not have_content 'My Name presents'
end
it 'does not show event information for unconfirmed events' do
expect(page).to_not have_selector('h3', text: 'My Name presents 1 Event:')
expect(page).to_not have_selector('ul li h4', text: 'This is my test event title!')
expect(page).to_not have_selector('ul li h4 strong', text: 'at')
expect(page).to_not have_selector('ul li h4', text: 'at My conference')
end
it 'shows user event information, when user has confirmed events' do
# User has 3 confirmed events, and 1 unconfirmed
# 2 confirmed events in one conference, 1 confirmed event in another conference
event1 = create(:event, state: 'confirmed', title: 'This is my test event title!', program: conference.program)
event2 = create(:event, state: 'confirmed', title: 'This is my second test event title!', program: conference.program)
event1.event_users = [create(:event_user, user: user, event_role: 'submitter')]
event2.event_users = [create(:event_user, user: user, event_role: 'submitter')]
another_conference = create(:conference, title: 'My another conference')
another_event = create(:event, state: 'confirmed', title: 'This is my another test event title!', program: another_conference.program)
another_event.event_users = [create(:event_user, user: user, event_role: 'submitter')]
2014-07-21 14:37:26 +02:00
2016-03-03 14:28:14 +02:00
visit user_path(user)
expect(page).to have_selector('h3', text: 'My Name presents 3 Events:', count: 1)
expect(page).to have_selector('ul li h4', text: 'This is my test event title!', count: 1)
expect(page).to have_selector('ul li h4 strong', text: 'at', count: 3)
expect(page).to have_selector('ul li h4', text: 'at My conference', count: 2)
expect(page).to have_selector('ul li h4', text: 'This is my second test event title!', count: 1)
expect(page).to have_selector('ul li h4', text: 'This is my another test event title!', count: 1)
expect(page).to have_selector('ul li h4', text: 'at My another conference', count: 1)
end
2014-05-15 17:28:08 +05:30
end
end