Merge branch '34907-dont-show-pipeline-schedule-button-for-non-member' into 'master'

Do not show pipeline schedule button for non-member

Closes #34907

See merge request !12757
This commit is contained in:
Kamil Trzciński 2017-07-11 15:18:59 +00:00
commit 2e9517af8e
3 changed files with 197 additions and 158 deletions

View file

@ -12,6 +12,7 @@
- schedule_path_proc = ->(scope) { pipeline_schedules_path(@project, scope: scope) } - schedule_path_proc = ->(scope) { pipeline_schedules_path(@project, scope: scope) }
= render "tabs", schedule_path_proc: schedule_path_proc, all_schedules: @all_schedules, scope: @scope = render "tabs", schedule_path_proc: schedule_path_proc, all_schedules: @all_schedules, scope: @scope
- if can?(current_user, :create_pipeline_schedule, @project)
.nav-controls .nav-controls
= link_to new_project_pipeline_schedule_path(@project), class: 'btn btn-create' do = link_to new_project_pipeline_schedule_path(@project), class: 'btn btn-create' do
%span= _('New schedule') %span= _('New schedule')

View file

@ -0,0 +1,4 @@
---
title: Do not show pipeline schedule button for non-member
merge_request: 12757
author: Takuya Noguchi

View file

@ -9,9 +9,10 @@ feature 'Pipeline Schedules', :feature, js: true do
let(:scope) { nil } let(:scope) { nil }
let!(:user) { create(:user) } let!(:user) { create(:user) }
context 'logged in as master' do
before do before do
project.add_master(user) project.add_master(user)
sign_in(user) gitlab_sign_in(user)
end end
describe 'GET /projects/pipeline_schedules' do describe 'GET /projects/pipeline_schedules' do
@ -194,6 +195,39 @@ feature 'Pipeline Schedules', :feature, js: true do
end end
end end
end end
end
context 'logged in as non-member' do
before do
gitlab_sign_in(user)
end
describe 'GET /projects/pipeline_schedules' do
before do
visit_pipelines_schedules
end
describe 'The view' do
it 'does not show create schedule button' do
expect(page).not_to have_link('New schedule')
end
end
end
end
context 'not logged in' do
describe 'GET /projects/pipeline_schedules' do
before do
visit_pipelines_schedules
end
describe 'The view' do
it 'does not show create schedule button' do
expect(page).not_to have_link('New schedule')
end
end
end
end
def visit_new_pipeline_schedule def visit_new_pipeline_schedule
visit new_project_pipeline_schedule_path(project, pipeline_schedule) visit new_project_pipeline_schedule_path(project, pipeline_schedule)