Fix the test failures

This commit is contained in:
Sasi Olin
2022-03-30 12:39:01 +02:00
parent 50e876dd6f
commit e85ecede4c
29 changed files with 232 additions and 232 deletions

View File

@@ -563,7 +563,7 @@ GEM
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sixarm_ruby_unaccent (1.2.0)
skylight (5.1.0)
skylight (5.1.1)
activesupport (>= 5.2.0)
sort_alphabetical (1.1.0)
unicode_utils (>= 1.2.2)

View File

@@ -22,8 +22,8 @@ describe Admin::TracksController do
it 'assigns @tracks with the correct values' do
expect(assigns(:tracks).length).to eq 2
expect(assigns(:tracks).include?(track)).to eq true
expect(assigns(:tracks).include?(self_organized_track)).to eq true
expect(assigns(:tracks).include?(track)).to be true
expect(assigns(:tracks).include?(self_organized_track)).to be true
end
it 'renders the index template' do
@@ -52,7 +52,7 @@ describe Admin::TracksController do
it 'assigns a new track with the correct conference' do
expect(assigns(:track)).to be_a Track
expect(assigns(:track).new_record?).to eq true
expect(assigns(:track).new_record?).to be true
expect(assigns(:track).program_id).to eq conference.program.id
end
@@ -69,7 +69,7 @@ describe Admin::TracksController do
it 'assigns a new track with the correct conference' do
expect(assigns(:track)).to be_a Track
expect(assigns(:track).new_record?).to eq false
expect(assigns(:track).new_record?).to be false
expect(assigns(:track).program_id).to eq conference.program.id
end
@@ -87,7 +87,7 @@ describe Admin::TracksController do
it 'the new track has the correct attributes' do
expect(assigns(:track).state).to eq 'confirmed'
expect(assigns(:track).cfp_active).to eq true
expect(assigns(:track).cfp_active).to be true
end
end
@@ -99,7 +99,7 @@ describe Admin::TracksController do
it 'assigns a new track with the correct conference' do
expect(assigns(:track)).to be_a Track
expect(assigns(:track).new_record?).to eq true
expect(assigns(:track).new_record?).to be true
expect(assigns(:track).program_id).to eq conference.program.id
end
@@ -112,7 +112,7 @@ describe Admin::TracksController do
end
it 'does not create a new track' do
expect(conference.program.tracks.find_by(short_name: 'my_track')).to eq nil
expect(conference.program.tracks.find_by(short_name: 'my_track')).to be_nil
end
end
end
@@ -199,7 +199,7 @@ describe Admin::TracksController do
end
it 'deletes the track' do
expect(Track.find_by(id: track)).to eq nil
expect(Track.find_by(id: track)).to be_nil
end
end
@@ -249,7 +249,7 @@ describe Admin::TracksController do
end
it 'becomes true' do
expect(self_organized_track.cfp_active).to eq true
expect(self_organized_track.cfp_active).to be true
end
end
@@ -269,7 +269,7 @@ describe Admin::TracksController do
end
it 'stays false' do
expect(self_organized_track.cfp_active).to eq false
expect(self_organized_track.cfp_active).to be false
end
end
end
@@ -295,7 +295,7 @@ describe Admin::TracksController do
end
it 'becomes false' do
expect(self_organized_track.cfp_active).to eq false
expect(self_organized_track.cfp_active).to be false
end
end
@@ -315,7 +315,7 @@ describe Admin::TracksController do
end
it 'stays true' do
expect(self_organized_track.cfp_active).to eq true
expect(self_organized_track.cfp_active).to be true
end
end
end

View File

@@ -25,12 +25,12 @@ describe Admin::UsersController do
user_to_confirm = create(:user, email: 'unconfirmed_user@osem.io', confirmed_at: nil)
patch :toggle_confirmation, params: { id: user_to_confirm.id, user: { to_confirm: 'true' } }
user_to_confirm.reload
expect(user_to_confirm.confirmed?).to eq true
expect(user_to_confirm.confirmed?).to be true
end
it 'undo confirmation of user' do
patch :toggle_confirmation, params: { id: user.id, user: { to_confirm: 'false' } }
user.reload
expect(user.confirmed?).to eq false
expect(user.confirmed?).to be false
end
end
describe 'PATCH #update' do

View File

@@ -31,7 +31,7 @@ describe Admin::VersionsController do
expect(flash[:error]).to match('The item is already in the state that you are trying to revert it back to')
end
it 'reverting deletion of object creates it again' do
it 'reverting deletion of object creates it again' do
event_type = conference.program.event_types.first
event_type.destroy
event_types_count = conference.program.event_types.count
@@ -41,7 +41,7 @@ describe Admin::VersionsController do
expect(conference.program.event_types.count).to eq(event_types_count + 1)
end
it 'reverting creation of object deletes it ' do
it 'reverting creation of object deletes it' do
lodging = create(:lodging, conference: conference)
get :revert_object, params: { id: lodging.versions.last.id }
expect(lodging.versions.last.event).to eq 'destroy'
@@ -131,8 +131,8 @@ describe Admin::VersionsController do
sign_in @user
get :index, params: { conference_id: conference.short_title }
expect(assigns(:versions).include?(@version_cfp)).to eq true
expect(assigns(:versions).include?(@version_organizer)).to eq false
expect(assigns(:versions).include?(@version_cfp)).to be true
expect(assigns(:versions).include?(@version_organizer)).to be false
end
it 'when user has role info_desk' do
@@ -140,9 +140,9 @@ describe Admin::VersionsController do
sign_in @user
get :index, params: { conference_id: conference.short_title }
expect(assigns(:versions).include?(@version_info_desk)).to eq true
expect(assigns(:versions).include?(@version_organizer)).to eq false
expect(assigns(:versions).include?(@version_cfp)).to eq false
expect(assigns(:versions).include?(@version_info_desk)).to be true
expect(assigns(:versions).include?(@version_organizer)).to be false
expect(assigns(:versions).include?(@version_cfp)).to be false
end
it 'when user has role organizer' do
@@ -150,9 +150,9 @@ describe Admin::VersionsController do
sign_in @user
get :index, params: { conference_id: conference.short_title }
expect(assigns(:versions).include?(@version_organizer)).to eq true
expect(assigns(:versions).include?(@version_cfp)).to eq true
expect(assigns(:versions).include?(@version_info_desk)).to eq true
expect(assigns(:versions).include?(@version_organizer)).to be true
expect(assigns(:versions).include?(@version_cfp)).to be true
expect(assigns(:versions).include?(@version_info_desk)).to be true
end
end
end

View File

@@ -13,7 +13,7 @@ describe ConfirmationsController do
it 'confirms and signs in user' do
get :show, params: { confirmation_token: user.confirmation_token }
user.reload
expect(user.confirmed?).to eq true
expect(user.confirmed?).to be true
expect(controller.current_user).to eq user
end
end
@@ -24,7 +24,7 @@ describe ConfirmationsController do
it 'confirms user' do
get :show, params: { confirmation_token: user.confirmation_token }
user.reload
expect(user.confirmed?).to eq true
expect(user.confirmed?).to be true
end
end
end

View File

@@ -20,8 +20,8 @@ describe TracksController do
it 'assigns @tracks with the correct values' do
expect(assigns(:tracks).length).to eq 1
expect(assigns(:tracks).include?(regular_track)).to eq false
expect(assigns(:tracks).include?(self_organized_track)).to eq true
expect(assigns(:tracks).include?(regular_track)).to be false
expect(assigns(:tracks).include?(self_organized_track)).to be true
end
it 'renders the index template' do
@@ -50,7 +50,7 @@ describe TracksController do
it 'assigns a new track with the correct conference' do
expect(assigns(:track)).to be_a Track
expect(assigns(:track).new_record?).to eq true
expect(assigns(:track).new_record?).to be true
expect(assigns(:track).program_id).to eq conference.program.id
end
@@ -74,14 +74,14 @@ describe TracksController do
end
it 'creates new track' do
expect(assigns(:track).new_record?).to eq false
expect(assigns(:track).new_record?).to be false
end
it 'the new tracks has the correct attributes' do
expect(assigns(:track).program_id).to eq conference.program.id
expect(assigns(:track).submitter).to eq user
expect(assigns(:track).state).to eq 'new'
expect(assigns(:track).cfp_active).to eq false
expect(assigns(:track).cfp_active).to be false
end
end
@@ -93,7 +93,7 @@ describe TracksController do
it 'assigns a new track with the correct conference' do
expect(assigns(:track)).to be_a Track
expect(assigns(:track).new_record?).to eq true
expect(assigns(:track).new_record?).to be true
expect(assigns(:track).program_id).to eq conference.program.id
end
@@ -106,7 +106,7 @@ describe TracksController do
end
it 'does not create a new track' do
expect(conference.program.tracks.find_by(short_name: 'my_track')).to eq nil
expect(conference.program.tracks.find_by(short_name: 'my_track')).to be_nil
end
end
end

View File

@@ -19,7 +19,7 @@ feature 'BaseController' do
end
end
context 'when user is ' do
context 'when user is' do
before(:each) do
sign_in(user)
end

View File

@@ -34,7 +34,7 @@ feature Conference do
expect(Conference.count).to eq(expected_count)
expect(Conference.last.organization).to eq(organization)
user.reload
expect(user.has_cached_role? :organizer, Conference.last).to eq(true)
expect(user.has_cached_role? :organizer, Conference.last).to be(true)
end
scenario 'update conference', feature: true, js: true do

View File

@@ -71,7 +71,7 @@ feature Openid do
expect(flash).to eq('test-participant-1@example.com signed in successfully with google')
expect(Openid.count).to eq(expected_count_openid)
expect(User.count).to eq(expected_count_user)
expect(Openid.where(email: 'test-1@example.com').first.nil?).to eq(false)
expect(Openid.where(email: 'test-1@example.com').first.nil?).to be(false)
end
scenario 'signs in with openID using the same email as another associated openid' do
@@ -105,8 +105,8 @@ feature Openid do
page.find('#flash .close').click
expect(Openid.count).to eq(expected_count_openid)
expect(User.count).to eq(expected_count_user)
expect(Openid.where(email: 'test-participant-1@example.com').first.nil?).to eq(false)
expect(Openid.where(email: 'test-1@example.com').first.nil?).to eq(false)
expect(Openid.where(email: 'test-participant-1@example.com').first.nil?).to be(false)
expect(Openid.where(email: 'test-1@example.com').first.nil?).to be(false)
# Sign in with different openID using same email (test-1@gmail.com)
sign_out
@@ -131,8 +131,8 @@ feature Openid do
shared_examples 'sign up with openid' do |provider|
scenario "has option to sign in with #{provider}" do
visit '/accounts/sign_up'
expect(page.has_content?('or sign in using')).to eq true
expect(page.has_link?("omniauth-#{provider}")).to eq true
expect(page.has_content?('or sign in using')).to be true
expect(page.has_link?("omniauth-#{provider}")).to be true
end
scenario "sign up with #{provider}" do

View File

@@ -37,7 +37,7 @@ feature Role do
visit admin_conference_roles_path(conference.short_title)
end
scenario "role #{role_name}" do
expect(page.has_link?('Edit', href: edit_admin_conference_role_path(conference.short_title, role_name))).to eq false
expect(page.has_link?('Edit', href: edit_admin_conference_role_path(conference.short_title, role_name))).to be false
end
end
@@ -60,7 +60,7 @@ feature Role do
click_button 'Add'
user_with_no_role.reload
expect(user_with_no_role.has_cached_role?(role.name, conference)).to eq true
expect(user_with_no_role.has_cached_role?(role.name, conference)).to be true
end
scenario "removes role #{role_name}", feature: true, js: true do
@@ -72,7 +72,7 @@ feature Role do
expect(page).to have_css('.alert', text: "Successfully removed role #{role_name} from user #{user_with_role.email}")
expect(by_role_name).to eq(role_name) | eq('organizer')
user_with_role.reload
expect(user_with_role.has_cached_role?(role_name, conference)).to eq false
expect(user_with_role.has_cached_role?(role_name, conference)).to be false
end
end
@@ -91,13 +91,13 @@ feature Role do
scenario "add role #{role_name}", feature: true, js: true do
click_link('Users', href: admin_conference_role_path(conference.short_title, role_name))
expect(page.has_field?('user_email')).to eq false
expect(page.has_field?('user_email')).to be false
end
scenario "remove role #{role_name}", feature: true, js: true do
click_link('Users', href: admin_conference_role_path(conference.short_title, role_name))
expect(first('td').has_css?('.bootstrap-switch-container')).to eq false
expect(first('td').has_css?('.bootstrap-switch-container')).to be false
end
end
@@ -121,7 +121,7 @@ feature Role do
click_button 'Add'
user_with_no_role.reload
expect(user_with_no_role.has_cached_role?('organization_admin', organization)).to eq true
expect(user_with_no_role.has_cached_role?('organization_admin', organization)).to be true
end
scenario 'successfully removes role organization_admin' do
@@ -129,7 +129,7 @@ feature Role do
first('tr').find('.btn-danger').click
organization_admin.reload
expect(organization_admin.has_cached_role?('organization_admin', organization)).to eq false
expect(organization_admin.has_cached_role?('organization_admin', organization)).to be false
end
end
@@ -137,12 +137,12 @@ feature Role do
scenario 'does not successfully add role organization_admin' do
click_link('Admins', href: admins_admin_organization_path(other_organization.id))
expect(page.has_field?('user_email')).to eq false
expect(page.has_field?('user_email')).to be false
end
scenario 'does not successfully removes role organization_admin' do
click_link('Admins', href: admins_admin_organization_path(other_organization.id))
expect(page.has_css?('.btn-danger')).to eq false
expect(page.has_css?('.btn-danger')).to be false
end
end
end

View File

@@ -90,8 +90,8 @@ feature Track do
expected.to change { Track.count }.by 1
expect(flash).to eq('Track request successfully created.')
within('table#tracks') do
expect(page.has_content?('Distribution')).to eq true
expect(page.has_content?('Events about our Linux dist...')).to eq true
expect(page.has_content?('Distribution')).to be true
expect(page.has_content?('Events about our Linux dist...')).to be true
end
end
@@ -111,8 +111,8 @@ feature Track do
expected.to_not(change { Track.count })
expect(flash).to eq("Track #{track.name} withdrawn.")
within('table#tracks') do
expect(page.has_content?(track.name)).to eq true
expect(page.has_link?('Re-Submit')).to eq true
expect(page.has_content?(track.name)).to be true
expect(page.has_link?('Re-Submit')).to be true
end
end
@@ -134,8 +134,8 @@ feature Track do
expected.to_not(change { Track.count })
expect(flash).to eq('Track request successfully updated.')
within('table#tracks') do
expect(page.has_content?('Distribution')).to eq true
expect(page.has_content?('Events about our Linux dist...')).to eq true
expect(page.has_content?('Distribution')).to be true
expect(page.has_content?('Events about our Linux dist...')).to be true
end
end
end

View File

@@ -36,29 +36,29 @@ describe ApplicationHelper, type: :helper do
describe 'does return correct concurrent events' do
it 'when events starts at the same time' do
expect(concurrent_events(event).include?(@other_event)).to eq true
expect(concurrent_events(event).include?(@other_event)).to be true
end
it 'when event is in between the other event' do
@event_schedule.update_attribute(:start_time, @other_event_schedule.start_time + 10.minutes)
expect(concurrent_events(event).include?(@other_event)).to eq true
expect(concurrent_events(event).include?(@other_event)).to be true
end
end
describe 'does not return as concurrent event ' do
describe 'does not return as concurrent event' do
it 'when event is not scheduled' do
@event_schedule.destroy
expect(concurrent_events(event).present?).to eq false
expect(concurrent_events(event).present?).to be false
end
it 'when one event starts and other ends at the same time' do
@event_schedule.update_attribute(:start_time, @other_event_schedule.end_time)
expect(concurrent_events(event).present?).to eq false
expect(concurrent_events(event).present?).to be false
end
it 'when conference program does not have a selected schedule' do
conference.program.update_attribute(:selected_schedule_id, nil)
expect(concurrent_events(event).present?).to eq false
expect(concurrent_events(event).present?).to be false
end
end

View File

@@ -6,7 +6,7 @@ describe DateTimeHelper, type: :helper do
describe 'format_datetime' do
it 'returns nothing if there is no parameter' do
expect(format_datetime(nil)).to eq nil
expect(format_datetime(nil)).to be_nil
end
it 'returns formatted string' do

View File

@@ -21,7 +21,7 @@ describe Cfp do
it 'returns nil when the cfp for events doesn\'t exist' do
cfp.destroy!
expect(conference.program.cfps.for_events).to eq nil
expect(conference.program.cfps.for_events).to be_nil
end
end
@@ -32,7 +32,7 @@ describe Cfp do
end
it 'returns nil when the cfp for tracks doesn\'t exist' do
expect(conference.program.cfps.for_tracks).to eq nil
expect(conference.program.cfps.for_tracks).to be_nil
end
end
@@ -81,24 +81,24 @@ describe Cfp do
describe 'returns true' do
it 'when end_date changed' do
cfp.end_date = Date.today
expect(cfp.start_date_changed?).to eq false
expect(cfp.end_date_changed?).to eq true
expect(cfp.notify_on_cfp_date_update?).to eq true
expect(cfp.start_date_changed?).to be false
expect(cfp.end_date_changed?).to be true
expect(cfp.notify_on_cfp_date_update?).to be true
end
it 'when start_date changed' do
cfp.start_date = Date.today
expect(cfp.end_date_changed?).to eq false
expect(cfp.start_date_changed?).to eq true
expect(cfp.notify_on_cfp_date_update?).to eq true
expect(cfp.end_date_changed?).to be false
expect(cfp.start_date_changed?).to be true
expect(cfp.notify_on_cfp_date_update?).to be true
end
end
describe 'returns false' do
it 'when there is no change in cfp dates' do
expect(cfp.start_date_changed?).to eq false
expect(cfp.end_date_changed?).to eq false
expect(cfp.notify_on_cfp_date_update?).to eq false
expect(cfp.start_date_changed?).to be false
expect(cfp.end_date_changed?).to be false
expect(cfp.notify_on_cfp_date_update?).to be false
end
it 'when send_on_cfp_dates_updates is not set' do
@@ -106,8 +106,8 @@ describe Cfp do
conference.email_settings.save!
cfp.end_date = Date.today
expect(cfp.end_date_changed?).to eq true
expect(cfp.notify_on_cfp_date_update?).to eq false
expect(cfp.end_date_changed?).to be true
expect(cfp.notify_on_cfp_date_update?).to be false
end
it 'when cfp_dates_updates_subject is not set' do
@@ -115,8 +115,8 @@ describe Cfp do
conference.email_settings.save!
cfp.end_date = Date.today
expect(cfp.end_date_changed?).to eq true
expect(cfp.notify_on_cfp_date_update?).to eq false
expect(cfp.end_date_changed?).to be true
expect(cfp.notify_on_cfp_date_update?).to be false
end
it 'when cfp_dates_updates_template is not set' do
@@ -124,8 +124,8 @@ describe Cfp do
conference.email_settings.save!
cfp.end_date = Date.today
expect(cfp.end_date_changed?).to eq true
expect(cfp.notify_on_cfp_date_update?).to eq false
expect(cfp.end_date_changed?).to be true
expect(cfp.notify_on_cfp_date_update?).to be false
end
end
end
@@ -135,13 +135,13 @@ describe Cfp do
it 'when start and end dates are in the past' do
cfp.start_date = Date.current - 3
cfp.end_date = Date.current - 1
expect(cfp.open?).to eq(false)
expect(cfp.open?).to be(false)
end
it 'when start and end dates are in the future' do
cfp.start_date = Date.current + 1
cfp.end_date = Date.current + 3
expect(cfp.open?).to eq(false)
expect(cfp.open?).to be(false)
end
end
@@ -149,7 +149,7 @@ describe Cfp do
it 'when start date is in the past and end date is in the future' do
cfp.start_date = Date.current - 1
cfp.end_date = Date.current + 1
expect(cfp.open?).to eq(true)
expect(cfp.open?).to be(true)
end
end
end

View File

@@ -8,12 +8,12 @@ describe Commercial do
it 'validates url format' do
commercial = build(:conference_commercial, url: 'ftp://example.com')
expect(commercial.valid?).to eq false
expect(commercial.valid?).to be false
expect(commercial.errors['url']).to eq ['is invalid']
end
it 'validates url rendering' do
commercial = build(:conference_commercial)
expect(commercial.valid?).to eq true
expect(commercial.valid?).to be true
end
end

View File

@@ -5,22 +5,22 @@ require 'spec_helper'
context 'Delegation' do
subject do
FactoryBot.create(:conference, start_date: 1.month.from_now, end_date: 2.month.from_now)
create(:conference, start_date: 1.month.from_now, end_date: 2.month.from_now)
end
context 'Venue' do
context 'when venue has not been set' do
it 'the accessors should be nil' do
expect(subject.city).to eq(nil)
expect(subject.country_name).to eq(nil)
expect(subject.venue_name).to eq(nil)
expect(subject.venue_street).to eq(nil)
expect(subject.city).to be_nil
expect(subject.country_name).to be_nil
expect(subject.venue_name).to be_nil
expect(subject.venue_street).to be_nil
end
end
context 'when venue has been set' do
it 'should delegate to venue' do
venue = FactoryBot.create(:venue)
venue = create(:venue)
subject.update(venue: venue)
expect(subject.city).to eq(venue.city)
expect(subject.country_name).to eq(venue.country_name)
@@ -33,7 +33,7 @@ end
describe Conference do
let(:subject) { create(:conference, start_date: Date.new(2014, 06, 30), end_date: Date.new(2014, 06, 30)) }
subject(:test_subject) { create(:conference, start_date: Date.new(2014, 06, 30), end_date: Date.new(2014, 06, 30)) }
describe '#write_event_distribution_to_db' do
@@ -744,7 +744,7 @@ describe Conference do
end
describe '#get_submission_line_colors' do
it ' returns correct values' do
it 'returns correct values' do
result = []
result.push(short_title: 'Submitted', color: 'blue')
result.push(short_title: 'Confirmed', color: 'green')

View File

@@ -21,7 +21,7 @@ describe EventSchedule do
context 'is invalid' do
it 'when event schedule start_time is after the conference end_hour, and returns an error message' do
new_scheduled_event = build(:event_scheduled, program: conference.program, hour: conference.start_date + conference.end_hour.hours + 1.hour)
expect(new_scheduled_event.valid?).to eq false
expect(new_scheduled_event.valid?).to be false
expect(new_scheduled_event.event_schedules.first.errors[:start_time]).to eq ["can't be after the conference end hour (#{conference.end_hour})"]
end
end
@@ -29,7 +29,7 @@ describe EventSchedule do
context 'is valid' do
it 'when event schedule start_time is between the conference end_hour and start_hour' do
new_scheduled_event = build(:event_scheduled, program: conference.program, hour: conference.start_date + conference.end_hour.hours - 1.hour)
expect(new_scheduled_event.valid?).to eq true
expect(new_scheduled_event.valid?).to be true
end
end
end
@@ -38,7 +38,7 @@ describe EventSchedule do
context 'is invalid' do
it 'when event schedule start_time is before the conference start_hour, and returns an error message' do
new_scheduled_event = build(:event_scheduled, program: conference.program, hour: conference.start_date)
expect(new_scheduled_event.valid?).to eq false
expect(new_scheduled_event.valid?).to be false
expect(new_scheduled_event.event_schedules.first.errors[:start_time]).to eq ["can't be before the conference start hour (#{conference.start_hour})"]
end
end
@@ -56,21 +56,21 @@ describe EventSchedule do
context 'is valid' do
it 'when scheduled in the track\'s room' do
event_schedule = build(:event_schedule, event: @event, room: @room)
expect(event_schedule.valid?).to eq true
expect(event_schedule.valid?).to be true
end
it 'when the track doesn\'t have a room' do
@track.room = nil
@track.save!
event_schedule = build(:event_schedule, event: @event)
expect(event_schedule.valid?).to eq true
expect(event_schedule.valid?).to be true
end
end
context 'is invalid' do
it 'when scheduled in different room than the track\'s' do
event_schedule = build(:event_schedule, event: @event)
expect(event_schedule.valid?).to eq false
expect(event_schedule.valid?).to be false
expect(event_schedule.errors[:room]).to eq ["must be the same as the track's room (#{@room.name})"]
end
end
@@ -88,20 +88,20 @@ describe EventSchedule do
context 'is valid' do
it 'when scheduled during the track\'s time slot' do
event_schedule = build(:event_schedule, event: @event, room: @room, start_time: Date.current + 3.hours)
expect(event_schedule.valid?).to eq true
expect(event_schedule.valid?).to be true
end
end
context 'is invalid' do
it 'when scheduled before the track\'s start date' do
event_schedule = build(:event_schedule, event: @event, room: @room, start_time: Date.current - 1.hour)
expect(event_schedule.valid?).to eq false
expect(event_schedule.valid?).to be false
expect(event_schedule.errors[:start_time]).to eq ["can't be before the track's start date (#{@track.start_date})"]
end
it 'when event ends after the track\'s end date' do
event_schedule = build(:event_schedule, event: @event, room: @room, start_time: Date.current + 1.day - 10.minutes)
expect(event_schedule.valid?).to eq false
expect(event_schedule.valid?).to be false
expect(event_schedule.errors[:end_time]).to eq ["can't be after the track's end date (#{@track.end_date})"]
end
end
@@ -119,7 +119,7 @@ describe EventSchedule do
it 'when the event belongs to a self-organized track and is scheduled in one of its track\'s schedules' do
schedule = create(:schedule, program: conference.program, track: @event.track)
event_schedule = build(:event_schedule, event: @event, room: @room, schedule: schedule)
expect(event_schedule.valid?).to eq true
expect(event_schedule.valid?).to be true
expect(event_schedule.errors[:schedule]).to eq []
end
@@ -127,7 +127,7 @@ describe EventSchedule do
@event.track = nil
@event.save!
event_schedule = build(:event_schedule, event: @event, room: @room)
expect(event_schedule.valid?).to eq true
expect(event_schedule.valid?).to be true
expect(event_schedule.errors[:schedule]).to eq []
end
end
@@ -135,7 +135,7 @@ describe EventSchedule do
context 'is invalid' do
it 'when the event belongs to a self_organized track but isn\'t scheduled in one of its schedules' do
event_schedule = build(:event_schedule, event: @event, room: @room)
expect(event_schedule.valid?).to eq false
expect(event_schedule.valid?).to be false
expect(event_schedule.errors[:schedule]).to eq ['must be one of My awesome track track\'s schedules']
end
end

View File

@@ -35,14 +35,14 @@ describe Event do
it 'it is valid, if max_attendees is less than room size' do
event.max_attendees = 2
expect(event.valid?).to eq true
expect(event.valid?).to be true
expect(event.errors.full_messages).to eq []
end
it 'it is not valid, if max_attendees attribute is bigger than size of room' do
event.max_attendees = 4
expect(event.valid?).to eq false
expect(event.valid?).to be false
expect(event.errors[:max_attendees]).to eq ['cannot be more than the room\'s capacity (3)']
end
end
@@ -56,13 +56,13 @@ describe Event do
context 'is invalid' do
it 'when abstract is too long' do
event.abstract = 'Test abstract here'
expect(event.valid?).to eq false
expect(event.valid?).to be false
expect(event.errors[:abstract]).to eq ['cannot have more than 2 words']
end
it 'when abstract is too short' do
event.abstract = 'Test'
expect(event.valid?).to eq false
expect(event.valid?).to be false
expect(event.errors[:abstract]).to eq ['cannot have less than 2 words']
end
end
@@ -70,7 +70,7 @@ describe Event do
context 'is valid' do
it 'when abstract length is within limits' do
event.abstract = 'Test abstract'
expect(event.valid?).to eq true
expect(event.valid?).to be true
expect(event.errors.size).to eq 0
end
end
@@ -81,7 +81,7 @@ describe Event do
it 'when event is created after the conference end_date, and returns an error message' do
conference = create(:conference, start_date: Date.today - 1, end_date: Date.today - 1)
new_event = build(:event, program: conference.program)
expect(new_event.valid?).to eq false
expect(new_event.valid?).to be false
expect(new_event.errors[:created_at]).to eq ["can't be after the conference end date!"]
end
end
@@ -90,7 +90,7 @@ describe Event do
it 'when event is created before the conference end_date' do
conference = create(:conference, start_date: Date.today - 1, end_date: Date.today + 1)
new_event = build(:event, program: conference.program)
expect(new_event.valid?).to eq true
expect(new_event.valid?).to be true
end
end
end
@@ -100,7 +100,7 @@ describe Event do
it 'when the track belongs to the same program and is confirmed' do
track = create(:track, state: 'confirmed', program: conference.program)
event = build(:event, program: conference.program, track: track)
expect(event.valid?).to eq true
expect(event.valid?).to be true
end
end
@@ -108,7 +108,7 @@ describe Event do
it 'when the track doesn\'t have the same program' do
track = create(:track, state: 'confirmed')
event = build(:event, program: conference.program, track: track)
expect(event.valid?).to eq false
expect(event.valid?).to be false
expect(event.errors[:track]).to eq ['is invalid']
end
@@ -116,7 +116,7 @@ describe Event do
track = create(:track, program: conference.program)
allow(track).to receive(:confirmed?).and_return(false)
event = build(:event, program: conference.program, track: track)
expect(event.valid?).to eq false
expect(event.valid?).to be false
expect(event.errors[:track]).to eq ['is invalid']
end
end
@@ -146,7 +146,7 @@ describe Event do
end
end
describe 'scope ' do
describe 'scope' do
context 'confirmed' do
it 'returns only confirmed events' do
my_event = create(:event, state: 'confirmed', program: conference.program)
@@ -165,10 +165,10 @@ describe Event do
end
describe '#scheduled?' do
it { expect(event.scheduled?).to eq false }
it { expect(event.scheduled?).to be false }
it 'returns true if the event is scheduled' do
create(:event_schedule, event: event)
expect(event.scheduled?).to eq true
expect(event.scheduled?).to be true
end
end
@@ -185,34 +185,34 @@ describe Event do
it 'returns true, if the event has no max_attendees' do
event.max_attendees = nil
event.save!
expect(event.registration_possible?).to eq true
expect(event.registration_possible?).to be true
end
it 'returns true, if the limit has not been reached' do
expect(event.registration_possible?).to eq true
expect(event.registration_possible?).to be true
end
it 'returns true, if the event is confirmed' do
event.save!
expect(event.registration_possible?).to eq true
expect(event.registration_possible?).to be true
end
it 'returns false, if the limit has been reached' do
event.registrations << create(:registration)
event.registrations << create(:registration)
expect(event.registration_possible?).to eq false
expect(event.registration_possible?).to be false
end
it 'returns false, if the event is not confirmed' do
event.state = 'new'
event.save!
expect(event.registration_possible?).to eq false
expect(event.registration_possible?).to be false
end
end
describe 'when the event does not require registration' do
it 'returns false' do
expect(event.registration_possible?).to eq false
expect(event.registration_possible?).to be false
end
end
end
@@ -236,22 +236,22 @@ describe Event do
describe '#voted?' do
it 'returns false if the event has no votes' do
expect(event.voted?).to eq false
expect(event.voted?).to be false
end
it 'returns false if the event has no votes by that user' do
create(:vote, user: another_user, event: event)
expect(event.voted?(user)).to eq false
expect(event.voted?(user)).to be false
end
it 'returns true when the event has votes' do
create(:vote, user: another_user, event: event)
expect(event.voted?).to eq true
expect(event.voted?).to be true
end
it 'returns true when the event has votes by that user' do
create(:vote, user: user, event: event)
expect(event.voted?(user)).to eq true
expect(event.voted?(user)).to be true
end
end

View File

@@ -24,7 +24,7 @@ describe Payment do
let(:ticket_1) { create(:ticket, price: 10, price_currency: 'USD', conference: conference) }
let(:payment) { create(:payment, user: user, conference: conference) }
it ' returns correct unpaid amount' do
it 'returns correct unpaid amount' do
create(:ticket_purchase, ticket: ticket_1, user: user, quantity: 8)
expect(payment.amount_to_pay).to eq(8000)
end
@@ -71,7 +71,7 @@ describe Payment do
context 'when the card is invalid' do
it 'returns false' do
payment_result = payment.purchase
expect(payment_result).to eq false
expect(payment_result).to be false
end
it 'assigns "failure" to payment.status' do

View File

@@ -75,7 +75,7 @@ describe Program do
end
it 'returns true if blind_voting is disabled' do
program.blind_voting = false
expect(program.show_voting?).to eq true
expect(program.show_voting?).to be true
end
end
@@ -86,19 +86,19 @@ describe Program do
it 'returns true if voting period is over' do
program.voting_end_date = Date.today - 1
expect(program.show_voting?).to eq true
expect(program.show_voting?).to be true
end
it 'returns false if we are still in votig period' do
program.voting_end_date = Date.today + 1
expect(program.show_voting?).to eq false
expect(program.show_voting?).to be false
end
end
end
describe 'voting_period?' do
it 'retuns true when voting dates are not set' do
expect(program.voting_period?).to eq true
expect(program.voting_period?).to be true
end
shared_examples 'voting period' do |voting_start_date, voting_end_date, returns|
@@ -125,7 +125,7 @@ describe Program do
expect(program.rating_enabled?).to be true
end
it 'returns false if proposals cannot be rated (program.rating == 0) ' do
it 'returns false if proposals cannot be rated (program.rating == 0)' do
program = conference.program
program.rating = 0
expect(program.rating_enabled?).to be false
@@ -156,7 +156,7 @@ describe Program do
it 'and creates events_types' do
program.destroy!
conference.reload
expect(conference.program).to eq nil
expect(conference.program).to be_nil
create(:program, conference_id: conference.id)
conference.reload
@@ -166,7 +166,7 @@ describe Program do
it 'and creates difficulty_levels' do
program.destroy!
conference.reload
expect(conference.program).to eq nil
expect(conference.program).to be_nil
create(:program, conference_id: conference.id)
conference.reload
@@ -206,25 +206,25 @@ describe Program do
describe 'languages' do
it "is not valid if languages aren't two letters separated by commas" do
program.languages = 'eng, De es'
expect(program.valid?).to eq false
expect(program.valid?).to be false
expect(program.errors[:languages]).to eq ['must be two letters separated by commas']
end
it 'is not valid if languages are repeated' do
program.languages = 'en,de,es,en'
expect(program.valid?).to eq false
expect(program.valid?).to be false
expect(program.errors[:languages]).to eq ["can't be repeated"]
end
it "is not valid if languages aren't ISO 639-1 valid codes" do
program.languages = 'en,hh,yu,zi,oo'
expect(program.valid?).to eq false
expect(program.valid?).to be false
expect(program.errors[:languages]).to eq ['must be ISO 639-1 valid codes']
end
it 'is valid otherwise' do
program.languages = 'en,De, ES, ru,el'
expect(program.valid?).to eq true
expect(program.valid?).to be true
end
end
@@ -244,15 +244,15 @@ describe Program do
let!(:event_schedule) { create(:event_schedule, event: event, schedule: schedule, start_time: DateTime.parse("#{Date.current + 1} 10:00").utc) }
it 'returns false irrespective of any date' do
expect(program.any_event_for_this_date?(Date.current + 1)).to eq false
expect(program.any_event_for_this_date?(Date.current + 1)).to be false
end
it 'returns false if date passed is empty' do
expect(program.any_event_for_this_date?('')).to eq false
expect(program.any_event_for_this_date?('')).to be false
end
it 'returns false if date passed is nil' do
expect(program.any_event_for_this_date?(nil)).to eq false
expect(program.any_event_for_this_date?(nil)).to be false
end
end
@@ -266,19 +266,19 @@ describe Program do
end
it 'returns true if there is any event for this date' do
expect(program.any_event_for_this_date?(Date.current + 1)).to eq true
expect(program.any_event_for_this_date?(Date.current + 1)).to be true
end
it 'returns false if there is no event for this date' do
expect(program.any_event_for_this_date?(Date.current + 2)).to eq false
expect(program.any_event_for_this_date?(Date.current + 2)).to be false
end
it 'returns false if date passed is empty' do
expect(program.any_event_for_this_date?('')).to eq false
expect(program.any_event_for_this_date?('')).to be false
end
it 'returns false if date passed is nil' do
expect(program.any_event_for_this_date?(nil)).to eq false
expect(program.any_event_for_this_date?(nil)).to be false
end
end
end
@@ -291,7 +291,7 @@ describe Program do
end
it 'returns nil if the program doesn\'t have a cfp' do
expect(program.cfp).to eq(nil)
expect(program.cfp).to be_nil
end
end
@@ -299,19 +299,19 @@ describe Program do
it 'returns an array without the \'events\' type, when the cfp for events exists' do
create(:cfp, cfp_type: 'events', program: program)
expect(program.remaining_cfp_types).to be_a Array
expect(program.remaining_cfp_types.include?('events')).to eq false
expect(program.remaining_cfp_types.include?('events')).to be false
end
it 'returns an array without the \'booths\' type, when the cfp for booths exists' do
create(:cfp, cfp_type: 'booths', program: program)
expect(program.remaining_cfp_types).to be_a Array
expect(program.remaining_cfp_types.include?('booths')).to eq false
expect(program.remaining_cfp_types.include?('booths')).to be false
end
it 'returns an array without the \'tracks\' type, when the cfp for tracks exists' do
create(:cfp, cfp_type: 'tracks', program: program)
expect(program.remaining_cfp_types).to be_a Array
expect(program.remaining_cfp_types.include?('tracks')).to eq false
expect(program.remaining_cfp_types.include?('tracks')).to be false
end
it 'returns an empty array when cfps for all the types exist' do

View File

@@ -22,13 +22,13 @@ describe RegistrationPeriod do
it 'when start_date and end_date are before conference end_date' do
registration_period.start_date = conference.end_date - 2
registration_period.end_date = conference.end_date - 1
expect(registration_period.valid?).to eq true
expect(registration_period.valid?).to be true
end
it 'when start_date and end_date are the same day as conference end_date' do
registration_period.start_date = conference.end_date
registration_period.end_date = conference.end_date
expect(registration_period.valid?).to eq true
expect(registration_period.valid?).to be true
end
end
@@ -36,13 +36,13 @@ describe RegistrationPeriod do
it 'when start_date and end_date are after conference end_date' do
registration_period.start_date = conference.end_date + 1
registration_period.end_date = conference.end_date + 2
expect(registration_period.valid?).to eq false
expect(registration_period.valid?).to be false
end
it 'when end_date is after conference end_date' do
registration_period.start_date = conference.end_date - 1
registration_period.end_date = conference.end_date + 1
expect(registration_period.valid?).to eq false
expect(registration_period.valid?).to be false
end
end
end
@@ -52,13 +52,13 @@ describe RegistrationPeriod do
it 'when start_date is before end_date' do
registration_period.start_date = conference.end_date - 2
registration_period.end_date = conference.end_date - 1
expect(registration_period.valid?).to eq true
expect(registration_period.valid?).to be true
end
it 'when start_date and end_date are on the same day' do
registration_period.start_date = conference.end_date - 2
registration_period.end_date = conference.end_date - 2
expect(registration_period.valid?).to eq true
expect(registration_period.valid?).to be true
end
end
@@ -66,7 +66,7 @@ describe RegistrationPeriod do
it 'when start_date is after end_date' do
registration_period.start_date = conference.start_date + 2
registration_period.end_date = conference.start_date + 1
expect(registration_period.valid?).to eq false
expect(registration_period.valid?).to be false
end
end
end

View File

@@ -26,6 +26,6 @@ describe Resource do
it 'is not valid with used greater than quantity' do
resource.used = resource.quantity + 1
expect(resource.valid?).to eq false
expect(resource.valid?).to be false
end
end

View File

@@ -30,35 +30,35 @@ describe SurveyQuestion do
it 'max_choices > min_choices' do
survey_question = build(:survey_question, kind: :choice, min_choices: 3, max_choices: 2)
expect(survey_question.valid?).to eq false
expect(survey_question.valid?).to be false
expect(survey_question.errors[:max_choices]).to eq ['Max choices should not be less than min choices']
end
end
describe '#multiple_choice?' do
it 'returns false, when choice with 1 max_choice' do
expect(single_choice_question.multiple_choice?).to eq false
expect(single_choice_question.multiple_choice?).to be false
end
it 'returns true, when choice with 2 max_choices' do
expect(multiple_choice_question.multiple_choice?).to eq true
expect(multiple_choice_question.multiple_choice?).to be true
end
end
describe '#single_choice?' do
it 'returns true, when choice with 1 max_choice' do
expect(single_choice_question.single_choice?).to eq true
expect(single_choice_question.single_choice?).to be true
end
it 'returns false, when choice with 2 max_choices' do
expect(multiple_choice_question.single_choice?).to eq false
expect(multiple_choice_question.single_choice?).to be false
end
end
describe 'min_choices value' do
it 'nil, when boolean question' do
boolean_question = create(:boolean_mandatory, min_choices: 3)
expect(boolean_question.min_choices).to eq nil
expect(boolean_question.min_choices).to be_nil
end
it 'not nil, when choice question' do
@@ -86,7 +86,7 @@ describe SurveyQuestion do
shared_examples 'is nil' do |question_kind, field|
scenario "when question is #{question_kind} and field is #{field}" do
question = create(:survey_question, kind: question_kind.to_sym, field => 3)
expect(question.send(field)).to eq nil
expect(question.send(field)).to be_nil
end
end

View File

@@ -17,10 +17,10 @@ describe Survey do
end
describe '#active?' do
it { expect(survey_active.active?).to eq true }
it { expect(survey_inactive.active?).to eq false }
it { expect(survey_active.active?).to be true }
it { expect(survey_inactive.active?).to be false }
it 'returns true, if both start_date and end_date are not set' do
expect(create(:survey, start_date: nil, end_date: nil, surveyable: create(:conference)).active?).to eq true
expect(create(:survey, start_date: nil, end_date: nil, surveyable: create(:conference)).active?).to be true
end
end
end

View File

@@ -42,7 +42,7 @@ describe TicketPurchase do
it 'it is not valid, if quantity for registration tickets is greater than to one' do
ticket_purchase.quantity = 4
expect(ticket_purchase.valid?).to eq false
expect(ticket_purchase.valid?).to be false
expect(ticket_purchase.errors[:quantity]).to eq ['cannot be greater than one for registration tickets.']
end
end

View File

@@ -13,10 +13,10 @@ describe TicketScanning do
describe 'before_create' do
it 'marks user as present' do
expect(registration.attended).to eq(false)
expect(registration.attended).to be(false)
ticket_scanning
registration.reload
expect(registration.attended).to eq(true)
expect(registration.attended).to be(true)
end
end
end

View File

@@ -54,11 +54,11 @@ describe Ticket do
create(:ticket_purchase,
user: user,
ticket: ticket)
expect(ticket.bought?(user)).to eq(true)
expect(ticket.bought?(user)).to be(true)
end
it 'returns false if the user has not bought this ticket' do
expect(ticket.bought?(user)).to eq(false)
expect(ticket.bought?(user)).to be(false)
end
end
@@ -79,7 +79,7 @@ describe Ticket do
context 'user has not paid' do
it 'returns true' do
expect(ticket.unpaid?(user)).to eq(true)
expect(ticket.unpaid?(user)).to be(true)
end
end
@@ -87,7 +87,7 @@ describe Ticket do
before { ticket_purchase.update_attribute(:paid, true) }
it 'returns false' do
expect(ticket.unpaid?(user)).to eq(false)
expect(ticket.unpaid?(user)).to be(false)
end
end
end

View File

@@ -75,32 +75,32 @@ describe Track do
context 'is valid' do
it 'when the track\'s dates are between the conference\'s dates' do
track = build(:track, start_date: @conference.start_date, end_date: @conference.end_date, program: @conference.program)
expect(track.valid?).to eq true
expect(track.valid?).to be true
end
end
context 'is invalid' do
it 'when the track\'s start date is before the conference\'s start date' do
track = build(:track, start_date: 2.days.ago, end_date: Date.tomorrow, program: @conference.program)
expect(track.valid?).to eq false
expect(track.valid?).to be false
expect(track.errors[:start_date]).to eq ["can't be outside of the conference's dates (#{1.day.ago.to_date}-#{2.days.from_now.to_date})"]
end
it 'when the track\'s start date is after the conference\'s end date' do
track = build(:track, start_date: 3.days.from_now, end_date: 4.days.from_now, program: @conference.program)
expect(track.valid?).to eq false
expect(track.valid?).to be false
expect(track.errors[:start_date]).to eq ["can't be outside of the conference's dates (#{1.day.ago.to_date}-#{2.days.from_now.to_date})"]
end
it 'when the track\'s end date is before the conference\'s start date' do
track = build(:track, start_date: 3.days.ago, end_date: 2.days.ago, program: @conference.program)
expect(track.valid?).to eq false
expect(track.valid?).to be false
expect(track.errors[:end_date]).to eq ["can't be outside of the conference's dates (#{1.day.ago.to_date}-#{2.days.from_now.to_date})"]
end
it 'when the track\'s end date is after the conference\'s end date' do
track = build(:track, start_date: Date.today, end_date: 3.days.from_now, program: @conference.program)
expect(track.valid?).to eq false
expect(track.valid?).to be false
expect(track.errors[:end_date]).to eq ["can't be outside of the conference's dates (#{1.day.ago.to_date}-#{2.days.from_now.to_date})"]
end
end
@@ -114,14 +114,14 @@ describe Track do
context 'is valid' do
it 'when the track\'s start date is before its end date' do
track = build(:track, start_date: Date.today, end_date: Date.tomorrow, program: @conference.program)
expect(track.valid?).to eq true
expect(track.valid?).to be true
end
end
context 'is invalid' do
it 'when the track\'s start date is after it\'s end date' do
track = build(:track, start_date: 1.day.from_now, end_date: 1.day.ago)
expect(track.valid?).to eq false
expect(track.valid?).to be false
expect(track.errors[:start_date]).to eq ['can\'t be after the end date']
end
end
@@ -137,7 +137,7 @@ describe Track do
it 'when the track\'s room belongs to the venue of the conference' do
room = create(:room, venue: @conference.venue)
track = build(:track, :self_organized, state: 'accepted', program: @conference.program, room: room)
expect(track.valid?).to eq true
expect(track.valid?).to be true
end
end
@@ -147,7 +147,7 @@ describe Track do
other_conference.venue = create(:venue)
room = create(:room, venue: other_conference.venue)
track = build(:track, :self_organized, state: 'accepted', program: @conference.program, room: room)
expect(track.valid?).to eq false
expect(track.valid?).to be false
expect(track.errors[:room]).to eq ['must be a room of The venue']
end
end
@@ -165,19 +165,19 @@ describe Track do
other_room = create(:room, venue: @conference.venue)
create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: other_room, start_date: Date.current, end_date: Date.current)
track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current)
expect(track.valid?).to eq true
expect(track.valid?).to be true
end
it 'when it ends before the other tracks in the same room' do
create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current)
track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current - 1.day, end_date: Date.current - 1.day)
expect(track.valid?).to eq true
expect(track.valid?).to be true
end
it 'when it starts after the other tracks in the same room' do
create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current)
track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current + 1.day, end_date: Date.current + 1.day)
expect(track.valid?).to eq true
expect(track.valid?).to be true
end
end
@@ -185,35 +185,35 @@ describe Track do
it 'when it starts and/or ends with another track in the same room' do
create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current)
track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current)
expect(track.valid?).to eq false
expect(track.valid?).to be false
expect(track.errors[:track]).to eq ['has overlapping dates with a confirmed or accepted track in the same room']
end
it 'when it starts before another track and ends after the other starts and before it ends' do
create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current + 2.days)
track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current - 1.day, end_date: Date.current + 1.day)
expect(track.valid?).to eq false
expect(track.valid?).to be false
expect(track.errors[:track]).to eq ['has overlapping dates with a confirmed or accepted track in the same room']
end
it 'when it starts after another track and before it ends and ends after the other' do
create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current + 2.days)
track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current + 1.day, end_date: Date.current + 3.days)
expect(track.valid?).to eq false
expect(track.valid?).to be false
expect(track.errors[:track]).to eq ['has overlapping dates with a confirmed or accepted track in the same room']
end
it 'when it starts after another track and ends before the other' do
create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current + 2.days)
track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current + 1.day, end_date: Date.current + 1.day)
expect(track.valid?).to eq false
expect(track.valid?).to be false
expect(track.errors[:track]).to eq ['has overlapping dates with a confirmed or accepted track in the same room']
end
it 'when it starts before another track and ends after the other' do
create(:track, :self_organized, state: 'confirmed', program: @conference.program, room: @room, start_date: Date.current, end_date: Date.current)
track = build(:track, :self_organized, program: @conference.program, room: @room, start_date: Date.current - 1.day, end_date: Date.current + 1.day)
expect(track.valid?).to eq false
expect(track.valid?).to be false
expect(track.errors[:track]).to eq ['has overlapping dates with a confirmed or accepted track in the same room']
end
end
@@ -229,7 +229,7 @@ describe Track do
context 'includes' do
it 'when track is accepted' do
accepted_track = create(:track, state: 'accepted', program: @program)
expect(@program.tracks.accepted.include?(accepted_track)).to eq true
expect(@program.tracks.accepted.include?(accepted_track)).to be true
end
end
@@ -237,7 +237,7 @@ describe Track do
%w[new to_accept confirmed to_reject rejected canceled withdrawn].each do |state|
it "when track is #{state.humanize}" do
not_accepted_track = create(:track, state: state, program: @program)
expect(@program.tracks.accepted.include?(not_accepted_track)).to eq false
expect(@program.tracks.accepted.include?(not_accepted_track)).to be false
end
end
end
@@ -251,7 +251,7 @@ describe Track do
context 'includes' do
it 'tracks with state \'confirmed\'' do
confirmed_track = create(:track, state: 'confirmed', program: @program)
expect(@program.tracks.confirmed.include?(confirmed_track)).to eq true
expect(@program.tracks.confirmed.include?(confirmed_track)).to be true
end
end
@@ -259,7 +259,7 @@ describe Track do
%w[new to_accept accepted to_reject rejected canceled withdrawn].each do |state|
it "tracks with state '#{state}'" do
unconfirmed_track = create(:track, state: state, program: @program)
expect(@program.tracks.confirmed.include?(unconfirmed_track)).to eq false
expect(@program.tracks.confirmed.include?(unconfirmed_track)).to be false
end
end
end
@@ -273,11 +273,11 @@ describe Track do
end
it 'include tracks with the cfp_active flag enabled' do
expect(@program.tracks.cfp_active.include?(@cfp_active_track)).to eq true
expect(@program.tracks.cfp_active.include?(@cfp_active_track)).to be true
end
it 'excludes tracks with the cfp_active flag disabled' do
expect(@program.tracks.cfp_active.include?(@non_cfp_active_track)).to eq false
expect(@program.tracks.cfp_active.include?(@non_cfp_active_track)).to be false
end
end
@@ -291,11 +291,11 @@ describe Track do
end
it 'includes self-organized tracks' do
expect(@program.tracks.self_organized.include?(self_organized_track)).to eq true
expect(@program.tracks.self_organized.include?(self_organized_track)).to be true
end
it 'excludes regular tracks' do
expect(@program.tracks.self_organized.include?(track)).to eq false
expect(@program.tracks.self_organized.include?(track)).to be false
end
end
end
@@ -303,12 +303,12 @@ describe Track do
describe '#self_organized?' do
it 'returns true when it has a submitter' do
expect(self_organized_track.submitter).to be_a User
expect(self_organized_track.self_organized?).to eq true
expect(self_organized_track.self_organized?).to be true
end
it 'returns false when it doesn\'t have a submitter' do
expect(track.submitter).to eq nil
expect(track.self_organized?).to eq false
expect(track.submitter).to be_nil
expect(track.self_organized?).to be false
end
end
@@ -346,17 +346,17 @@ describe Track do
end
it 'gives the role of the track organizer to the submitter of the track' do
expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to eq false
expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to be false
self_organized_track.assign_role_to_submitter
expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to eq true
expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to be true
end
it 'is executed when the track is confirmed' do
self_organized_track.state = 'accepted'
self_organized_track.save!
expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to eq false
expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to be false
self_organized_track.confirm
expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to eq true
expect(@submitter.has_cached_role?(:track_organizer, self_organized_track)).to be true
end
end
@@ -373,23 +373,23 @@ describe Track do
end
it 'revokes the role of the track organizer' do
expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to eq true
expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to be true
self_organized_track.revoke_role_and_cleanup
@a_track_organizer.reload
expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to eq false
expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to be false
end
it 'destroys the track\'s schedules' do
expect(Schedule.find(@schedule_of_self_organized_track.id)).to eq @schedule_of_self_organized_track
self_organized_track.revoke_role_and_cleanup
expect(Schedule.find_by(id: @schedule_of_self_organized_track.id)).to eq nil
expect(Schedule.find_by(id: @schedule_of_self_organized_track.id)).to be_nil
end
it 'removes the track from the events that have it set' do
expect(@event_of_self_organized_track.track).to eq self_organized_track
self_organized_track.revoke_role_and_cleanup
@event_of_self_organized_track.reload
expect(@event_of_self_organized_track.track).to eq nil
expect(@event_of_self_organized_track.track).to be_nil
end
it 'sets the state of the track\'s events to new' do
@@ -404,17 +404,17 @@ describe Track do
self_organized_track.save!
self_organized_track.cancel
@a_track_organizer.reload
expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to eq false
expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to be false
@event_of_self_organized_track.reload
expect(@event_of_self_organized_track.track).to eq nil
expect(@event_of_self_organized_track.track).to be_nil
end
it 'is executed when the track is withdrawn' do
self_organized_track.withdraw
@a_track_organizer.reload
expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to eq false
expect(@a_track_organizer.has_cached_role?(:track_organizer, self_organized_track)).to be false
@event_of_self_organized_track.reload
expect(@event_of_self_organized_track.track).to eq nil
expect(@event_of_self_organized_track.track).to be_nil
end
end
@@ -423,7 +423,7 @@ describe Track do
it 'when the state is "accepted"' do
self_organized_track.state = 'accepted'
self_organized_track.save!
expect(self_organized_track.accepted?).to eq true
expect(self_organized_track.accepted?).to be true
end
end
@@ -432,7 +432,7 @@ describe Track do
it "when the state is \"#{state}\"" do
self_organized_track.state = state
self_organized_track.save!
expect(self_organized_track.accepted?).to eq false
expect(self_organized_track.accepted?).to be false
end
end
end
@@ -443,7 +443,7 @@ describe Track do
it 'when the state is "confirmed"' do
self_organized_track.state = 'confirmed'
self_organized_track.save!
expect(self_organized_track.confirmed?).to eq true
expect(self_organized_track.confirmed?).to be true
end
end
@@ -452,7 +452,7 @@ describe Track do
it "when the state is \"#{state}\"" do
self_organized_track.state = state
self_organized_track.save!
expect(self_organized_track.confirmed?).to eq false
expect(self_organized_track.confirmed?).to be false
end
end
end
@@ -472,7 +472,7 @@ describe Track do
allow(track).to receive(:confirmed?).and_return(false)
end
it { expect(track.self_organized_and_accepted_or_confirmed?).to eq true }
it { expect(track.self_organized_and_accepted_or_confirmed?).to be true }
end
context 'accepted? returns false and confirmed? returns true' do
@@ -481,7 +481,7 @@ describe Track do
allow(track).to receive(:confirmed?).and_return(true)
end
it { expect(track.self_organized_and_accepted_or_confirmed?).to eq true }
it { expect(track.self_organized_and_accepted_or_confirmed?).to be true }
end
end
end
@@ -498,7 +498,7 @@ describe Track do
allow(track).to receive(:confirmed?).and_return(false)
end
it { expect(track.self_organized_and_accepted_or_confirmed?).to eq false }
it { expect(track.self_organized_and_accepted_or_confirmed?).to be false }
end
end
@@ -513,7 +513,7 @@ describe Track do
allow(track).to receive(:confirmed?).and_return(false)
end
it { expect(track.self_organized_and_accepted_or_confirmed?).to eq false }
it { expect(track.self_organized_and_accepted_or_confirmed?).to be false }
end
context 'accepted? returns true and confirmed? returns false' do
@@ -522,7 +522,7 @@ describe Track do
allow(track).to receive(:confirmed?).and_return(false)
end
it { expect(track.self_organized_and_accepted_or_confirmed?).to eq false }
it { expect(track.self_organized_and_accepted_or_confirmed?).to be false }
end
context 'accepted? returns false and confirmed? returns true' do
@@ -531,7 +531,7 @@ describe Track do
allow(track).to receive(:confirmed?).and_return(true)
end
it { expect(track.self_organized_and_accepted_or_confirmed?).to eq false }
it { expect(track.self_organized_and_accepted_or_confirmed?).to be false }
end
end
end
@@ -539,13 +539,13 @@ describe Track do
describe '#create_organizer_role' do
it 'creates the role of the track organizer' do
expect(Role.find_by(name: 'track_organizer', resource: self_organized_track)).to eq nil
expect(Role.find_by(name: 'track_organizer', resource: self_organized_track)).to be_nil
self_organized_track.send(:create_organizer_role)
expect(Role.find_by(name: 'track_organizer', resource: self_organized_track).description).to eq 'For the organizers of the Track'
end
it 'is executed when the track is accepted' do
expect(Role.find_by(name: 'track_organizer', resource: self_organized_track)).to eq nil
expect(Role.find_by(name: 'track_organizer', resource: self_organized_track)).to be_nil
self_organized_track.accept
expect(Role.find_by(name: 'track_organizer', resource: self_organized_track).description).to eq 'For the organizers of the Track'
end

View File

@@ -346,7 +346,7 @@ describe User do
describe '#confirmed?' do
context 'confirmed user' do
it 'returns true' do
expect(user.confirmed?).to eq true
expect(user.confirmed?).to be true
end
end
@@ -354,7 +354,7 @@ describe User do
before { user.update_attribute(:confirmed_at, nil) }
it 'returns false' do
expect(user.confirmed?).to eq false
expect(user.confirmed?).to be false
end
end
end
@@ -395,7 +395,7 @@ describe User do
describe 'rolify' do
it 'returns the correct role' do
expect(user_admin.is_admin).to eq(true)
expect(user_admin.is_admin).to be(true)
expect(organizer.roles.first).to eq(organizer_role)
end