active_remote 2.1.0.rc1 → 2.1.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9db0dc04521916e66ca566f9ece9b5f0cc8e803e
4
- data.tar.gz: aea18e2d9200b988918570898a95fb0a47ed15aa
3
+ metadata.gz: 4ad2b0b5cc487a370172d15c33f1a09fdc81e676
4
+ data.tar.gz: 5f61ffc37e948bdb97ee80290c8f74c4193cdf35
5
5
  SHA512:
6
- metadata.gz: bead40af9673772592780b3a7b62252815fcd0805e2988a5d7d4b6f9d2a3eb32975e3fd2b50f1937096d32c1c053ae5ff8567959861f5c87aeac01cdd27b0b57
7
- data.tar.gz: 56d7903986b4bbb33a3c703a833441d44dd76210a560bb48c9e12d72ac9fff3da23276ba3958752d4b8a8b30507f0c44185c4a57fa289c3fbf89dc20698ce330
6
+ metadata.gz: 3447b324f221b6d18b1470ea1661222bc0afe04629ae6e6f137f5642c7f5ca7f2dac2f2f58825e1f698be6b721e025dd3780413fca8a75f1b0939ef9f6b7b61b
7
+ data.tar.gz: 17ba0f511feebdd491a69f54c0386fb1a919e91577b76a6ab3bee29d5c119c1ce0d0c18fb2059d4fe382cec63df670b605ccdc2cb4b9cee45e08425d2a7f1748
@@ -78,7 +78,7 @@ module ActiveRemote
78
78
  raise ReadOnlyRemoteRecord if readonly?
79
79
  response = rpc.execute(:delete, scope_key_hash)
80
80
 
81
- add_errors(response.errors)
81
+ add_errors_from_response(response)
82
82
 
83
83
  return success? ? freeze : false
84
84
  end
@@ -103,7 +103,7 @@ module ActiveRemote
103
103
  raise ReadOnlyRemoteRecord if readonly?
104
104
  response = rpc.execute(:destroy, scope_key_hash)
105
105
 
106
- add_errors(response.errors)
106
+ add_errors_from_response(response)
107
107
 
108
108
  return success? ? freeze : false
109
109
  end
@@ -234,7 +234,7 @@ module ActiveRemote
234
234
  response = rpc.execute(:create, new_attributes)
235
235
 
236
236
  assign_attributes(response.to_hash)
237
- add_errors(response.errors)
237
+ add_errors_from_response(response)
238
238
 
239
239
  @new_record = has_errors?
240
240
  success?
@@ -264,7 +264,7 @@ module ActiveRemote
264
264
  response = rpc.execute(:update, updated_attributes)
265
265
 
266
266
  assign_attributes(response.to_hash)
267
- add_errors(response.errors)
267
+ add_errors_from_response(response)
268
268
 
269
269
  success?
270
270
  end
@@ -22,8 +22,7 @@ module ActiveRemote
22
22
  end
23
23
  end
24
24
 
25
- # Examine the given response and add any errors to our internal errors
26
- # list.
25
+ # Add the given errors to our internal errors list
27
26
  #
28
27
  # ====Examples
29
28
  #
@@ -43,12 +42,20 @@ module ActiveRemote
43
42
  end
44
43
  end
45
44
 
46
- # DEPRECATED Use :add_errors instead
45
+ # Examine the given response and add any errors to our internal errors
46
+ # list.
47
+ #
48
+ # ====Examples
49
+ #
50
+ # response = remote_call(:action_that_returns_errors, { :stuff => 'foo' })
51
+ #
52
+ # add_errors_from_response(response)
47
53
  #
48
54
  def add_errors_from_response(response = nil)
49
- warn 'DEPRECATED Model#add_errors_from_response is deprecated and will be removed in Active Remote 3.0. Use Model#add_errors instead'
50
-
51
- response ||= last_response
55
+ unless response
56
+ warn 'DEPRECATED calling Model#add_errors_from_response without args is deprecated and will be removed in Active Remote 3.0.'
57
+ response = last_response
58
+ end
52
59
 
53
60
  add_errors(response.errors) if response.respond_to?(:errors)
54
61
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveRemote
2
- VERSION = "2.1.0.rc1"
2
+ VERSION = "2.1.0.rc2"
3
3
  end
@@ -30,4 +30,27 @@ describe ActiveRemote::Serialization do
30
30
  end
31
31
  end
32
32
  end
33
+
34
+ describe "#add_errors_from_response" do
35
+ subject { Tag.new }
36
+
37
+ context "when the response responds to :errors" do
38
+ let(:error) { Generic::Error.new(:field => 'name', :message => 'Boom!') }
39
+ let(:response) { Generic::Remote::Tag.new(:errors => [ error ]) }
40
+
41
+ it "adds errors to the active remote object" do
42
+ subject.better_receive(:add_errors).with(response.errors)
43
+ subject.add_errors_from_response(response)
44
+ end
45
+ end
46
+
47
+ context "when the response does not respond to :errors" do
48
+ let(:response_without_errors) { double(:response_without_errors) }
49
+
50
+ it "does not add errors" do
51
+ subject.better_not_receive(:add_errors)
52
+ subject.add_errors_from_response(response_without_errors)
53
+ end
54
+ end
55
+ end
33
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_remote
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.rc1
4
+ version: 2.1.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hutchison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-12 00:00:00.000000000 Z
11
+ date: 2014-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr