Commit 6059e912 authored by Andrew Fontaine's avatar Andrew Fontaine

Add alias for last? parameter on environments page

'last?', while usuable as a key in javascript, does not conform to the
rest of the language very well. 'is_last', on the other hand, is more
expected.
parent 749370c5
......@@ -22,6 +22,8 @@ class DeploymentEntity < Grape::Entity
expose :deployed_at
expose :tag
expose :last?
expose :last?, as: :is_last
expose :deployed_by, as: :user, using: UserEntity
expose :deployable, if: -> (deployment) { deployment.deployable.present? } do |deployment, opts|
......
......@@ -4,7 +4,7 @@ class DeploymentSerializer < BaseSerializer
entity DeploymentEntity
def represent_concise(resource, opts = {})
opts[:only] = [:iid, :id, :sha, :created_at, :deployed_at, :tag, :last?, :id, ref: [:name]]
opts[:only] = [:iid, :id, :sha, :created_at, :deployed_at, :tag, :last?, :is_last, :id, ref: [:name]]
represent(resource, opts)
end
end
......@@ -7,6 +7,7 @@
"iid",
"tag",
"last?",
"is_last",
"ref",
"id"
],
......@@ -16,6 +17,7 @@
"id": { "type": "integer" },
"iid": { "type": "integer" },
"last?": { "type": "boolean" },
"is_last": { "type": "boolean" },
"ref": {
"type": "object",
"required": [
......
......@@ -42,6 +42,10 @@ RSpec.describe DeploymentEntity do
expect(subject).to include(:deployed_at)
end
it 'exposes last? as is_last' do
expect(subject).to include(:is_last)
end
context 'when deployable is nil' do
let(:entity) { described_class.new(deployment, request: request, deployment_details: false) }
let(:deployment) { create(:deployment, deployable: nil, project: project) }
......
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