diff --git a/lib/graphiti/resource_proxy.rb b/lib/graphiti/resource_proxy.rb index ba69f4c0..0fc6e45a 100644 --- a/lib/graphiti/resource_proxy.rb +++ b/lib/graphiti/resource_proxy.rb @@ -118,6 +118,7 @@ def save(action: :create) end def destroy + data transaction_response = @resource.transaction do metadata = {method: :destroy} model = @resource.destroy(@query.filters[:id], metadata) @@ -135,6 +136,7 @@ def destroy end def update_attributes + data save(action: :update) end diff --git a/lib/graphiti/version.rb b/lib/graphiti/version.rb index 6ee5b3ac..69667898 100644 --- a/lib/graphiti/version.rb +++ b/lib/graphiti/version.rb @@ -1,3 +1,3 @@ module Graphiti - VERSION = "1.2.21" + VERSION = "1.2.22" end diff --git a/spec/persistence_spec.rb b/spec/persistence_spec.rb index 45005865..32723e46 100644 --- a/spec/persistence_spec.rb +++ b/spec/persistence_spec.rb @@ -32,6 +32,40 @@ def self.name expect(employee.data.first_name).to eq("Jane") end + describe 'updating' do + let!(:employee) { PORO::Employee.create(first_name: 'asdf') } + + before do + payload[:data][:id] = employee.id.to_s + end + + describe 'with scope override' do + it 'is honored' do + employee = klass.find(payload, { type: 'foo' }) + expect { + employee.update_attributes + }.to raise_error(Graphiti::Errors::RecordNotFound) + end + end + end + + describe 'destroying' do + let!(:employee) { PORO::Employee.create(first_name: 'asdf') } + + before do + payload[:data][:id] = employee.id.to_s + end + + describe 'with scope override' do + it 'is honored' do + employee = klass.find(payload, { type: 'foo' }) + expect { + employee.destroy + }.to raise_error(Graphiti::Errors::RecordNotFound) + end + end + end + describe "overrides" do before do klass.class_eval do