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
alias_method :build, :object
def playable?
can?(request.user, :play_build, build) && build.playable?
build.playable? && can?(request.user, :play_build, build)
end
end
......@@ -12,7 +12,7 @@ class BuildEntity < Grape::Entity
path_to(:retry_namespace_project_build, build)
end
expose :play_path, if: proc { playable? } do |build|
expose :play_path, if: -> (*) { playable? } do |build|
path_to(:play_namespace_project_build, build)
end
......@@ -26,7 +26,7 @@ class BuildEntity < Grape::Entity
alias_method :build, :object
def playable?
can?(request.user, :play_build, build) && build.playable?
build.playable? && can?(request.user, :play_build, build)
end
def detailed_status
......
......@@ -48,15 +48,15 @@ class PipelineEntity < Grape::Entity
end
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,
pipeline.project,
pipeline.id)
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,
pipeline.project,
pipeline.id)
......
......@@ -5,7 +5,7 @@ module Ci
raise Gitlab::Access::AccessDeniedError
end
# Try to enqueue thebuild, otherwise create a duplicate.
# Try to enqueue the build, otherwise create a duplicate.
#
if build.enqueue
build.tap { |action| action.update(user: current_user) }
......
......@@ -260,10 +260,8 @@ describe Projects::BuildsController do
end
describe 'POST play' do
let(:project) { create(:project, :public) }
before do
project.add_developer(user)
project.add_master(user)
sign_in(user)
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