Sha256: 2cda3439d8cc4c40f479011f4488933fe061cf5955639757e6b5419692cec5df

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'test_helper'

class PoliciesTest < Minitest::Test
  def setup
    @project = Project.new
  end

  def test_symbol_conversion
    assert_equal authorized?(:show, :project), true
    assert_equal authorized?(:edit, :project), false
  end

  def test_symbol_conversion_without_action_argument
    assert_equal authorized?(:project), false
  end

  def test_plural_symbol_conversion
    assert_equal authorized?(:show, :projects), true
    assert_equal authorized?(:edit, :projects), false
  end

  def test_plural_symbol_conversion_without_action_argument
    assert_equal authorized?(:projects), false
  end

  def test_object_conversion
    assert_equal authorized?(:show, @project), true
    assert_equal authorized?(:edit, @project), false
  end

  def test_unauthorized_error_raised
    assert_raises Policies::UnauthorizedError do
      authorize(:edit, @project)
    end
  end

  def test_unauthorized_error_raised_without_action_argument
    assert_raises Policies::UnauthorizedError do
      authorize(@project)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
policies-1.1.0 test/policies_test.rb