From 42a361dcce2acb718a435d2cf563362c6b208d15 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Fri, 18 Mar 2011 21:05:43 -0700 Subject: [PATCH] Don't redirect ajax requests to getting_started. Fix a possible source of errors and backfill a couple tests --- app/controllers/aspects_controller.rb | 2 +- spec/controllers/aspects_controller_spec.rb | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index f58999e5b..d755a7268 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -19,7 +19,7 @@ class AspectsController < ApplicationController @selected_contacts.uniq! # redirect to signup - if (current_user.getting_started == true || @aspects.blank?) && !request.format.mobile? + if (current_user.getting_started == true || @aspects.blank?) && !request.format.mobile? && !request.format.js? redirect_to getting_started_path else if params[:sort_order].blank? and session[:sort_order].blank? diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index aa708001d..e1b421951 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -111,8 +111,25 @@ describe AspectsController do assigns(:posts).should == @posts.reverse end end + context 'with getting_started = true' do + before do + @alice.getting_started = true + @alice.save + end + it 'redirects to getting_started' do + get :index + response.should redirect_to getting_started_path + end + it 'does not redirect mobile users to getting_started' do + get :index, :format => :mobile + response.should_not be_redirect + end + it 'does not redirect ajax to getting_started' do + get :index, :format => :js + response.should_not be_redirect + end + end end - context 'performance', :performance => true do before do require 'benchmark'