Sha256: 49d6dbaf0d9fa74ea7eb2bd0711d2df31431321e31ce951dc8e1a6536518f7af

Contents?: true

Size: 1.63 KB

Versions: 8

Compression:

Stored size: 1.63 KB

Contents

require 'test_helper'

module Guts
  class TypesControllerTest < ActionController::TestCase
    setup do
      @type   = guts_types :page_type
      @routes = Engine.routes
    end

    test 'should get index' do
      get :index
      assert_response :success
      assert_not_nil assigns(:types)
    end

    test 'should get new' do
      get :new
      assert_response :success
    end

    test 'should create type' do
      assert_difference('Type.count') do
        post :create, type: { slug: 'controller-type', title: 'Controller Type' }
      end

      assert_redirected_to types_path
      assert_equal 'Type was successfully created.', flash[:notice]
    end

    test 'should fail to create type and send back to new' do
      post :create, type: { title: '' }
      assert_template 'guts/types/new'
    end
    
    test 'should show type' do
      get :show, id: @type
      assert_response :success
    end

    test 'should get edit' do
      get :edit, id: @type
      assert_response :success
    end

    test 'should update type' do
      patch :update, id: @type, type: { slug: @type.slug, title: @type.title }
      assert_redirected_to types_path
      assert_equal 'Type was successfully updated.', flash[:notice]
    end
    
    test 'should fail to edit type and send back to edit' do
      patch :update, id: @type, type: { title: '' }
      assert_template 'guts/types/edit'
    end

    test 'should destroy type' do
      assert_difference('Type.count', -1) do
        delete :destroy, id: @type
      end

      assert_redirected_to types_path
      assert_equal 'Type was successfully destroyed.', flash[:notice]
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
guts-1.3.2 test/controllers/guts/types_controller_test.rb
guts-1.3.1 test/controllers/guts/types_controller_test.rb
guts-1.3.0 test/controllers/guts/types_controller_test.rb
guts-1.2.2 test/controllers/guts/types_controller_test.rb
guts-1.2.1 test/controllers/guts/types_controller_test.rb
guts-1.2.0 test/controllers/guts/types_controller_test.rb
guts-1.1.1 test/controllers/guts/types_controller_test.rb
guts-1.1.0 test/controllers/guts/types_controller_test.rb