active_remote 5.1.0 → 5.1.1
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d01c0d9e90a995d69eca7eb4fc5778033dc78b6c2a1a2ed1472f828833d1ffb
|
4
|
+
data.tar.gz: 3304e91fb6c6dbf24955f5f84bccf1f19e4fb2f9a9a16a8a58c0dc41416f9e18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ac0f959ee3b70f396917d360c8b1c28c663530dc0b4d1f8b890ce277e401663208a80da549917f204a7a6f628b60cdb8e278d348f884b33d87ea5bc17503e56
|
7
|
+
data.tar.gz: d5db551ce3a30686ebe5bc529e2511a8e1b20b669d7ffd2b4b666f24d94bcbfec3b06cbda7787f03f469d5c87ffc7f7ce53b100f401795aea5f18cfa450d5850
|
data/lib/active_remote/errors.rb
CHANGED
@@ -43,6 +43,16 @@ module ActiveRemote
|
|
43
43
|
# Raised by ActiveRemove::Base.save! and ActiveRemote::Base.create! methods
|
44
44
|
# when remote record cannot be saved because it is invalid.
|
45
45
|
class RemoteRecordNotSaved < ActiveRemoteError
|
46
|
+
attr_reader :record
|
47
|
+
|
48
|
+
def initialize(message_or_record = nil)
|
49
|
+
message = message_or_record
|
50
|
+
if message_or_record.is_a?(::ActiveRemote::Base)
|
51
|
+
@record = message_or_record
|
52
|
+
message = @record.errors.full_messages.join(", ")
|
53
|
+
end
|
54
|
+
super(message)
|
55
|
+
end
|
46
56
|
end
|
47
57
|
|
48
58
|
class UnknownAttributeError < ActiveRemoteError
|
@@ -198,7 +198,7 @@ module ActiveRemote
|
|
198
198
|
# Also runs any before/after save callbacks that are defined.
|
199
199
|
#
|
200
200
|
def save!(*args)
|
201
|
-
save(*args) ||
|
201
|
+
save(*args) || fail(RemoteRecordNotSaved, self)
|
202
202
|
end
|
203
203
|
|
204
204
|
# Returns true if the record doesn't have errors; otherwise, returns false.
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ::ActiveRemote::RemoteRecordNotSaved do
|
4
|
+
let(:record) { ::Tag.new }
|
5
|
+
|
6
|
+
before do
|
7
|
+
record.errors[:base] << "Some error one!"
|
8
|
+
record.errors[:base] << "Some error two!"
|
9
|
+
end
|
10
|
+
|
11
|
+
context "when an active remote record is used" do
|
12
|
+
it "uses embedded errors in message" do
|
13
|
+
expect { fail(::ActiveRemote::RemoteRecordNotSaved, record) }
|
14
|
+
.to raise_error(ActiveRemote::RemoteRecordNotSaved, "Some error one!, Some error two!")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when a string is used" do
|
19
|
+
it "uses the string in the error message" do
|
20
|
+
expect { fail(::ActiveRemote::RemoteRecordNotSaved, "something bad happened") }
|
21
|
+
.to raise_error(ActiveRemote::RemoteRecordNotSaved, "something bad happened")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when no message is used" do
|
26
|
+
it "raises the error" do
|
27
|
+
expect { raise(::ActiveRemote::RemoteRecordNotSaved) }
|
28
|
+
.to raise_error(ActiveRemote::RemoteRecordNotSaved)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -314,9 +314,16 @@ describe ::ActiveRemote::Persistence do
|
|
314
314
|
end
|
315
315
|
|
316
316
|
context "when the record is not saved" do
|
317
|
+
let(:errors) {
|
318
|
+
[Generic::Error.new(:field => "name", :message => "Error one!"),
|
319
|
+
Generic::Error.new(:field => "name", :message => "Error two!")]
|
320
|
+
}
|
321
|
+
let(:response) { Generic::Remote::Tag.new(:errors => errors) }
|
322
|
+
before { allow(rpc).to receive(:execute).and_return(response) }
|
323
|
+
|
317
324
|
it "raises an exception" do
|
318
|
-
|
319
|
-
|
325
|
+
expect { subject.save! }
|
326
|
+
.to raise_error(ActiveRemote::RemoteRecordNotSaved, "Name Error one!, Name Error two!")
|
320
327
|
end
|
321
328
|
end
|
322
329
|
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: 5.1.
|
4
|
+
version: 5.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Hutchison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- spec/lib/active_remote/base_spec.rb
|
229
229
|
- spec/lib/active_remote/dirty_spec.rb
|
230
230
|
- spec/lib/active_remote/dsl_spec.rb
|
231
|
+
- spec/lib/active_remote/errors_spec.rb
|
231
232
|
- spec/lib/active_remote/integration_spec.rb
|
232
233
|
- spec/lib/active_remote/persistence_spec.rb
|
233
234
|
- spec/lib/active_remote/primary_key_spec.rb
|
@@ -281,7 +282,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
281
282
|
- !ruby/object:Gem::Version
|
282
283
|
version: '0'
|
283
284
|
requirements: []
|
284
|
-
|
285
|
+
rubyforge_project:
|
286
|
+
rubygems_version: 2.7.6
|
285
287
|
signing_key:
|
286
288
|
specification_version: 4
|
287
289
|
summary: Active Record for your platform
|
@@ -291,6 +293,7 @@ test_files:
|
|
291
293
|
- spec/lib/active_remote/base_spec.rb
|
292
294
|
- spec/lib/active_remote/dirty_spec.rb
|
293
295
|
- spec/lib/active_remote/dsl_spec.rb
|
296
|
+
- spec/lib/active_remote/errors_spec.rb
|
294
297
|
- spec/lib/active_remote/integration_spec.rb
|
295
298
|
- spec/lib/active_remote/persistence_spec.rb
|
296
299
|
- spec/lib/active_remote/primary_key_spec.rb
|