From df1f9262bcd50512d25c0b29c5b5c7ba0a5735e1 Mon Sep 17 00:00:00 2001 From: Zach Wolfenbarger Date: Fri, 14 Jun 2024 20:11:49 -0500 Subject: [PATCH] AggClient already returns the parsed response body (#4348) * AggClient already returns the parsed response body * and the spec fix --- app/controllers/api/v1/aggregations_controller.rb | 2 +- spec/controllers/api/v1/aggregations_controller_spec.rb | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/aggregations_controller.rb b/app/controllers/api/v1/aggregations_controller.rb index 9a52a4331..f47d3b089 100644 --- a/app/controllers/api/v1/aggregations_controller.rb +++ b/app/controllers/api/v1/aggregations_controller.rb @@ -17,7 +17,7 @@ def create create_params['links']['user'] ) super do |agg| - agg.update({ task_id: response.body[:task_id], status: 'pending' }) + agg.update({ task_id: response[:task_id], status: 'pending' }) end rescue AggregationClient::ConnectionError json_api_render(:service_unavailable, 'The aggregation service is unavailable or not responding') diff --git a/spec/controllers/api/v1/aggregations_controller_spec.rb b/spec/controllers/api/v1/aggregations_controller_spec.rb index 71a494dfe..cd4623e8f 100644 --- a/spec/controllers/api/v1/aggregations_controller_spec.rb +++ b/spec/controllers/api/v1/aggregations_controller_spec.rb @@ -31,7 +31,7 @@ describe 'create' do let(:test_attr) { :workflow_id } let(:test_attr_value) { workflow.id } - let(:fake_response) { double } + let(:fake_response) { { 'task_id': 'asdf-1234-asdf' } } let(:mock_agg) { instance_double(AggregationClient) } let(:create_params) do @@ -48,7 +48,6 @@ before do allow(AggregationClient).to receive(:new).and_return(mock_agg) - allow(fake_response).to receive(:body).and_return({ 'task_id': 'asdf-1234-asdf' }) allow(mock_agg).to receive(:send_aggregation_request).and_return(fake_response) default_request scopes: scopes, user_id: authorized_user.id end