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
|
2023-03-17 16:20:25 +05:30
|
|
|
it { is_expected.to validate_inclusion_of(:highest_access_level).in_array(Gitlab::Access.all_values).allow_nil }
|
2020-04-08 14:13:33 +05:30
|
|
|
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
|