Sha256: 79f7923239e7f0963334fadbfaa2c9a1a01e9a106ec8a79c9f423c4e3f046c84

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'test_helper'

class SurveyAdmin::QuestionsControllerTest < ActionController::TestCase
  #fixtures :questions

  def test_index
    get :index
    assert_template 'index'
  end

  def test_show
    question = Factory(:question)
    get :show, :id => question.id
    assert_template 'show'
  end

  def test_new
    get :new
    assert_template 'new'
  end

  def test_create_invalid
    Question.any_instance.stubs(:valid?).returns(false)
    post :create
    assert_template 'new'
  end

  def test_create_valid
    Question.any_instance.stubs(:valid?).returns(true)
    post :create
    assert_redirected_to survey_admin_question_answers_url(assigns(:question))
  end

  def test_edit
    question = Factory(:question)
    get :edit, :id => question.id
    assert_template 'edit'
  end

  def test_update_invalid
    question = Factory(:question)
    Question.any_instance.stubs(:valid?).returns(false)
    put :update, :id => question.id
    assert_template 'edit'
  end

  def test_update_valid
    question = Factory(:question)
    Question.any_instance.stubs(:valid?).returns(true)
    put :update, :id => question.id
    assert_redirected_to survey_admin_question_answers_url(assigns(:question))
  end

  def test_destroy
    question = Factory(:question)
    delete :destroy, :id => question.id
    assert_redirected_to survey_admin_questions_url
    assert Question.exists?(question.id)
    assert !Question.find(question.id).active
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
survey_says-0.0.1 test/functional/survey_admin/questions_controller_test.rb