From 6acce3fc394f65bd002b727fb974bdd0788d6767 Mon Sep 17 00:00:00 2001 From: matthew-nichols Date: Mon, 26 Feb 2018 11:37:46 -0700 Subject: [PATCH] Allow primary_key to be set on create ActiveRecord allows the primary key to be set on create. This makes ActiveRemote#create behave the same way by allowing the primary_key attribute to be sent in a create operation. --- lib/active_remote/persistence.rb | 1 - spec/lib/active_remote/persistence_spec.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/active_remote/persistence.rb b/lib/active_remote/persistence.rb index 4d869df..8c0ffe1 100644 --- a/lib/active_remote/persistence.rb +++ b/lib/active_remote/persistence.rb @@ -238,7 +238,6 @@ def remote_create run_callbacks :create do # Use the getter here so we get the type casting. new_attributes = attributes - new_attributes.delete(primary_key.to_s) response = rpc.execute(:create, new_attributes) diff --git a/spec/lib/active_remote/persistence_spec.rb b/spec/lib/active_remote/persistence_spec.rb index 67c0183..c1c3674 100644 --- a/spec/lib/active_remote/persistence_spec.rb +++ b/spec/lib/active_remote/persistence_spec.rb @@ -208,7 +208,7 @@ subject { Tag.new } it "creates the record" do - expected_attributes = subject.attributes.reject { |key, value| key == "guid" } + expected_attributes = subject.attributes expect(rpc).to receive(:execute).with(:create, expected_attributes) subject.save end