active_remote 5.0.0 → 5.0.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: 13ac236138c203bfc5f5992a45160b4100090f1f75354eec968ae4ea9aa4b586
|
4
|
+
data.tar.gz: 372f5fd8259cc0d333f676949990f2d75ef412e47a1ec7fce6f86565ab3082c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62172bfc8d7eff79a0c69c5aed7a16bda69d5730e0085d16a569252018701fc863c7a65547f981efcd278dbf968ce1ed8ae81732c9bf308027842478c99bc413
|
7
|
+
data.tar.gz: 6851060fd28a08648c1c55c6e878af12b0509272a5d3690913a99b26808b67c885a10d614be7ce48c4d78a964584f967bd8748c899272316e95347364a11b565
|
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.0.
|
4
|
+
version: 5.0.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
|
@@ -234,6 +234,7 @@ files:
|
|
234
234
|
- spec/lib/active_remote/base_spec.rb
|
235
235
|
- spec/lib/active_remote/dirty_spec.rb
|
236
236
|
- spec/lib/active_remote/dsl_spec.rb
|
237
|
+
- spec/lib/active_remote/errors_spec.rb
|
237
238
|
- spec/lib/active_remote/integration_spec.rb
|
238
239
|
- spec/lib/active_remote/persistence_spec.rb
|
239
240
|
- spec/lib/active_remote/primary_key_spec.rb
|
@@ -287,7 +288,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
287
288
|
- !ruby/object:Gem::Version
|
288
289
|
version: '0'
|
289
290
|
requirements: []
|
290
|
-
|
291
|
+
rubyforge_project:
|
292
|
+
rubygems_version: 2.7.6
|
291
293
|
signing_key:
|
292
294
|
specification_version: 4
|
293
295
|
summary: Active Record for your platform
|
@@ -297,6 +299,7 @@ test_files:
|
|
297
299
|
- spec/lib/active_remote/base_spec.rb
|
298
300
|
- spec/lib/active_remote/dirty_spec.rb
|
299
301
|
- spec/lib/active_remote/dsl_spec.rb
|
302
|
+
- spec/lib/active_remote/errors_spec.rb
|
300
303
|
- spec/lib/active_remote/integration_spec.rb
|
301
304
|
- spec/lib/active_remote/persistence_spec.rb
|
302
305
|
- spec/lib/active_remote/primary_key_spec.rb
|