Sha256: 4ae13bee1e49680d651b2ce52996c33c505e78cf55e504b265bdd0843937701d

Contents?: true

Size: 1.78 KB

Versions: 8

Compression:

Stored size: 1.78 KB

Contents

require 'test_helper'

module Guts
  class OptionsControllerTest < ActionController::TestCase
    setup do
      @option = guts_options :option_one
      @routes = Engine.routes
    end

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

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

    test 'should create option' do
      assert_difference('Option.count') do
        post :create, option: { key: 'Testing Key', value: '123' }
      end

      assert_redirected_to options_path
      assert_equal 'Option was successfully created.', flash[:notice]
    end

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

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

    test 'should update option' do
      patch :update, id: @option, option: { value: 'Hey!' }
      assert_redirected_to options_path
      assert_equal 'Option was successfully updated.', flash[:notice]
    end
    
    test 'should fail to edit option and send back to edit' do
      patch :update, id: @option, option: { key: '' }
      assert_template 'guts/options/edit'
    end

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

      assert_redirected_to options_path
      assert_equal 'Option was successfully destroyed.', flash[:notice]
    end
    
    test 'should allow for custom paginated limit' do
      get :index, per_page: 100
      assert_equal 100, assigns(:per_page).to_i
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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