Sha256: 6c09d4e8941d9c8c3a51c57441cc72d89234d4d0f56a98233b81bc7eb0f0a1e0

Contents?: true

Size: 1.7 KB

Versions: 21

Compression:

Stored size: 1.7 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

class <%= controller_class_name %>ControllerTest < ActionController::TestCase
  context 'GET to index' do
    setup do
      get :index
    end
    should_respond_with :success
    should_assign_to :<%= table_name %>
  end

  context 'GET to new' do
    setup do
      get :new
    end

    should_respond_with :success
    should_render_template :new
    should_assign_to :<%= file_name %>
  end

  context 'POST to create' do
    setup do
      post :create, :<%= file_name %> => Factory.attributes_for(:<%= file_name %>)
      @<%= file_name %> = <%= class_name %>.find(:all).last
    end
    
    should_redirect_to '<%= file_name %>_path(@<%= file_name %>)'
  end

  context 'GET to show' do
    setup do
      @<%= file_name %> = Factory(:<%= file_name %>)
      get :show, :id => @<%= file_name %>.id
    end
    should_respond_with :success
    should_render_template :show
    should_assign_to :<%= file_name %>
  end

  context 'GET to edit' do
    setup do
      @<%= file_name %> = Factory(:<%= file_name %>)
      get :edit, :id => @<%= file_name %>.id
    end
    should_respond_with :success
    should_render_template :edit
    should_assign_to :<%= file_name %>
  end

  context 'PUT to update' do
    setup do
      @<%= file_name %> = Factory(:<%= file_name %>)
      put :update, :id => @<%= file_name %>.id, :<%= file_name %> => Factory.attributes_for(:<%= file_name %>)
    end
    should_redirect_to '<%= file_name %>_path(@<%= file_name %>)'
  end

  context 'DELETE to destroy' do
    setup do
      @<%= file_name %> = Factory(:<%= file_name %>)
      delete :destroy, :id => @<%= file_name %>.id
    end
    should_redirect_to '<%= table_name %>_path'
  end
end

Version data entries

21 entries across 21 versions & 8 rubygems

Version Path
coreymartella-dmd_generator-0.2.3 rails_generators/dmd_scaffold/templates/functional_test/basic.rb
jeffleeismyhero-shoulda_generator-0.3.0 rails_generators/shoulda_scaffold/templates/functional_test/basic.rb
jeffleeismyhero-shoulda_generator-0.3.1 rails_generators/shoulda_scaffold/templates/functional_test/basic.rb
martijn-shoulda_generator-0.2.1 rails_generators/shoulda_scaffold/templates/functional_test/basic.rb
mattyoho-shoulda_generator-0.2.1 rails_generators/shoulda_scaffold/templates/functional_test/basic.rb
stefanpenner-my_generator-0.1.1 rails_generators/shoulda_scaffold/templates/functional_test/basic.rb
stefanpenner-my_generator-0.1.2 rails_generators/my_scaffold/templates/functional_test/basic.rb
stefanpenner-my_generator-0.1.3 rails_generators/my_scaffold/templates/functional_test/basic.rb
stefanpenner-my_scaffold-0.1.3 rails_generators/my_scaffold/templates/functional_test/basic.rb
stefanpenner-my_scaffold-1.0.0 generators/my_scaffold/templates/functional_test/basic.rb
stefanpenner-my_scaffold-1.1.0 generators/my_scaffold/templates/functional_test/basic.rb
stefanpenner-my_scaffold-1.2.0 generators/my_scaffold/templates/functional_test/basic.rb
stefanpenner-my_scaffold-1.2.1 generators/my_scaffold/templates/functional_test/basic.rb
stefanpenner-my_scaffold-1.4.0 generators/my_scaffold/templates/functional_test/basic.rb
stefanpenner-my_scaffold-1.4.1 generators/my_scaffold/templates/functional_test/basic.rb
stefanpenner-shoulda_generator-0.2.1 rails_generators/shoulda_scaffold/templates/functional_test/basic.rb
stefanpenner-shoulda_generator-0.2.2 rails_generators/shoulda_scaffold/templates/functional_test/basic.rb
technicalpickles-shoulda_generator-0.1.0 rails_generators/shoulda_scaffold/templates/functional_test/basic.rb
technicalpickles-shoulda_generator-0.1.1 rails_generators/shoulda_scaffold/templates/functional_test/basic.rb
technicalpickles-shoulda_generator-0.1.2 rails_generators/shoulda_scaffold/templates/functional_test/basic.rb