Change Cfp scopes to class methods

When no record matches the requested criteria a scope will return all
the records
In this case, if no record can be found we want the result to be nil

Also, make some readability fixes in specs
This commit is contained in:
AEtherC0r3 2017-07-16 20:29:03 +03:00 committed by Stella Rouzi
parent d9faffc96a
commit f9903eba16
5 changed files with 59 additions and 30 deletions

View file

@ -115,7 +115,7 @@ feature 'Has correct abilities' do
expect(current_path).to eq(edit_admin_conference_program_cfp_path(conference.short_title, conference.program.cfp))
# Event, booth, track cfps exist
cft = create(:cfp, cfp_type: 'tracks', program: conference.program)
call_for_tracks = create(:cfp, cfp_type: 'tracks', program: conference.program)
visit new_admin_conference_program_cfp_path(conference.short_title)
expect(current_path).to eq root_path
@ -125,7 +125,7 @@ feature 'Has correct abilities' do
expect(current_path).to eq new_admin_conference_program_cfp_path(conference.short_title)
# Only booth exists
cft.destroy!
call_for_tracks.destroy!
visit new_admin_conference_program_cfp_path(conference.short_title)
expect(current_path).to eq(new_admin_conference_program_cfp_path(conference.short_title))
@ -138,19 +138,19 @@ feature 'Has correct abilities' do
expect(current_path).to eq(new_admin_conference_program_cfp_path(conference.short_title))
# Only Tracks cfp exists
cft = create(:cfp, cfp_type: 'tracks', program: conference.program)
call_for_tracks = create(:cfp, cfp_type: 'tracks', program: conference.program)
visit new_admin_conference_program_cfp_path(conference.short_title)
expect(current_path).to eq new_admin_conference_program_cfp_path(conference.short_title)
visit edit_admin_conference_program_cfp_path(conference.short_title, cft)
expect(current_path).to eq edit_admin_conference_program_cfp_path(conference.short_title, cft)
visit edit_admin_conference_program_cfp_path(conference.short_title, call_for_tracks)
expect(current_path).to eq edit_admin_conference_program_cfp_path(conference.short_title, call_for_tracks)
# Event and track cfps exist
create(:cfp, cfp_type: 'events', program: conference.program)
visit new_admin_conference_program_cfp_path(conference.short_title)
expect(current_path).to eq new_admin_conference_program_cfp_path(conference.short_title)
cft.destroy!
call_for_tracks.destroy!
visit admin_conference_program_events_path(conference.short_title)
expect(current_path).to eq(admin_conference_program_events_path(conference.short_title))