debian-mirror-gitlab/spec/models/user_highest_role_spec.rb

30 lines
917 B
Ruby
Raw Normal View History

2020-04-08 14:13:33 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe UserHighestRole do
2020-04-08 14:13:33 +05:30
describe 'associations' do
it { is_expected.to belong_to(:user).required }
end
describe 'validations' do
it { is_expected.to validate_inclusion_of(:highest_access_level).in_array([nil, *Gitlab::Access.all_values]) }
end
2020-04-22 19:07:51 +05:30
describe 'scopes' do
describe '.with_highest_access_level' do
let(:developer_access_level) { Gitlab::Access::DEVELOPER }
let!(:developer) { create(:user_highest_role, :developer) }
let!(:another_developer) { create(:user_highest_role, :developer) }
let!(:maintainer) { create(:user_highest_role, :maintainer) }
it 'only returns entry for developer access level' do
expect(described_class.with_highest_access_level(developer_access_level)).to contain_exactly(
developer,
another_developer
)
end
end
end
2020-04-08 14:13:33 +05:30
end