From 57716fd89c85a25fe6494cffc81fb1173f40b8df Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Tue, 15 Sep 2020 11:19:25 +0200 Subject: [PATCH] Fix API and tests for new task completion logic [SCI-5004] --- app/controllers/api/v1/tasks_controller.rb | 4 ++-- spec/requests/api/v1/tasks_controller_spec.rb | 19 +++---------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/app/controllers/api/v1/tasks_controller.rb b/app/controllers/api/v1/tasks_controller.rb index b3b28bb85..635082f88 100644 --- a/app/controllers/api/v1/tasks_controller.rb +++ b/app/controllers/api/v1/tasks_controller.rb @@ -60,13 +60,13 @@ module Api def task_params_create raise TypeError unless params.require(:data).require(:type) == 'tasks' - params.require(:data).require(:attributes).permit(%i(name x y description state)) + params.require(:data).require(:attributes).permit(%i(name x y description)) end def task_params_update raise TypeError unless params.require(:data).require(:type) == 'tasks' - params.require(:data).require(:attributes).permit(%i(name x y description state my_module_status_id)) + params.require(:data).require(:attributes).permit(%i(name x y description my_module_status_id)) end def load_task_for_managing diff --git a/spec/requests/api/v1/tasks_controller_spec.rb b/spec/requests/api/v1/tasks_controller_spec.rb index 99dabb623..24ff8d712 100644 --- a/spec/requests/api/v1/tasks_controller_spec.rb +++ b/spec/requests/api/v1/tasks_controller_spec.rb @@ -292,7 +292,7 @@ RSpec.describe 'Api::V1::TasksController', type: :request do end end - context 'task completion, when has valid params' do + context 'direct task completion disabled, when has valid params' do let(:request_body) do { data: { @@ -304,23 +304,10 @@ RSpec.describe 'Api::V1::TasksController', type: :request do } end - it 'returns status 200' do + it 'returns status 204, no changes to task' do action - expect(response).to have_http_status 200 - end - - it 'returns well formated response' do - action - - expect(json).to match( - hash_including( - data: hash_including( - type: 'tasks', - attributes: hash_including(state: 'completed') - ) - ) - ) + expect(response).to have_http_status 204 end end