Skip to content

Commit

Permalink
Fixed #show @next_question tests, got them passing
Browse files Browse the repository at this point in the history
  • Loading branch information
nickh committed Nov 15, 2009
1 parent 0c4e21c commit 045670d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/controllers/responses_controller.rb
Expand Up @@ -30,7 +30,8 @@ def create
end

def show
redirect_to(new_response_path) if @response.nil? || params[:id].to_i != @response.id
return redirect_to(new_response_path) if @response.nil? || params[:id].to_i != @response.id
@next_question = @response.next_question
end

def update
Expand Down
3 changes: 3 additions & 0 deletions spec/controllers/responses_controller_spec.rb
Expand Up @@ -127,6 +127,7 @@
describe 'when there are unanswered questions' do
before do
@test_answers = (1..3).collect{|i| Answer.create(:question_id => i, :response => @test_response)}
session[:respondent] = @test_respondent
end

it 'should have a next question' do
Expand All @@ -138,10 +139,12 @@
describe 'when all questions have been answered' do
before do
@test_answers = @test_questions.collect{|q| Answer.create(:question_id => q.id, :response => @test_response)}
session[:respondent] = @test_respondent
end

it 'should not have a next question' do
get :show, :id => @test_response.id
assigns.should have_key(:next_question)
assigns[:next_question].should be_nil
end
end
Expand Down

0 comments on commit 045670d

Please sign in to comment.