Sha256: 33c2857a9597344dd267c0d69d0ad50af31d3032470d8e38b845691a9c94241e

Contents?: true

Size: 863 Bytes

Versions: 4

Compression:

Stored size: 863 Bytes

Contents

require 'rails_helper'
require 'cancan/matchers'

# TODO: add more ability tests
RSpec.describe MnoEnterprise::Ability, type: :model do
  subject(:ability) { described_class.new(user) }
  let(:user) { FactoryGirl.build(:user, admin_role: admin_role) }
  let(:admin_role) { nil }
  let(:organization) { FactoryGirl.build(:organization) }

  before { allow(user).to receive(:role).with(organization) { nil } }

  context 'when User#admin_role is admin' do
    let(:admin_role) { 'admin' }
    it { is_expected.to be_able_to(:manage_app_instances, organization) }
  end

  context 'when User#admin_role has a random case' do
    let(:admin_role) { 'ADmIn' }
    it { is_expected.to be_able_to(:manage_app_instances, organization) }
  end

  context 'when no User#admin_role' do
    it { is_expected.not_to be_able_to(:manage_app_instances, organization) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mno-enterprise-core-3.3.3 spec/models/mno_enterprise/ability_spec.rb
mno-enterprise-core-3.3.2 spec/models/mno_enterprise/ability_spec.rb
mno-enterprise-core-3.3.1 spec/models/mno_enterprise/ability_spec.rb
mno-enterprise-core-3.3.0 spec/models/mno_enterprise/ability_spec.rb