Commit c17f8a2f authored by Etienne Baqué's avatar Etienne Baqué

Merge branch 'upgrade-grape-entity' into 'master'

Upgrade grape-entity gem

See merge request gitlab-org/gitlab!61866
parents df28ca91 79d05070
...@@ -92,7 +92,7 @@ gem 'net-ldap', '~> 0.16.3' ...@@ -92,7 +92,7 @@ gem 'net-ldap', '~> 0.16.3'
# API # API
gem 'grape', '~> 1.5.2' gem 'grape', '~> 1.5.2'
gem 'grape-entity', '~> 0.7.1' gem 'grape-entity', '~> 0.9.0'
gem 'rack-cors', '~> 1.0.6', require: 'rack/cors' gem 'rack-cors', '~> 1.0.6', require: 'rack/cors'
# GraphQL API # GraphQL API
......
...@@ -538,8 +538,8 @@ GEM ...@@ -538,8 +538,8 @@ GEM
mustermann-grape (~> 1.0.0) mustermann-grape (~> 1.0.0)
rack (>= 1.3.0) rack (>= 1.3.0)
rack-accept rack-accept
grape-entity (0.7.1) grape-entity (0.9.0)
activesupport (>= 4.0) activesupport (>= 3.0.0)
multi_json (>= 1.3.2) multi_json (>= 1.3.2)
grape-path-helpers (1.6.3) grape-path-helpers (1.6.3)
activesupport activesupport
...@@ -1471,7 +1471,7 @@ DEPENDENCIES ...@@ -1471,7 +1471,7 @@ DEPENDENCIES
google-protobuf (~> 3.15.8) google-protobuf (~> 3.15.8)
gpgme (~> 2.0.19) gpgme (~> 2.0.19)
grape (~> 1.5.2) grape (~> 1.5.2)
grape-entity (~> 0.7.1) grape-entity (~> 0.9.0)
grape-path-helpers (~> 1.6.3) grape-path-helpers (~> 1.6.3)
grape_logging (~> 1.7) grape_logging (~> 1.7)
graphiql-rails (~> 1.4.10) graphiql-rails (~> 1.4.10)
......
...@@ -38,7 +38,7 @@ class DeploymentEntity < Grape::Entity ...@@ -38,7 +38,7 @@ class DeploymentEntity < Grape::Entity
expose :commit, using: CommitEntity, if: -> (*) { include_details? } expose :commit, using: CommitEntity, if: -> (*) { include_details? }
expose :manual_actions, using: JobEntity, if: -> (*) { include_details? && can_create_deployment? } expose :manual_actions, using: JobEntity, if: -> (*) { include_details? && can_create_deployment? }
expose :scheduled_actions, using: JobEntity, if: -> (*) { include_details? && can_create_deployment? } expose :scheduled_actions, using: JobEntity, if: -> (*) { include_details? && can_create_deployment? }
expose :playable_build, expose_nil: false, if: -> (*) { include_details? && can_create_deployment? } do |deployment, options| expose :playable_build, if: -> (deployment) { include_details? && can_create_deployment? && deployment.playable_build } do |deployment, options|
JobEntity.represent(deployment.playable_build, options.merge(only: [:play_path, :retry_path])) JobEntity.represent(deployment.playable_build, options.merge(only: [:play_path, :retry_path]))
end end
......
...@@ -21,7 +21,7 @@ class EnvironmentEntity < Grape::Entity ...@@ -21,7 +21,7 @@ class EnvironmentEntity < Grape::Entity
expose :stop_action_available?, as: :has_stop_action expose :stop_action_available?, as: :has_stop_action
expose :rollout_status, if: -> (*) { can_read_deploy_board? }, using: RolloutStatusEntity expose :rollout_status, if: -> (*) { can_read_deploy_board? }, using: RolloutStatusEntity
expose :upcoming_deployment, expose_nil: false do |environment, ops| expose :upcoming_deployment, if: -> (environment) { environment.upcoming_deployment } do |environment, ops|
DeploymentEntity.represent(environment.upcoming_deployment, DeploymentEntity.represent(environment.upcoming_deployment,
ops.merge(except: UNNECESSARY_ENTRIES_FOR_UPCOMING_DEPLOYMENT)) ops.merge(except: UNNECESSARY_ENTRIES_FOR_UPCOMING_DEPLOYMENT))
end end
......
...@@ -20,7 +20,7 @@ class IssueBoardEntity < Grape::Entity ...@@ -20,7 +20,7 @@ class IssueBoardEntity < Grape::Entity
API::Entities::Project.represent issue.project, only: [:id, :path] API::Entities::Project.represent issue.project, only: [:id, :path]
end end
expose :milestone, expose_nil: false do |issue| expose :milestone, if: -> (issue) { issue.milestone } do |issue|
API::Entities::Milestone.represent issue.milestone, only: [:id, :title] API::Entities::Milestone.represent issue.milestone, only: [:id, :title]
end end
......
...@@ -11,13 +11,13 @@ class DashboardEnvironmentEntity < Grape::Entity ...@@ -11,13 +11,13 @@ class DashboardEnvironmentEntity < Grape::Entity
expose :external_url expose :external_url
expose :last_visible_deployment, as: :last_deployment, expose_nil: false do |environment| expose :last_visible_deployment, as: :last_deployment, if: ->(environment) { environment.last_visible_deployment } do |environment|
DeploymentEntity.represent(environment.last_visible_deployment, DeploymentEntity.represent(environment.last_visible_deployment,
options.merge(request: request_with_project, options.merge(request: request_with_project,
except: unnecessary_deployment_fields)) except: unnecessary_deployment_fields))
end end
expose :last_visible_pipeline, as: :last_pipeline, expose_nil: false do |environment| expose :last_visible_pipeline, as: :last_pipeline, if: ->(environment) { environment.last_visible_pipeline } do |environment|
PipelineDetailsEntity.represent(environment.last_visible_pipeline, PipelineDetailsEntity.represent(environment.last_visible_pipeline,
options.merge(request: request_with_project, options.merge(request: request_with_project,
only: required_pipeline_fields)) only: required_pipeline_fields))
......
...@@ -239,23 +239,23 @@ RSpec.describe Ci::PipelineEntity do ...@@ -239,23 +239,23 @@ RSpec.describe Ci::PipelineEntity do
end end
context 'when pipeline has failed builds' do context 'when pipeline has failed builds' do
let_it_be(:pipeline) { create(:ci_pipeline, user: user) } let_it_be(:pipeline) { create(:ci_pipeline, project: project, user: user) }
let_it_be(:build) { create(:ci_build, :success, pipeline: pipeline) } let_it_be(:build) { create(:ci_build, :success, pipeline: pipeline) }
let_it_be(:failed_1) { create(:ci_build, :failed, pipeline: pipeline) } let_it_be(:failed_1) { create(:ci_build, :failed, pipeline: pipeline) }
let_it_be(:failed_2) { create(:ci_build, :failed, pipeline: pipeline) } let_it_be(:failed_2) { create(:ci_build, :failed, pipeline: pipeline) }
context 'when the user can retry the pipeline' do context 'when the user can retry the pipeline' do
it 'exposes these failed builds' do before do
allow(entity).to receive(:can_retry?).and_return(true) project.add_maintainer(user)
end
it 'exposes these failed builds' do
expect(subject[:failed_builds].map { |b| b[:id] }).to contain_exactly(failed_1.id, failed_2.id) expect(subject[:failed_builds].map { |b| b[:id] }).to contain_exactly(failed_1.id, failed_2.id)
end end
end end
context 'when the user cannot retry the pipeline' do context 'when the user cannot retry the pipeline' do
it 'is nil' do it 'is nil' do
allow(entity).to receive(:can_retry?).and_return(false)
expect(subject[:failed_builds]).to be_nil expect(subject[:failed_builds]).to be_nil
end end
end end
......
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