Sha256: 034d4967b0debccc0278aae68a1ce0338ca3273e722a43e63ca989f128fbef81

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

module Authz
  RSpec.describe BusinessProcess, type: :model do
    describe 'validations' do
      it { is_expected.to validate_presence_of :code }
      it { is_expected.to validate_presence_of :name }
      it { is_expected.to validate_presence_of :description }
      it { is_expected.to validate_uniqueness_of(:code) }
      it { is_expected.to validate_uniqueness_of(:name) }
      it { should allow_value('valid').for(:code) }
      it { should allow_value('valid_code').for(:code) }
      it { should_not allow_value('Invalid').for(:code) }
      it { should_not allow_value('9_a').for(:code) }

      it 'should automatically extract the code from the name' do
        bp = create(:authz_business_process, code: nil,
                                                          name: 'Manage Reports')
        expect(bp.code).to eq 'manage_reports'
      end
    end

    describe 'Associations' do
      it { should have_many(:business_process_has_controller_actions) }
      it { should have_many(:controller_actions).through(:business_process_has_controller_actions) }
      it { should have_many(:role_has_business_processes) }
      it { should have_many(:roles).through(:role_has_business_processes) }
      it { should have_many(:role_grants).through(:roles) }
      it { should have_many(:users) }
    end


  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
authz-0.0.1.alpha4 spec/models/authz/business_process_spec.rb
authz-0.0.1.alpha3 spec/models/authz/business_process_spec.rb
authz-0.0.1.alpha2 spec/models/authz/business_process_spec.rb
authz-0.0.1.alpha spec/models/authz/business_process_spec.rb