active_remote 3.3.1 → 3.3.2
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: c58546bd68ea6b44a52688282a95a40b1734cd71d67c651ec29329527abf3e84
|
4
|
+
data.tar.gz: 5cb91fb55081d8b59ec24f946c87fdcc64c12d31b822b93261937631a00c99ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fcf39ec901d0ae3d4b39e5c9715705b80a368db2a6f2048e1eca668647d5d7f8d456c99708b279d2ee5430ef62fd5d1cf6c087d919030fecd838b374e00410d
|
7
|
+
data.tar.gz: 001fd0f7e5576f878537930191126b4621c9b61c1353775d27ea625fcfa3913213d48283d94f5c9043d7a9c0bac07646ff0f8e453e0a563f3a9afd32991ea1d9
|
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
|
@@ -184,7 +184,7 @@ module ActiveRemote
|
|
184
184
|
# Also runs any before/after save callbacks that are defined.
|
185
185
|
#
|
186
186
|
def save!(*args)
|
187
|
-
save(*args) ||
|
187
|
+
save(*args) || fail(RemoteRecordNotSaved, self)
|
188
188
|
end
|
189
189
|
|
190
190
|
# 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
|
@@ -259,9 +259,16 @@ describe ::ActiveRemote::Persistence do
|
|
259
259
|
end
|
260
260
|
|
261
261
|
context "when the record is not saved" do
|
262
|
+
let(:errors) {
|
263
|
+
[Generic::Error.new(:field => "name", :message => "Error one!"),
|
264
|
+
Generic::Error.new(:field => "name", :message => "Error two!")]
|
265
|
+
}
|
266
|
+
let(:response) { Generic::Remote::Tag.new(:errors => errors) }
|
267
|
+
before { allow(rpc).to receive(:execute).and_return(response) }
|
268
|
+
|
262
269
|
it "raises an exception" do
|
263
|
-
|
264
|
-
|
270
|
+
expect { subject.save! }
|
271
|
+
.to raise_error(ActiveRemote::RemoteRecordNotSaved, "Name Error one!, Name Error two!")
|
265
272
|
end
|
266
273
|
end
|
267
274
|
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: 3.3.
|
4
|
+
version: 3.3.2
|
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
|
@@ -232,6 +232,7 @@ files:
|
|
232
232
|
- spec/lib/active_remote/base_spec.rb
|
233
233
|
- spec/lib/active_remote/dirty_spec.rb
|
234
234
|
- spec/lib/active_remote/dsl_spec.rb
|
235
|
+
- spec/lib/active_remote/errors_spec.rb
|
235
236
|
- spec/lib/active_remote/integration_spec.rb
|
236
237
|
- spec/lib/active_remote/persistence_spec.rb
|
237
238
|
- spec/lib/active_remote/primary_key_spec.rb
|
@@ -287,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
287
288
|
version: '0'
|
288
289
|
requirements: []
|
289
290
|
rubyforge_project:
|
290
|
-
rubygems_version: 2.7.
|
291
|
+
rubygems_version: 2.7.6
|
291
292
|
signing_key:
|
292
293
|
specification_version: 4
|
293
294
|
summary: Active Record for your platform
|
@@ -297,6 +298,7 @@ test_files:
|
|
297
298
|
- spec/lib/active_remote/base_spec.rb
|
298
299
|
- spec/lib/active_remote/dirty_spec.rb
|
299
300
|
- spec/lib/active_remote/dsl_spec.rb
|
301
|
+
- spec/lib/active_remote/errors_spec.rb
|
300
302
|
- spec/lib/active_remote/integration_spec.rb
|
301
303
|
- spec/lib/active_remote/persistence_spec.rb
|
302
304
|
- spec/lib/active_remote/primary_key_spec.rb
|