blob: c6679069c491745f7e2319fe1374ef6fcef40e26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# frozen_string_literal: true
require "spec_helper"
RSpec.describe Users::GroupCalloutsHelper do
let_it_be(:user, refind: true) { create(:user) }
let_it_be(:group) { create(:group) }
before do
allow(helper).to receive(:current_user).and_return(user)
end
describe '.show_invite_banner?' do
subject { helper.show_invite_banner?(group) }
context 'when user has the admin ability for the group' do
before do
group.add_owner(user)
end
context 'when the invite_members_banner has not been dismissed' do
it { is_expected.to eq(true) }
context 'when the group was just created' do
before do
flash[:notice] = "Group #{group.name} was successfully created"
end
it { is_expected.to eq(false) }
end
context 'with concerning multiple members' do
let_it_be(:user_2) { create(:user) }
context 'on current group' do
before do
group.add_guest(user_2)
end
it { is_expected.to eq(false) }
end
context 'on current group that is a subgroup' do
let_it_be(:subgroup) { create(:group, parent: group) }
subject { helper.show_invite_banner?(subgroup) }
context 'with only one user on parent and this group' do
it { is_expected.to eq(true) }
end
context 'when another user is on this group' do
before do
subgroup.add_guest(user_2)
end
it { is_expected.to eq(false) }
end
context 'when another user is on the parent group' do
before do
group.add_guest(user_2)
end
it { is_expected.to eq(false) }
end
end
end
end
context 'when the invite_members_banner has been dismissed' do
before do
create(
:group_callout,
user: user,
group: group,
feature_name: described_class::INVITE_MEMBERS_BANNER
)
end
it { is_expected.to eq(false) }
end
end
context 'when user does not have admin ability for the group' do
it { is_expected.to eq(false) }
end
end
end
|