Sha256: bd8046a8b40bc317c154c6c3f662f72c91abc742d5430eadc7817e4668f41124

Contents?: true

Size: 1.81 KB

Versions: 1

Compression:

Stored size: 1.81 KB

Contents

require 'test_helper'

class DucksControllerTest < ActionController::TestCase
  
  test 'create' do
    Duck.any_instance.expects(:save).returns(true)
    @duck = ducks(:basic)
    post :create, :duck => @duck.attributes
    assert_not_nil flash[:notice]
    assert_response :redirect
  end
  
  test 'create with failure' do
    Duck.any_instance.expects(:save).returns(false)
    @duck = ducks(:basic)
    post :create, :duck => @duck.attributes
    assert_not_nil flash[:error]
    assert_template 'new'
  end
  
  test 'update' do
    Duck.any_instance.expects(:save).returns(true)
    @duck = ducks(:basic)
    put :update, :id => @duck.to_param, :duck => @duck.attributes
    assert_not_nil flash[:notice]
    assert_response :redirect
  end
  
  test 'update with failure' do
    Duck.any_instance.expects(:save).returns(false)
    @duck = ducks(:basic)
    put :update, :id => @duck.to_param, :duck => @duck.attributes
    assert_not_nil flash[:error]
    assert_template 'edit'
  end
  
  test 'destroy' do
    Duck.any_instance.expects(:destroy).returns(true)
    @duck = ducks(:basic)
    delete :destroy, :id => @duck.to_param
    assert_not_nil flash[:notice]
    assert_response :redirect
  end
  
  test 'destroy with failure' do
    Duck.any_instance.expects(:destroy).returns(false)
    @duck = ducks(:basic)
    delete :destroy, :id => @duck.to_param
    assert_not_nil flash[:error]
    assert_response :redirect
  end
  
  test 'new' do
    get :new
    assert_response :success
  end
  
  test 'edit' do
    @duck = ducks(:basic)
    get :edit, :id => @duck.to_param
    assert_response :success
  end
  
  test 'show' do
    @duck = ducks(:basic)
    get :show, :id => @duck.to_param
    assert_response :success
  end
  
  test 'index' do
    get :index
    assert_response :success
    assert_not_nil assigns(:ducks)
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grimen-dry_scaffold-0.3.0 generators/dry_scaffold/prototypes/controllers/tests/test_unit/functional_test.rb