Commit 16cca3a0 authored by Toon Claes's avatar Toon Claes

Expose if action is playable in JSON

To avoid a manual build action being played (resulting in a 404),
expose `playable?` in the JSON so the frontend can disable/hide the
play button if it's not playable.
parent 7a623907
...@@ -141,6 +141,7 @@ export default { ...@@ -141,6 +141,7 @@ export default {
const parsedAction = { const parsedAction = {
name: gl.text.humanize(action.name), name: gl.text.humanize(action.name),
play_path: action.play_path, play_path: action.play_path,
playable: action.playable,
}; };
return parsedAction; return parsedAction;
}); });
......
...@@ -11,4 +11,6 @@ class BuildActionEntity < Grape::Entity ...@@ -11,4 +11,6 @@ class BuildActionEntity < Grape::Entity
build.project, build.project,
build) build)
end end
expose :playable?, as: :playable
end end
...@@ -16,6 +16,7 @@ class BuildEntity < Grape::Entity ...@@ -16,6 +16,7 @@ class BuildEntity < Grape::Entity
path_to(:play_namespace_project_build, build) path_to(:play_namespace_project_build, build)
end end
expose :playable?, as: :playable
expose :created_at expose :created_at
expose :updated_at expose :updated_at
......
...@@ -17,5 +17,9 @@ describe BuildActionEntity do ...@@ -17,5 +17,9 @@ describe BuildActionEntity do
it 'contains path to the action play' do it 'contains path to the action play' do
expect(subject[:path]).to include "builds/#{build.id}/play" expect(subject[:path]).to include "builds/#{build.id}/play"
end end
it 'contains whether it is playable' do
expect(subject[:playable]).to eq build.playable?
end
end end
end end
...@@ -18,6 +18,10 @@ describe BuildEntity do ...@@ -18,6 +18,10 @@ describe BuildEntity do
expect(subject).not_to include(/variables/) expect(subject).not_to include(/variables/)
end end
it 'contains whether it is playable' do
expect(subject[:playable]).to eq build.playable?
end
it 'contains timestamps' do it 'contains timestamps' do
expect(subject).to include(:created_at, :updated_at) expect(subject).to include(:created_at, :updated_at)
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