Don't redirect ajax requests to getting_started. Fix a possible source of errors and backfill a couple tests

This commit is contained in:
Raphael Sofaer 2011-03-18 21:05:43 -07:00
parent 3db11cf38d
commit 42a361dcce
2 changed files with 19 additions and 2 deletions

View file

@ -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?

View file

@ -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'