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.3.14 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.3.13 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.3.12 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.3.11 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.3.10 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.3.9 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.3.8 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.3.7 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.3.6 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.3.5 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.3.4 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.3.3 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.3.2 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.3.1 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.3.0 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.36 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.35 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.34 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.28 lib/templates/test_unit/scaffold/functional_test.rb
incline-0.2.27 lib/templates/test_unit/scaffold/functional_test.rb