summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-03 12:32:39 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-03 12:32:39 +0200
commit72307940bb04d29dc751adb5e76330d2ce45e9ce (patch)
treee7a3441115e60118d428999aed6164b782a213a3
parent738bf2c23891467dbc9c74d08223fd3c4e432ae7 (diff)
downloadgitlab-ce-72307940bb04d29dc751adb5e76330d2ce45e9ce.tar.gz
Improve code style related to protected actions
-rw-r--r--app/serializers/build_action_entity.rb2
-rw-r--r--app/serializers/build_entity.rb4
-rw-r--r--app/serializers/pipeline_entity.rb6
-rw-r--r--app/services/ci/play_build_service.rb2
-rw-r--r--spec/controllers/projects/builds_controller_spec.rb4
5 files changed, 8 insertions, 10 deletions
diff --git a/app/serializers/build_action_entity.rb b/app/serializers/build_action_entity.rb
index 0bb7e561073..3eff724ae91 100644
--- a/app/serializers/build_action_entity.rb
+++ b/app/serializers/build_action_entity.rb
@@ -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
diff --git a/app/serializers/build_entity.rb b/app/serializers/build_entity.rb
index f301900c43c..10ba7c90c10 100644
--- a/app/serializers/build_entity.rb
+++ b/app/serializers/build_entity.rb
@@ -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
diff --git a/app/serializers/pipeline_entity.rb b/app/serializers/pipeline_entity.rb
index ad8b4d43e8f..7eb7aac72eb 100644
--- a/app/serializers/pipeline_entity.rb
+++ b/app/serializers/pipeline_entity.rb
@@ -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)
diff --git a/app/services/ci/play_build_service.rb b/app/services/ci/play_build_service.rb
index c9ed45408f2..5b3ff1ced38 100644
--- a/app/services/ci/play_build_service.rb
+++ b/app/services/ci/play_build_service.rb
@@ -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) }
diff --git a/spec/controllers/projects/builds_controller_spec.rb b/spec/controllers/projects/builds_controller_spec.rb
index 3bf03c88ff5..3ce23c17cdc 100644
--- a/spec/controllers/projects/builds_controller_spec.rb
+++ b/spec/controllers/projects/builds_controller_spec.rb
@@ -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