Sha256: f6838a792090953c61101c91b3736b0ab8276bfc400b81eeef1cc8b80a22a3d9

Contents?: true

Size: 1.68 KB

Versions: 5

Compression:

Stored size: 1.68 KB

Contents

require 'test_helper'

module Guts
  class GroupsControllerTest < ActionController::TestCase
    setup do
      @group  = guts_groups :test_group
      @routes = Engine.routes
    end

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

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

    test 'should create group' do
      assert_difference('Group.count') do
        post :create, group: { slug: 'group-test', title: 'Group Test' }
      end

      assert_redirected_to edit_group_path(assigns(:group))
      assert_equal 'Group was successfully created.', flash[:notice]
    end

    test 'should fail to create group and send back to new' do
      post :create, group: { title: '' }
      assert_template 'guts/groups/new'
    end

    test 'should show group' do
      get :show, id: @group
      assert_response :success
    end

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

    test 'should update group' do
      patch :update, id: @group, group: { slug: @group.slug, title: @group.title }
      assert_redirected_to edit_group_path(assigns(:group))
      assert_equal 'Group was successfully updated.', flash[:notice]
    end

    test 'should fail to update group and send back to edit' do
      patch :update, id: @group, group: { title: '' }
      assert_template 'guts/groups/edit'
    end

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

      assert_redirected_to groups_path
      assert_equal 'Group was successfully destroyed.', flash[:notice]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
guts-1.4.0 test/controllers/guts/groups_controller_test.rb
guts-1.3.6 test/controllers/guts/groups_controller_test.rb
guts-1.3.5 test/controllers/guts/groups_controller_test.rb
guts-1.3.4 test/controllers/guts/groups_controller_test.rb
guts-1.3.3 test/controllers/guts/groups_controller_test.rb