Sha256: 39137188193a6a73d3b5f0d416613b4ca9bbf16f9ce394877882a7066e0dfe37

Contents?: true

Size: 1.68 KB

Versions: 43

Compression:

Stored size: 1.68 KB

Contents

require 'test_helper'

<% module_namespacing do -%>
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
  setup do
    @<%= singular_table_name %> = <%= fixture_name %>(:one)
<% if mountable_engine? -%>
    @routes = Engine.routes
<% end -%>
    # Log in as the admin to ensure full access.
    # You may want to test accessibility separately.
    log_in_as incline_users(:admin)
  end

  test "should get index" do
    get :index
    assert_response :success
  end

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

  test "should create <%= singular_table_name %>" do
    # To avoid issues with uniqueness, we destroy the item first.
    @<%= singular_table_name %>.destroy
    
    # Now we should be able to create an item with the same info. 
    assert_difference('<%= class_name %>.count') do
      post :create, <%= "#{singular_table_name}: { #{attributes_hash} }" %>
    end

    assert_redirected_to <%= index_helper %>_path
  end

  test "should show <%= singular_table_name %>" do
    get :show, id: <%= "@#{singular_table_name}" %>
    assert_response :success
  end

  test "should get edit" do
    get :edit, id: <%= "@#{singular_table_name}" %>
    assert_response :success
  end

  test "should update <%= singular_table_name %>" do
    patch :update, id: <%= "@#{singular_table_name}" %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %>
    assert_redirected_to <%= index_helper %>_path
  end

  test "should destroy <%= singular_table_name %>" do
    assert_difference('<%= class_name %>.count', -1) do
      delete :destroy, id: <%= "@#{singular_table_name}" %>
    end

    assert_redirected_to <%= index_helper %>_path
  end
end
<% end -%>

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
incline-0.2.26 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.25 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.24 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.23 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.22 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.21 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.20 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.19 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.18 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.17 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.16 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.15 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.14 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.13 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.12 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.11 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.10 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.9 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.8 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.7 lib/templates/test_unit/scaffold/functional_test.rb