debian-mirror-gitlab/spec/policies/project_member_policy_spec.rb

44 lines
1.3 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ProjectMemberPolicy do
let(:project) { create(:project) }
let(:maintainer_user) { create(:user) }
let(:member) { create(:project_member, project: project, user: member_user) }
subject { described_class.new(maintainer_user, member) }
before do
create(:project_member, :maintainer, project: project, user: maintainer_user)
end
context 'with regular member' do
let(:member_user) { create(:user) }
2021-06-08 01:23:25 +05:30
it { is_expected.to be_allowed(:read_project) }
2020-07-28 23:09:34 +05:30
it { is_expected.to be_allowed(:update_project_member) }
it { is_expected.to be_allowed(:destroy_project_member) }
it { is_expected.not_to be_allowed(:destroy_project_bot_member) }
end
2021-06-08 01:23:25 +05:30
context 'when user is project owner' do
2022-04-04 11:22:00 +05:30
let(:member_user) { project.first_owner }
2021-06-08 01:23:25 +05:30
let(:member) { project.members.find_by!(user: member_user) }
it { is_expected.to be_allowed(:read_project) }
it { is_expected.to be_disallowed(:update_project_member) }
it { is_expected.to be_disallowed(:destroy_project_member) }
end
2020-07-28 23:09:34 +05:30
context 'with a bot member' do
let(:member_user) { create(:user, :project_bot) }
it { is_expected.to be_allowed(:destroy_project_bot_member) }
it { is_expected.not_to be_allowed(:update_project_member) }
it { is_expected.not_to be_allowed(:destroy_project_member) }
end
end