smooth_operator 1.21.3 → 1.21.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/console.rb +2 -0
- data/lib/smooth_operator/attribute_assignment.rb +1 -5
- data/lib/smooth_operator/remote_call/base.rb +1 -1
- data/lib/smooth_operator/version.rb +1 -1
- data/lib/smooth_operator.rb +6 -1
- data/spec/smooth_operator/remote_call_spec.rb +4 -4
- data/spec/support/models/comment.rb +2 -0
- data/spec/support/models/post.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjNhMmMxNjM2YzRiMzY4ZGIxNzc4YzI3YTE2MTY4ZDQ1Y2MzNGRjMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmE3NjZkNTExYzdhNWRlNTQ1ZTZhNDIwMDNlMDBkODQ4NmFlYmJiNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDEwZWY2MjJhYTY2NzY2ZGQzZjVkM2I5ODBmMjk0MTI5YWZkMzNmMzM1NTkx
|
10
|
+
OGMxOTVmYjYyYTRmZjVmMjljZjk4NGYxMWNiNzkzMzAwMmQ1NjViODRkMzYw
|
11
|
+
YzMzOWRiOWQ1NDgxODc4YTRlMTk5MDllZDdlZDE3MGI4NjA4Yjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjllMGFlMjdhOWUyZDdiOTBkM2QyZGNhYzE0NjJkMWJiZmMwODBlMGE5YjJl
|
14
|
+
NGQ0NWRiN2E2Y2Y4NjcyMzk2NjZhNTRkY2I4NzA1ZjE4ZmExYjRjNDVkNzE2
|
15
|
+
MWI3ZTA4NDkzODE3ODk2YWMwZDJhNDljNzk0ZDY0ZDM0MmI2M2U=
|
data/console.rb
CHANGED
@@ -31,4 +31,6 @@ post = Post.new(comments: [{ id: 1, name: '1' }, { id: 2, name: '2' }], address:
|
|
31
31
|
|
32
32
|
comments_attributes = { "0" => { id: 1, name: '3' }, "1" => { name: '4' } }
|
33
33
|
|
34
|
+
comments_with_errors = { "0" => { id: 1, name: '3', errors: { body: ["can't be blank"] } }, "1" => { name: '4', errors: { body: ["can't be blank"] } } }
|
35
|
+
|
34
36
|
binding.pry
|
data/lib/smooth_operator.rb
CHANGED
@@ -38,6 +38,8 @@ module SmoothOperator
|
|
38
38
|
include ActiveModel::Validations::Callbacks
|
39
39
|
include ActiveModel::Conversion
|
40
40
|
|
41
|
+
self.unknown_hash_class = SmoothOperator::OpenStruct
|
42
|
+
|
41
43
|
validate :validate_induced_errors, :validate_nested_objects
|
42
44
|
|
43
45
|
def column_for_attribute(attribute_name)
|
@@ -77,7 +79,10 @@ module SmoothOperator
|
|
77
79
|
end
|
78
80
|
|
79
81
|
def validate_nested_objects
|
80
|
-
|
82
|
+
all_nested_objects = self.class.reflections.keys
|
83
|
+
.map { |association| send(association) }.flatten.compact
|
84
|
+
|
85
|
+
all_nested_objects.map { |nested_object| nested_object.valid? }.all?
|
81
86
|
end
|
82
87
|
|
83
88
|
end
|
@@ -247,7 +247,7 @@ describe SmoothOperator::RemoteCall do
|
|
247
247
|
|
248
248
|
context "when the connection exceeds the timeout" do
|
249
249
|
subject { User::TimeoutConnection.new }
|
250
|
-
|
250
|
+
|
251
251
|
before { subject.save('/timeout') }
|
252
252
|
|
253
253
|
it "#ok? should return false" do
|
@@ -291,8 +291,8 @@ describe SmoothOperator::RemoteCall do
|
|
291
291
|
context "when the server response's body does not contains valid json data" do
|
292
292
|
let(:remote_call) { User::Base.find('bad_json') }
|
293
293
|
|
294
|
-
it "should return
|
295
|
-
expect(remote_call.data).to
|
294
|
+
it "it should return what the server has returned" do
|
295
|
+
expect(remote_call.data).to eq('ok')
|
296
296
|
end
|
297
297
|
end
|
298
298
|
end
|
@@ -308,7 +308,7 @@ describe SmoothOperator::RemoteCall do
|
|
308
308
|
|
309
309
|
context "when a server connection fails" do
|
310
310
|
subject { User::TimeoutConnection.new }
|
311
|
-
|
311
|
+
|
312
312
|
before { subject.save('/timeout') }
|
313
313
|
|
314
314
|
it "should return 0" do
|
data/spec/support/models/post.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smooth_operator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.21.
|
4
|
+
version: 1.21.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- João Gonçalves
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|