Merge branch 'fix_leave_project_display' into 'master'
Fix and test leave project display The 'Leave this project' display on project page was broken. It was calling the method incorrectly, which returned `nil` and displayed nothing. This fixes the display and also adds 2 different tests for it. cc/ @jvanbaarsen @stanhu Please review and merge if you think it looks good. Thank you! See merge request !2166
This commit is contained in:
commit
3b61dc47ec
|
@ -105,6 +105,14 @@ module ProjectsHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_max_access_in_project(user_id, project)
|
||||||
|
level = project.team.max_member_access(user_id)
|
||||||
|
|
||||||
|
if level
|
||||||
|
Gitlab::Access.options_with_owner.key(level)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_project_nav_tabs(project, current_user)
|
def get_project_nav_tabs(project, current_user)
|
||||||
|
@ -277,14 +285,6 @@ module ProjectsHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_max_access_in_project(user, project)
|
|
||||||
level = project.team.max_member_access(user)
|
|
||||||
|
|
||||||
if level
|
|
||||||
Gitlab::Access.options_with_owner.key(level)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def leave_project_message(project)
|
def leave_project_message(project)
|
||||||
"Are you sure you want to leave \"#{project.name}\" project?"
|
"Are you sure you want to leave \"#{project.name}\" project?"
|
||||||
end
|
end
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
= render default_project_view
|
= render default_project_view
|
||||||
|
|
||||||
- if current_user
|
- if current_user
|
||||||
- access = user_max_access_in_project(current_user, @project)
|
- access = user_max_access_in_project(current_user.id, @project)
|
||||||
- if access
|
- if access
|
||||||
.prepend-top-20.project-footer
|
.prepend-top-20.project-footer
|
||||||
.gray-content-block.footer-block.center
|
.gray-content-block.footer-block.center
|
||||||
|
|
|
@ -70,6 +70,20 @@ feature 'Project', feature: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'leave project link' do
|
||||||
|
let(:user) { create(:user) }
|
||||||
|
let(:project) { create(:project, namespace: user.namespace) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
login_with(user)
|
||||||
|
project.team.add_user(user, Gitlab::Access::MASTER)
|
||||||
|
visit namespace_project_path(project.namespace, project)
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(page).to have_content('You have Master access to this project.') }
|
||||||
|
it { expect(page).to have_link('Leave this project') }
|
||||||
|
end
|
||||||
|
|
||||||
def remove_with_confirm(button_text, confirm_with)
|
def remove_with_confirm(button_text, confirm_with)
|
||||||
click_button button_text
|
click_button button_text
|
||||||
fill_in 'confirm_name_input', with: confirm_with
|
fill_in 'confirm_name_input', with: confirm_with
|
||||||
|
|
|
@ -53,6 +53,16 @@ describe ProjectsHelper do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'user_max_access_in_project' do
|
||||||
|
let(:project) { create(:project) }
|
||||||
|
let(:user) { create(:user) }
|
||||||
|
before do
|
||||||
|
project.team.add_user(user, Gitlab::Access::MASTER)
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(helper.user_max_access_in_project(user.id, project)).to eq('Master') }
|
||||||
|
end
|
||||||
|
|
||||||
describe "readme_cache_key" do
|
describe "readme_cache_key" do
|
||||||
let(:project) { create(:project) }
|
let(:project) { create(:project) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue