diff options
Diffstat (limited to 'spec/helpers/invite_members_helper_spec.rb')
-rw-r--r-- | spec/helpers/invite_members_helper_spec.rb | 120 |
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 |