summaryrefslogtreecommitdiff
path: root/spec/helpers/invite_members_helper_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-26 15:08:40 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-26 15:08:40 +0000
commita1908447b77a6d005a77f1be2f717cd35274c82d (patch)
tree8348f9346b1631d78b0ae5e5493ebdef5273d5cb /spec/helpers/invite_members_helper_spec.rb
parent6e320396b26439a0c3fa1df1ce9f4c2395518227 (diff)
downloadgitlab-ce-a1908447b77a6d005a77f1be2f717cd35274c82d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers/invite_members_helper_spec.rb')
-rw-r--r--spec/helpers/invite_members_helper_spec.rb120
1 files changed, 80 insertions, 40 deletions
diff --git a/spec/helpers/invite_members_helper_spec.rb b/spec/helpers/invite_members_helper_spec.rb
index b4e05d67553..d75b3c9f2e3 100644
--- a/spec/helpers/invite_members_helper_spec.rb
+++ b/spec/helpers/invite_members_helper_spec.rb
@@ -7,70 +7,110 @@ RSpec.describe InviteMembersHelper do
let_it_be(:developer) { create(:user, developer_projects: [project]) }
let(:owner) { project.owner }
- before do
- assign(:project, project)
- end
+ context 'with project' do
+ before do
+ assign(:project, project)
+ end
- describe "#directly_invite_members?" do
- context 'when the user is an owner' do
- before do
- allow(helper).to receive(:current_user) { owner }
- end
+ describe "#directly_invite_members?" do
+ context 'when the user is an owner' do
+ before do
+ allow(helper).to receive(:current_user) { owner }
+ end
+
+ it 'returns false' do
+ allow(helper).to receive(:experiment_enabled?).with(:invite_members_version_a) { false }
- it 'returns false' do
- allow(helper).to receive(:experiment_enabled?).with(:invite_members_version_a) { false }
+ expect(helper.directly_invite_members?).to eq false
+ end
- expect(helper.directly_invite_members?).to eq false
+ it 'returns true' do
+ allow(helper).to receive(:experiment_enabled?).with(:invite_members_version_a) { true }
+
+ expect(helper.directly_invite_members?).to eq true
+ end
end
- it 'returns true' do
- allow(helper).to receive(:experiment_enabled?).with(:invite_members_version_a) { true }
+ context 'when the user is a developer' do
+ before do
+ allow(helper).to receive(:current_user) { developer }
+ end
+
+ it 'returns false' do
+ allow(helper).to receive(:experiment_enabled?).with(:invite_members_version_a) { true }
- expect(helper.directly_invite_members?).to eq true
+ expect(helper.directly_invite_members?).to eq false
+ end
end
end
- context 'when the user is a developer' do
- before do
- allow(helper).to receive(:current_user) { developer }
+ describe "#indirectly_invite_members?" do
+ context 'when a user is a developer' do
+ before do
+ allow(helper).to receive(:current_user) { developer }
+ end
+
+ it 'returns false' do
+ allow(helper).to receive(:experiment_enabled?).with(:invite_members_version_b) { false }
+
+ expect(helper.indirectly_invite_members?).to eq false
+ end
+
+ it 'returns true' do
+ allow(helper).to receive(:experiment_enabled?).with(:invite_members_version_b) { true }
+
+ expect(helper.indirectly_invite_members?).to eq true
+ end
end
- it 'returns false' do
- allow(helper).to receive(:experiment_enabled?).with(:invite_members_version_a) { true }
+ context 'when a user is an owner' do
+ before do
+ allow(helper).to receive(:current_user) { owner }
+ end
- expect(helper.directly_invite_members?).to eq false
+ it 'returns false' do
+ allow(helper).to receive(:experiment_enabled?).with(:invite_members_version_b) { true }
+
+ expect(helper.indirectly_invite_members?).to eq false
+ end
end
end
end
- describe "#indirectly_invite_members?" do
- context 'when a user is a developer' do
- before do
- allow(helper).to receive(:current_user) { developer }
- end
+ context 'with group' do
+ let_it_be(:group) { create(:group) }
- it 'returns false' do
- allow(helper).to receive(:experiment_enabled?).with(:invite_members_version_b) { false }
+ describe "#invite_group_members?" do
+ context 'when the user is an owner' do
+ before do
+ group.add_owner(owner)
+ allow(helper).to receive(:current_user) { owner }
+ end
- expect(helper.indirectly_invite_members?).to eq false
- end
+ it 'returns false' do
+ allow(helper).to receive(:experiment_enabled?).with(:invite_members_empty_group_version_a) { false }
- it 'returns true' do
- allow(helper).to receive(:experiment_enabled?).with(:invite_members_version_b) { true }
+ expect(helper.invite_group_members?(group)).to eq false
+ end
- expect(helper.indirectly_invite_members?).to eq true
- end
- end
+ it 'returns true' do
+ allow(helper).to receive(:experiment_enabled?).with(:invite_members_empty_group_version_a) { true }
- context 'when a user is an owner' do
- before do
- allow(helper).to receive(:current_user) { owner }
+ expect(helper.invite_group_members?(group)).to eq true
+ end
end
- it 'returns false' do
- allow(helper).to receive(:experiment_enabled?).with(:invite_members_version_b) { true }
+ context 'when the user is a developer' do
+ before do
+ group.add_developer(developer)
+ allow(helper).to receive(:current_user) { developer }
+ end
+
+ it 'returns false' do
+ allow(helper).to receive(:experiment_enabled?).with(:invite_members_empty_group_version_a) { true }
- expect(helper.indirectly_invite_members?).to eq false
+ expect(helper.invite_group_members?(group)).to eq false
+ end
end
end
end