Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
c023bbbb
Commit
c023bbbb
authored
Jun 30, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix policy by new guild line
parent
7d5351e1
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
135 deletions
+111
-135
app/policies/ci/pipeline_schedule_policy.rb
app/policies/ci/pipeline_schedule_policy.rb
+10
-8
spec/controllers/projects/pipeline_schedules_controller_spec.rb
...ontrollers/projects/pipeline_schedules_controller_spec.rb
+81
-106
spec/features/projects/pipeline_schedules_spec.rb
spec/features/projects/pipeline_schedules_spec.rb
+20
-21
No files found.
app/policies/ci/pipeline_schedule_policy.rb
View file @
c023bbbb
...
@@ -2,22 +2,24 @@ module Ci
...
@@ -2,22 +2,24 @@ module Ci
class
PipelineSchedulePolicy
<
PipelinePolicy
class
PipelineSchedulePolicy
<
PipelinePolicy
alias_method
:pipeline_schedule
,
:subject
alias_method
:pipeline_schedule
,
:subject
def
rules
condition
(
:protected_action
)
do
super
owned_by_developer?
&&
owned_by_another?
if
owned_by_developer?
&&
owned_by_another?
cannot!
:update_pipeline_schedule
end
end
end
rule
{
protected_action
}.
prevent
:update_pipeline_schedule
private
private
def
owned_by_developer?
def
owned_by_developer?
pipeline_schedule
.
project
.
team
.
developer?
(
user
)
return
false
unless
@user
pipeline_schedule
.
project
.
team
.
developer?
(
@user
)
end
end
def
owned_by_another?
def
owned_by_another?
!
pipeline_schedule
.
owned_by?
(
user
)
return
false
unless
@user
!
pipeline_schedule
.
owned_by?
(
@user
)
end
end
end
end
end
end
spec/controllers/projects/pipeline_schedules_controller_spec.rb
View file @
c023bbbb
This diff is collapsed.
Click to expand it.
spec/features/projects/pipeline_schedules_spec.rb
View file @
c023bbbb
...
@@ -19,19 +19,12 @@ feature 'Pipeline Schedules', :feature, js: true do
...
@@ -19,19 +19,12 @@ feature 'Pipeline Schedules', :feature, js: true do
visit_pipelines_schedules
visit_pipelines_schedules
end
end
it
'avoids N + 1 queries'
do
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
visit_pipelines_schedules
}.
count
create_list
(
:ci_pipeline_schedule
,
2
,
project:
project
)
expect
{
visit_pipelines_schedules
}.
not_to
exceed_query_limit
(
control_count
)
end
describe
'The view'
do
describe
'The view'
do
it
'displays the required information description'
do
it
'displays the required information description'
do
page
.
within
(
'.pipeline-schedule-table-row'
)
do
page
.
within
(
'.pipeline-schedule-table-row'
)
do
expect
(
page
).
to
have_content
(
'pipeline schedule'
)
expect
(
page
).
to
have_content
(
'pipeline schedule'
)
expect
(
page
).
to
have_content
(
pipeline_schedule
.
real_next_run
.
strftime
(
'%b %d, %Y'
))
expect
(
find
(
".next-run-cell time"
)[
'data-original-title'
])
.
to
include
(
pipeline_schedule
.
real_next_run
.
strftime
(
'%b %d, %Y'
))
expect
(
page
).
to
have_link
(
'master'
)
expect
(
page
).
to
have_link
(
'master'
)
expect
(
page
).
to
have_link
(
"#
#{
pipeline
.
id
}
"
)
expect
(
page
).
to
have_link
(
"#
#{
pipeline
.
id
}
"
)
end
end
...
@@ -62,7 +55,7 @@ feature 'Pipeline Schedules', :feature, js: true do
...
@@ -62,7 +55,7 @@ feature 'Pipeline Schedules', :feature, js: true do
it
'deletes the pipeline'
do
it
'deletes the pipeline'
do
click_link
'Delete'
click_link
'Delete'
expect
(
page
).
not_to
have_c
ontent
(
'pipeline schedule'
)
expect
(
page
).
not_to
have_c
ss
(
".pipeline-schedule-table-row"
)
end
end
end
end
...
@@ -150,16 +143,18 @@ feature 'Pipeline Schedules', :feature, js: true do
...
@@ -150,16 +143,18 @@ feature 'Pipeline Schedules', :feature, js: true do
scenario
'user sees the new variable in edit window'
do
scenario
'user sees the new variable in edit window'
do
find
(
".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']"
).
click
find
(
".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']"
).
click
expect
(
find
(
".pipeline-variable-list .pipeline-variable-row:nth-child(1) .pipeline-variable-key-input"
).
value
).
to
eq
(
'AAA'
)
page
.
within
(
'.pipeline-variable-list'
)
do
expect
(
find
(
".pipeline-variable-list .pipeline-variable-row:nth-child(1) .pipeline-variable-value-input"
).
value
).
to
eq
(
'AAA123'
)
expect
(
find
(
".pipeline-variable-row:nth-child(1) .pipeline-variable-key-input"
).
value
).
to
eq
(
'AAA'
)
expect
(
find
(
".pipeline-variable-list .pipeline-variable-row:nth-child(2) .pipeline-variable-key-input"
).
value
).
to
eq
(
'BBB'
)
expect
(
find
(
".pipeline-variable-row:nth-child(1) .pipeline-variable-value-input"
).
value
).
to
eq
(
'AAA123'
)
expect
(
find
(
".pipeline-variable-list .pipeline-variable-row:nth-child(2) .pipeline-variable-value-input"
).
value
).
to
eq
(
'BBB123'
)
expect
(
find
(
".pipeline-variable-row:nth-child(2) .pipeline-variable-key-input"
).
value
).
to
eq
(
'BBB'
)
expect
(
find
(
".pipeline-variable-row:nth-child(2) .pipeline-variable-value-input"
).
value
).
to
eq
(
'BBB123'
)
end
end
end
end
end
context
'when user edits a variable of a pipeline schedule'
do
context
'when user edits a variable of a pipeline schedule'
do
background
do
background
do
create
(
:ci_pipeline_schedule
,
owner:
user
).
tap
do
|
pipeline_schedule
|
create
(
:ci_pipeline_schedule
,
project:
project
,
owner:
user
).
tap
do
|
pipeline_schedule
|
create
(
:ci_pipeline_schedule_variable
,
key:
'AAA'
,
value:
'AAA123'
,
pipeline_schedule:
pipeline_schedule
)
create
(
:ci_pipeline_schedule_variable
,
key:
'AAA'
,
value:
'AAA123'
,
pipeline_schedule:
pipeline_schedule
)
end
end
visit_pipelines_schedules
visit_pipelines_schedules
...
@@ -171,26 +166,30 @@ feature 'Pipeline Schedules', :feature, js: true do
...
@@ -171,26 +166,30 @@ feature 'Pipeline Schedules', :feature, js: true do
scenario
'user sees the updated variable in edit window'
do
scenario
'user sees the updated variable in edit window'
do
find
(
".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']"
).
click
find
(
".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']"
).
click
expect
(
find
(
".pipeline-variable-list .pipeline-variable-row:nth-child(1) .pipeline-variable-key-input"
).
value
).
to
eq
(
'foo'
)
page
.
within
(
'.pipeline-variable-list'
)
do
expect
(
find
(
".pipeline-variable-list .pipeline-variable-row:nth-child(1) .pipeline-variable-value-input"
).
value
).
to
eq
(
'bar'
)
expect
(
find
(
".pipeline-variable-row:nth-child(1) .pipeline-variable-key-input"
).
value
).
to
eq
(
'foo'
)
expect
(
find
(
".pipeline-variable-row:nth-child(1) .pipeline-variable-value-input"
).
value
).
to
eq
(
'bar'
)
end
end
end
end
end
context
'when user removes a variable of a pipeline schedule'
do
context
'when user removes a variable of a pipeline schedule'
do
background
do
background
do
create
(
:ci_pipeline_schedule
,
owner:
user
).
tap
do
|
pipeline_schedule
|
create
(
:ci_pipeline_schedule
,
project:
project
,
owner:
user
).
tap
do
|
pipeline_schedule
|
create
(
:ci_pipeline_schedule_variable
,
key:
'AAA'
,
value:
'AAA123'
,
pipeline_schedule:
pipeline_schedule
)
create
(
:ci_pipeline_schedule_variable
,
key:
'AAA'
,
value:
'AAA123'
,
pipeline_schedule:
pipeline_schedule
)
end
end
visit_pipelines_schedules
visit_pipelines_schedules
find
(
".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']"
).
click
find
(
".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']"
).
click
fi
rst
(
'.pipeline-variable-list .pipeline-variable-row-remove-button'
).
click
fi
nd
(
'.pipeline-variable-list .pipeline-variable-row-remove-button'
).
click
click_button
'Save pipeline schedule'
click_button
'Save pipeline schedule'
end
end
scenario
'user does not see the removed variable in edit window'
do
scenario
'user does not see the removed variable in edit window'
do
find
(
".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']"
).
click
find
(
".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']"
).
click
expect
(
find
(
".pipeline-variable-list .pipeline-variable-row:nth-child(1) .pipeline-variable-key-input"
).
value
).
to
eq
(
''
)
page
.
within
(
'.pipeline-variable-list'
)
do
expect
(
find
(
".pipeline-variable-list .pipeline-variable-row:nth-child(1) .pipeline-variable-value-input"
).
value
).
to
eq
(
''
)
expect
(
find
(
".pipeline-variable-row:nth-child(1) .pipeline-variable-key-input"
).
value
).
to
eq
(
''
)
expect
(
find
(
".pipeline-variable-row:nth-child(1) .pipeline-variable-value-input"
).
value
).
to
eq
(
''
)
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment