summaryrefslogtreecommitdiff
path: root/spec/helpers
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-06-27 16:20:57 +0200
committerRémy Coutable <remy@rymai.me>2016-07-01 17:44:46 +0200
commitbd78f5733ca546bf940438b84aefa2fa3abacb36 (patch)
tree9d9ac648a594623489e628e025bde48f7ef2b2f9 /spec/helpers
parent557ca2b31ff503b36a4b65af2641fcd0f5682d5b (diff)
downloadgitlab-ce-bd78f5733ca546bf940438b84aefa2fa3abacb36.tar.gz
Exclude requesters from Project#members, Group#members and User#membersexplicit-requesters-scope
And create new Project#requesters, Group#requesters scopes. Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/members_helper_spec.rb66
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/helpers/members_helper_spec.rb b/spec/helpers/members_helper_spec.rb
index f75fdb739f6..7b2155e9a4e 100644
--- a/spec/helpers/members_helper_spec.rb
+++ b/spec/helpers/members_helper_spec.rb
@@ -57,6 +57,72 @@ describe MembersHelper do
end
end
+ describe '#can_see_request_access_button?' do
+ let(:user) { create(:user) }
+ let(:group) { create(:group, :public) }
+ let(:project) { create(:project, :public, group: group) }
+
+ before do
+ allow(helper).to receive(:current_user).and_return(user)
+ end
+
+ context 'source is a group' do
+ context 'current_user is not a member' do
+ it 'returns true' do
+ expect(helper.can_see_request_access_button?(group)).to be_truthy
+ end
+ end
+
+ context 'current_user is a member' do
+ it 'returns false' do
+ group.add_owner(user)
+
+ expect(helper.can_see_request_access_button?(group)).to be_falsy
+ end
+ end
+
+ context 'current_user is a requester' do
+ it 'returns true' do
+ group.request_access(user)
+
+ expect(helper.can_see_request_access_button?(group)).to be_truthy
+ end
+ end
+ end
+
+ context 'source is a project' do
+ context 'current_user is not a member' do
+ it 'returns true' do
+ expect(helper.can_see_request_access_button?(project)).to be_truthy
+ end
+ end
+
+ context 'current_user is a group member' do
+ it 'returns false' do
+ group.add_owner(user)
+
+ expect(helper.can_see_request_access_button?(project)).to be_falsy
+ end
+ end
+
+ context 'current_user is a group requester' do
+ it 'returns false' do
+ group.request_access(user)
+
+ expect(helper.can_see_request_access_button?(project)).to be_falsy
+ end
+ end
+
+ context 'current_user is a member' do
+ it 'returns false' do
+ project.team << [user, :master]
+
+ expect(helper.can_see_request_access_button?(project)).to be_falsy
+ end
+ end
+ end
+ end
+
describe '#remove_member_message' do
let(:requester) { build(:user) }
let(:project) { create(:project) }