diff --git a/Gemfile.lock b/Gemfile.lock index 2b07671..7b38f6d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - croods (0.3.2) + croods (0.3.3) api-pagination (= 4.8.2) committee (= 3.3.0) devise_token_auth (= 1.1.3) diff --git a/lib/croods/controller/member.rb b/lib/croods/controller/member.rb index fb3acc0..784e3f7 100644 --- a/lib/croods/controller/member.rb +++ b/lib/croods/controller/member.rb @@ -23,7 +23,7 @@ def identifier params[resource.identifier] end - def member_params + def member_params # rubocop:disable Metrics/AbcSize params .permit(resource.request_attributes.keys) .merge( @@ -31,6 +31,8 @@ def member_params .require(resource.resource_name) .permit! ) + rescue StandardError + params.permit(resource.request_attributes.keys) end def new_member diff --git a/spec/todos/tasks/update_spec.rb b/spec/todos/tasks/update_spec.rb index 9dc6582..8a14a6f 100644 --- a/spec/todos/tasks/update_spec.rb +++ b/spec/todos/tasks/update_spec.rb @@ -231,6 +231,17 @@ it { is_expected.to have_http_status(:ok) } end + context 'when we add an attribute that does not exist in the model' do + let(:params) { { foobaz: 'foobar' } } + + before do + put "/tasks/#{task.id}", params: params.to_json + end + + it { is_expected.to have_http_status(:ok) } + # it { expect(response.body).to eq_json(error) } + end + context 'when task is from another organization' do let(:id) { another_user_task.id } diff --git a/todos/app/resources/tasks/resource.rb b/todos/app/resources/tasks/resource.rb index de47d28..5c62d83 100644 --- a/todos/app/resources/tasks/resource.rb +++ b/todos/app/resources/tasks/resource.rb @@ -7,6 +7,7 @@ class Resource < ApplicationResource request do skip_attribute :finished + add_attribute :foobaz, :string, null: true end add_action :finish, method: :put do diff --git a/todos/app/resources/tasks/update.rb b/todos/app/resources/tasks/update.rb index b061696..71aedc6 100644 --- a/todos/app/resources/tasks/update.rb +++ b/todos/app/resources/tasks/update.rb @@ -5,6 +5,7 @@ class Update < Croods::Service about :task def execute + params.delete(:foobaz) task.update!(params) task.list.update!(