Commit 72307940 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve code style related to protected actions

parent 738bf2c2
...@@ -19,6 +19,6 @@ class BuildActionEntity < Grape::Entity ...@@ -19,6 +19,6 @@ class BuildActionEntity < Grape::Entity
alias_method :build, :object alias_method :build, :object
def playable? def playable?
can?(request.user, :play_build, build) && build.playable? build.playable? && can?(request.user, :play_build, build)
end end
end end
...@@ -12,7 +12,7 @@ class BuildEntity < Grape::Entity ...@@ -12,7 +12,7 @@ class BuildEntity < Grape::Entity
path_to(:retry_namespace_project_build, build) path_to(:retry_namespace_project_build, build)
end end
expose :play_path, if: proc { playable? } do |build| expose :play_path, if: -> (*) { playable? } do |build|
path_to(:play_namespace_project_build, build) path_to(:play_namespace_project_build, build)
end end
...@@ -26,7 +26,7 @@ class BuildEntity < Grape::Entity ...@@ -26,7 +26,7 @@ class BuildEntity < Grape::Entity
alias_method :build, :object alias_method :build, :object
def playable? def playable?
can?(request.user, :play_build, build) && build.playable? build.playable? && can?(request.user, :play_build, build)
end end
def detailed_status def detailed_status
......
...@@ -48,15 +48,15 @@ class PipelineEntity < Grape::Entity ...@@ -48,15 +48,15 @@ class PipelineEntity < Grape::Entity
end end
expose :commit, using: CommitEntity expose :commit, using: CommitEntity
expose :yaml_errors, if: ->(pipeline, _) { pipeline.has_yaml_errors? } expose :yaml_errors, if: -> (pipeline, _) { pipeline.has_yaml_errors? }
expose :retry_path, if: proc { can_retry? } do |pipeline| expose :retry_path, if: -> (*) { can_retry? } do |pipeline|
retry_namespace_project_pipeline_path(pipeline.project.namespace, retry_namespace_project_pipeline_path(pipeline.project.namespace,
pipeline.project, pipeline.project,
pipeline.id) pipeline.id)
end end
expose :cancel_path, if: proc { can_cancel? } do |pipeline| expose :cancel_path, if: -> (*) { can_cancel? } do |pipeline|
cancel_namespace_project_pipeline_path(pipeline.project.namespace, cancel_namespace_project_pipeline_path(pipeline.project.namespace,
pipeline.project, pipeline.project,
pipeline.id) pipeline.id)
......
...@@ -5,7 +5,7 @@ module Ci ...@@ -5,7 +5,7 @@ module Ci
raise Gitlab::Access::AccessDeniedError raise Gitlab::Access::AccessDeniedError
end end
# Try to enqueue thebuild, otherwise create a duplicate. # Try to enqueue the build, otherwise create a duplicate.
# #
if build.enqueue if build.enqueue
build.tap { |action| action.update(user: current_user) } build.tap { |action| action.update(user: current_user) }
......
...@@ -260,10 +260,8 @@ describe Projects::BuildsController do ...@@ -260,10 +260,8 @@ describe Projects::BuildsController do
end end
describe 'POST play' do describe 'POST play' do
let(:project) { create(:project, :public) }
before do before do
project.add_developer(user) project.add_master(user)
sign_in(user) sign_in(user)
post_play post_play
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment