Address Douwe's feedback

- Make it more explicit that `source` must respond to `#group` and that
`#group` must be present.
- Indent subsequent lines of a multi-line condition.

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2016-06-17 18:37:53 +02:00
parent e71ce77e39
commit 7c9571a3ba
No known key found for this signature in database
GPG key ID: 46DF07E5CD9E96AB
4 changed files with 53 additions and 20 deletions

View file

@ -8,8 +8,8 @@ module MembersHelper
def default_show_roles(member)
can?(current_user, action_member_permission(:update, member), member) ||
can?(current_user, action_member_permission(:destroy, member), member) ||
can?(current_user, action_member_permission(:admin, member), member.source)
can?(current_user, action_member_permission(:destroy, member), member) ||
can?(current_user, action_member_permission(:admin, member), member.source)
end
def remove_member_message(member, user: nil)

View file

@ -1,5 +1,5 @@
- member = source.members.find_by(user_id: current_user.id)
- group_member = source.group.members.find_by(user_id: current_user.id) if source.try(:group)
- group_member = source.group.members.find_by(user_id: current_user.id) if source.respond_to?(:group) && source.group
- unless group_member
- if member

View file

@ -0,0 +1,50 @@
require 'spec_helper'
feature 'Projects > Members > Group member cannot request access to his group project', feature: true do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
background do
end
scenario 'owner does not see the request access button' do
group.add_owner(user)
login_and_visit_project_page(user)
expect(page).not_to have_content 'Request Access'
end
scenario 'master does not see the request access button' do
group.add_master(user)
login_and_visit_project_page(user)
expect(page).not_to have_content 'Request Access'
end
scenario 'developer does not see the request access button' do
group.add_developer(user)
login_and_visit_project_page(user)
expect(page).not_to have_content 'Request Access'
end
scenario 'reporter does not see the request access button' do
group.add_reporter(user)
login_and_visit_project_page(user)
expect(page).not_to have_content 'Request Access'
end
scenario 'guest does not see the request access button' do
group.add_guest(user)
login_and_visit_project_page(user)
expect(page).not_to have_content 'Request Access'
end
def login_and_visit_project_page(user)
login_as(user)
visit namespace_project_path(project.namespace, project)
end
end

View file

@ -1,17 +0,0 @@
require 'spec_helper'
feature 'Projects > Members > Group owner cannot request access to his group project', feature: true do
let(:owner) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
background do
group.add_owner(owner)
login_as(owner)
visit namespace_project_path(project.namespace, project)
end
scenario 'owner does not see the request access button' do
expect(page).not_to have_content 'Request Access'
end
end