Merge pull request #427 from gopesht/fix#309

Redirect to root path if splash is not public
This commit is contained in:
Artem Chernikov 2014-08-04 16:22:39 +02:00
commit 31f56ea4a9
2 changed files with 22 additions and 6 deletions

View file

@ -1,7 +1,7 @@
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? redirect_to root_path, notice: "Conference not ready yet!!" unless @conference.make_conference_public?
end end
def gallery_photos def gallery_photos

View file

@ -15,11 +15,27 @@ describe ConferenceController do
end end
end end
context 'conference is not public' do context 'conference is not public' do
it 'raises routing error' do before(:each) { conference.update_attribute(:make_conference_public, false) }
# rendered as 404 NOT FOUND in production environment
conference.update_attribute(:make_conference_public, false) it 'redirects to root path' do
expect { get :show, id: conference.short_title }. get :show, id: conference.short_title
to raise_error(ActionController::RoutingError) 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 end
end end