Sha256: c6803c301c32f98071d970b27fdaf166f601ebb0c1dd75406f2224232950ac61

Contents?: true

Size: 1.54 KB

Versions: 39

Compression:

Stored size: 1.54 KB

Contents

require 'test_helper'

class AbilityTest < ActiveSupport::TestCase
  fixtures :all

  def test_superuser_permission
    ability = Ability.new(adminpanel_users(:valid))

    assert ability.can?(:manage, :all)
  end

  def test_read_permission
    ability = Ability.new(adminpanel_users(:reader))

    assert ability.can?(:read, Adminpanel::Product)
    assert ability.cannot?(:destroy, Adminpanel::Product)
    assert ability.cannot?(:update, Adminpanel::Product)
    assert ability.cannot?(:create, Adminpanel::Product)
  end

  def test_create_permission
    ability = Ability.new(adminpanel_users(:creator))

    assert ability.cannot?(:destroy, Adminpanel::Product)
    assert ability.cannot?(:update, Adminpanel::Product)
    assert ability.can?(:create, Adminpanel::Product)
  end

  def test_delete_permission
    ability = Ability.new(adminpanel_users(:deleter))

    assert ability.can?(:destroy, Adminpanel::Product)
    assert ability.cannot?(:update, Adminpanel::Product)
    assert ability.cannot?(:create, Adminpanel::Product)
  end

  def test_updater_permission
    ability = Ability.new(adminpanel_users(:updater))

    assert ability.cannot?(:destroy, Adminpanel::Product)
    assert ability.can?(:update, Adminpanel::Product)
    assert ability.cannot?(:create, Adminpanel::Product)
  end

  def test_superuser_permission
    ability = Ability.new(adminpanel_users(:superuser))

    assert ability.cannot?(:destroy, Adminpanel::Product)
    assert ability.can?(:update, Adminpanel::Product)
    assert ability.can?(:create, Adminpanel::Product)
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
adminpanel-3.6.1 test/models/ability_test.rb
adminpanel-3.6.0 test/models/ability_test.rb
adminpanel-3.5.1 test/models/ability_test.rb
adminpanel-3.5.0 test/models/ability_test.rb
adminpanel-3.4.7 test/models/ability_test.rb
adminpanel-3.4.6 test/models/ability_test.rb
adminpanel-3.4.5 test/models/ability_test.rb
adminpanel-3.4.4 test/models/ability_test.rb
adminpanel-3.4.3 test/models/ability_test.rb
adminpanel-3.4.2 test/models/ability_test.rb
adminpanel-3.4.1 test/models/ability_test.rb
adminpanel-3.4.0 test/models/ability_test.rb
adminpanel-3.3.4 test/models/ability_test.rb
adminpanel-3.3.3 test/models/ability_test.rb
adminpanel-3.3.0 test/models/ability_test.rb
adminpanel-3.2.1 test/models/ability_test.rb
adminpanel-3.2.0 test/models/ability_test.rb
adminpanel-3.1.0 test/models/ability_test.rb
adminpanel-3.0.0 test/models/ability_test.rb
adminpanel-2.6.1 test/models/ability_test.rb