Sha256: a028932f6a0a6e76b84b761a8731cb6cc15f2a43129c4dd0c11f3d6c8b135181

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

require "test_helper"

class Admin::PostsControllerTest < ActionController::TestCase

  context "Admin" do

    setup do
      @admin = Factory(:typus_user)
      @request.session[:typus_user_id] = @admin.id
    end

    should "add a category" do
      assert @admin.can?("create", "Post")
    end

    should "destroy a post" do
      get :destroy, { :id => Factory(:post).id, :method => :delete }

      assert_response :redirect
      assert_equal "Post successfully removed.", flash[:notice]
      assert_redirected_to :action => :index
    end

  end

  context "Designer" do

    setup do
      @designer = Factory(:typus_user, :role => "designer")
      @request.session[:typus_user_id] = @designer.id
    end

    should "not_allow_designer_to_add_a_post" do
      get :new

      assert_response :redirect
      assert_equal "Designer can't perform action. (new)", flash[:notice]
      assert_redirected_to :action => :index
    end

    should "not_allow_designer_to_destroy_a_post" do
      get :destroy, { :id => Factory(:post).id, :method => :delete }

      assert_response :redirect
      assert_equal "Designer can't delete this item.", flash[:notice]
      assert_redirected_to :action => :index

    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
typus-1.0.0.pre8 test/functional/admin/resources_controller_posts_roles.rb
typus-1.0.0.pre7 test/functional/admin/resources_controller_posts_roles.rb
typus-1.0.0.pre6 test/functional/admin/resources_controller_posts_roles.rb
typus-1.0.0.pre5 test/functional/admin/resources_controller_posts_roles.rb
typus-1.0.0.pre4 test/functional/admin/resources_controller_posts_roles.rb
typus-1.0.0.pre3 test/functional/admin/resources_controller_posts_roles.rb
typus-1.0.0.pre2 test/functional/admin/resources_controller_posts_roles.rb
typus-1.0.0.pre test/functional/admin/resources_controller_posts_roles.rb