From 8c1c546bdfd8e3b6bd9a21c9b2a42f84660ac42c Mon Sep 17 00:00:00 2001 From: MrZYX <pr0fkill@gmail.com> Date: Wed, 6 Jul 2011 15:38:54 +0200 Subject: [PATCH] fixed #884 --- app/controllers/aspects_controller.rb | 13 +++++++++++-- spec/controllers/aspects_controller_spec.rb | 12 ++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 690acb0102..8c94858d3f 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -24,10 +24,16 @@ class AspectsController < ApplicationController aspect_ids = @aspects.map{|a| a.id} # redirect to signup - if (current_user.getting_started == true || @aspects.blank?) && !request.format.mobile? && !request.format.js? + if current_user.getting_started == true && !request.format.mobile? && !request.format.js? redirect_to getting_started_path return end + + # redirect to aspects creation + if @aspects.blank? + redirect_to new_aspect_path + return + end unless params[:only_posts] all_selected_people = Person.joins(:contacts => :aspect_memberships). @@ -88,7 +94,10 @@ class AspectsController < ApplicationController def new @aspect = Aspect.new @person_id = params[:person_id] - render :layout => false + respond_to do |format| + format.js { render :layout => false } + format.html { render '_new' } + end end def destroy diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 8308737383..f74b8f18b2 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -90,6 +90,18 @@ describe AspectsController do response.should_not be_redirect end end + + context 'with no aspects' do + before do + alice.aspects.each { |aspect| aspect.destroy } + alice.reload + end + + it 'redirects to the new aspect page' do + get :index + response.should redirect_to new_aspect_path + end + end context 'with posts in multiple aspects' do before do -- GitLab