Redirect to root path if splash is not public

This commit is contained in:
Gopesh Tulsyan 2014-08-03 11:27:54 +05:30
parent 4955b2b7b8
commit 23c68211f0
2 changed files with 22 additions and 6 deletions

View file

@ -1,7 +1,7 @@
class ConferenceController < ApplicationController
def show
@conference = Conference.find_by_short_title(params[:id])
not_found unless @conference.make_conference_public?
redirect_to root_path, notice: "Conference not ready yet!!" unless @conference.make_conference_public?
end
def gallery_photos

View file

@ -15,11 +15,27 @@ describe ConferenceController do
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)
before(:each) { conference.update_attribute(:make_conference_public, false) }
it 'redirects to root path' do
get :show, id: conference.short_title
expect(response).to redirect_to root_path
end
it 'renders flash saying conference not ready' do
get :show, id: conference.short_title
expect(flash[:notice]).to eq("Conference not ready yet!!")
end
end
context 'gallery photos for splash' do
it 'return conference photos' do
xhr :get, :gallery_photos, id: conference.short_title
expect(assigns(:photos)).to eq conference.photos
end
it 'renders photos template' do
xhr :get, :gallery_photos, id: conference.short_title
expect(response).to render_template :photos
end
end
end