BigW Consortium Gitlab

Commit 16cca3a0 by 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 {
const parsedAction = {
name: gl.text.humanize(action.name),
play_path: action.play_path,
playable: action.playable,
};
return parsedAction;
});
......
......@@ -11,4 +11,6 @@ class BuildActionEntity < Grape::Entity
build.project,
build)
end
expose :playable?, as: :playable
end
......@@ -16,6 +16,7 @@ class BuildEntity < Grape::Entity
path_to(:play_namespace_project_build, build)
end
expose :playable?, as: :playable
expose :created_at
expose :updated_at
......
......@@ -17,5 +17,9 @@ describe BuildActionEntity do
it 'contains path to the action play' do
expect(subject[:path]).to include "builds/#{build.id}/play"
end
it 'contains whether it is playable' do
expect(subject[:playable]).to eq build.playable?
end
end
end
......@@ -18,6 +18,10 @@ describe BuildEntity do
expect(subject).not_to include(/variables/)
end
it 'contains whether it is playable' do
expect(subject[:playable]).to eq build.playable?
end
it 'contains timestamps' do
expect(subject).to include(:created_at, :updated_at)
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