Sha256: e866584a35fd2d625b14d317174746dc5e52b4609b98923fd819c3926ba96b4b

Contents?: true

Size: 743 Bytes

Versions: 9

Compression:

Stored size: 743 Bytes

Contents

require 'rails_helper'

module Mks
  module Auth
    RSpec.describe UserRole, type: :model do
      it 'has a valid factory' do
        expect(create(:user_role)).to be_valid
      end

      it 'is invalid with no name' do
        expect(build(:user_role, name: nil)).not_to be_valid
      end

      it 'is invalid with duplicate name' do
        ur = create(:user_role)
        expect(build(:user_role, name: ur.name)).not_to be_valid
      end

      it 'can access users' do
        u = create(:user, :with_role)
        role = u.roles.first
        expect(role.users.count).to eq 1
      end

      it 'can access menus' do
        ur = create(:user_role, :with_menus)
        expect(ur.menus.count).to eq 3
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mks_auth-1.4.0 spec/models/mks/auth/user_role_spec.rb
mks_auth-1.2.0 spec/models/mks/auth/user_role_spec.rb
mks_auth-1.0.0 spec/models/mks/auth/user_role_spec.rb
mks_auth-1.0.9 spec/models/mks/auth/user_role_spec.rb
mks_auth-1.0.8 spec/models/mks/auth/user_role_spec.rb
mks_auth-1.0.7 spec/models/mks/auth/user_role_spec.rb
mks_auth-1.0.6 spec/models/mks/auth/user_role_spec.rb
mks_auth-1.0.5 spec/models/mks/auth/user_role_spec.rb
mks_auth-1.0.4 spec/models/mks/auth/user_role_spec.rb