Adds routing error check in conference#show
Adds make_conference_public to conference factory Added test
This commit is contained in:
parent
291a61bc8d
commit
2b94ba0281
4 changed files with 23 additions and 7 deletions
|
|
@ -72,4 +72,8 @@ class ApplicationController < ActionController::Base
|
||||||
redirect_to root_path, :alert => exception.message
|
redirect_to root_path, :alert => exception.message
|
||||||
end
|
end
|
||||||
helper_method :organizer_or_admin?
|
helper_method :organizer_or_admin?
|
||||||
|
|
||||||
|
def not_found
|
||||||
|
raise ActionController::RoutingError.new('Not Found')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
class ConferenceController < ApplicationController
|
class ConferenceController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@conference = Conference.find_by_short_title(params[:id])
|
@conference = Conference.find_by_short_title(params[:id])
|
||||||
|
not_found unless @conference.make_conference_public?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ require 'spec_helper'
|
||||||
describe ConferenceController do
|
describe ConferenceController do
|
||||||
let(:conference) { create(:conference) }
|
let(:conference) { create(:conference) }
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
|
context 'conference made public' do
|
||||||
it 'assigns the requested conference to conference' do
|
it 'assigns the requested conference to conference' do
|
||||||
get :show, id: conference.short_title
|
get :show, id: conference.short_title
|
||||||
expect(assigns(:conference)).to eq conference
|
expect(assigns(:conference)).to eq conference
|
||||||
|
|
@ -13,4 +14,13 @@ describe ConferenceController do
|
||||||
expect(response).to render_template :show
|
expect(response).to render_template :show
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
context 'conference is not public' do
|
||||||
|
it 'raises routing error' do
|
||||||
|
# rendered as 404 NOT FOUND in production environment
|
||||||
|
conference.update_attribute(:make_conference_public, false)
|
||||||
|
expect { get :show, id: conference.short_title }.
|
||||||
|
to raise_error(ActionController::RoutingError)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ FactoryGirl.define do
|
||||||
contact_email 'admin@example.com'
|
contact_email 'admin@example.com'
|
||||||
start_date Date.today
|
start_date Date.today
|
||||||
end_date Date.tomorrow
|
end_date Date.tomorrow
|
||||||
|
make_conference_public true
|
||||||
venue
|
venue
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue