From e2073f9726b8d8a5988be46d74bf4b30bca8fd9e Mon Sep 17 00:00:00 2001 From: MisterOryon Date: Thu, 2 Jan 2025 13:03:11 +0100 Subject: [PATCH] feat: add request_distribution_ids to Bench API response This update includes request_distribution_ids in the Bench API response, allowing clients to access associated request distribution IDs. Test coverage has been added to verify the presence and correctness of this new data field. --- app/blueprinter/bench_blueprint.rb | 4 ++++ spec/acceptance/api/v1/benches_controller_spec.rb | 3 +++ 2 files changed, 7 insertions(+) diff --git a/app/blueprinter/bench_blueprint.rb b/app/blueprinter/bench_blueprint.rb index 4270b6d..255de0a 100644 --- a/app/blueprinter/bench_blueprint.rb +++ b/app/blueprinter/bench_blueprint.rb @@ -3,4 +3,8 @@ class BenchBlueprint < Base # Fields fields :name, :dimensions, :positions, :greenhouse_id + + field :request_distribution_ids do |bench| + bench.request_distributions.pluck(:id) + end end diff --git a/spec/acceptance/api/v1/benches_controller_spec.rb b/spec/acceptance/api/v1/benches_controller_spec.rb index 20b7247..8c8f8d4 100644 --- a/spec/acceptance/api/v1/benches_controller_spec.rb +++ b/spec/acceptance/api/v1/benches_controller_spec.rb @@ -16,6 +16,8 @@ let!(:bench) { greenhouse.benches.first } let!(:id) { bench.id } + let!(:request_distribution_ids) { bench.request_distributions.pluck(:id) } + get '/api/v1/greenhouses/:greenhouse_id/benches' do parameter :'page[number]', "The number of the desired page\n\n" \ "If used, additional information is returned in the response headers:\n" \ @@ -88,6 +90,7 @@ expect(response['dimensions']).to eq(dimensions) expect(response['positions']).to eq(positions) expect(response['greenhouse_id']).to eq(greenhouse_id) + expect(response['request_distribution_ids'].count).to eq(0) end end