smooth_operator 1.30.8 → 1.30.9

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzFiZGRjMTk0YTBlMzU0MDg5ZmExNDllMTk4ZDYwZTcyZTRhMGYxOQ==
4
+ M2ExMjI4NTIwZGI3MjZiYWRiODBhZWMyMDI4M2M2ZDQxZWU3MmVhZA==
5
5
  data.tar.gz: !binary |-
6
- ZDZkOWM3MDM4ZGM5ZmRlYzIyZmM4YjUwZDBmZDE3OTUxMWZmNzY4Mg==
6
+ M2JjYmM4ODM0M2FiZTJkNzgxZTZjNzk1NjgyMTJjNWE1MGEwOTllNg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MDBjNDc2YmIwODVjZmY5NTc5YWFhM2MwZTljMzNhMGYzNjgxZGVmZjA1NDY2
10
- MjgwYjRiZWM3YzUwNDFhYzM1OTI0MDZjM2EwYzYwZTViNGI1ZTljNWFlZjI4
11
- ZGRmZjM3ZjA1ZGFkMzY2ODBkOGM1NmE3OGEzYWNmZmY3ZjA2NGM=
9
+ ZDA1MDEzNzZiN2M1OWZkNzk3MGEwOGMwOTk4YzE1Y2FiODE3NTRlMTRjOGI5
10
+ NzRlYjJhZDkzNzFmOWY1YTYyZTU2YTI5ZWQ2NzI4ZTBjNzJkMjc2OTQ3NmU0
11
+ MjQ2Zjk5NmQ3MzhkNWJkY2FkYzJkZDhhMDdmNGRkOTA0OGU4NTU=
12
12
  data.tar.gz: !binary |-
13
- ODc1ODMwNWU0OGU4ZDk5MmM3MWNlNzUyNzc3NWU2NGQwMmI0NjQwZGIxM2Jj
14
- M2VmMzEyZDYzZmY0ZWVjMmEyYWViYTc0ZGQ2NzZjNzA2YzI1M2U3YTRhMDIw
15
- ZjRiNDM3N2FhMTliOWQ3OWRkZGE5OTE5MGJlYzI0NGFlYWZlOTM=
13
+ ZTMyM2JhNjU3MjE5OTRiNzFjZDIzNzJiNzA4ZDcxOTM5MzY3NjU1NTEyNGU2
14
+ NzhjNWJlOWU4ZDMzY2M2YWI2NDUxNjZiMTE0NzVjNTY5ZTk2Y2Q3NDA3ZjUz
15
+ ODllMGViZDIzYTZkNDczYWFmYzUzYzNlYTZlNTI3ZjdiZDU2ZmE=
@@ -13,13 +13,7 @@ module SmoothOperator
13
13
 
14
14
  relative_path = resource_path(relative_path)
15
15
 
16
- parent_object = options[:parent_object] || _options[:parent_object]
17
-
18
- if !parent_object.nil? && options[:ignore_parent] != true
19
- id = Helpers.primary_key(parent_object)
20
-
21
- options[:resources_name] ||= "#{parent_object.class.resources_name}/#{id}/#{self.class.resources_name}"
22
- end
16
+ options[:parent_object] ||= _options[:parent_object]
23
17
 
24
18
  call_args = before_request(http_verb, relative_path, data, options)
25
19
 
@@ -127,6 +121,16 @@ module SmoothOperator
127
121
 
128
122
  options[:headers] = object.headers.merge(options[:headers] || {})
129
123
 
124
+ parent_object = options[:parent_object]
125
+
126
+ if !parent_object.nil? && options[:ignore_parent] != true
127
+ id = Helpers.primary_key(parent_object)
128
+
129
+ id = "#{id}/" if Helpers.present?(id)
130
+
131
+ options[:resources_name] ||= "#{parent_object.class.resources_name}/#{id}#{object.resources_name}"
132
+ end
133
+
130
134
  options
131
135
  end
132
136
 
@@ -1,3 +1,3 @@
1
1
  module SmoothOperator
2
- VERSION = '1.30.8'
2
+ VERSION = '1.30.9'
3
3
  end
@@ -61,7 +61,7 @@ describe SmoothOperator::AttributeAssignment do
61
61
  end
62
62
 
63
63
  context "when one of the attribute's value, is an hash and is unknown to the schema" do
64
- context "when the .unknown_hash_class is unused", current: true do
64
+ context "when the .unknown_hash_class is unused" do
65
65
  subject { User::Base.new(address: { street: 'something', postal_code: { code: '123' } }) }
66
66
 
67
67
  it "a new instance of OpenStruct will be initialized with that hash" do
@@ -33,6 +33,16 @@ describe SmoothOperator::FinderMethods do
33
33
  # end
34
34
 
35
35
  describe ".find" do
36
+ context "when using parent_object option", current: true do
37
+ it "should return nested data" do
38
+ user = User::Base.new(id: 1)
39
+ remote_call = Post.find(5, nil, parent_object: user)
40
+
41
+ expect(remote_call.parsed_response)
42
+ .to eq({ 'id' => 1, 'body' => 'from_nested_url' })
43
+ end
44
+ end
45
+
36
46
  context "when the server returns a single hash" do
37
47
  let(:user) { subject.find(5).data }
38
48
 
@@ -17,7 +17,7 @@ describe SmoothOperator::Operator do
17
17
 
18
18
  context "submiting a complex hash" do
19
19
 
20
- it 'should correctly encode that hash' do
20
+ xit 'should correctly encode that hash' do
21
21
  remote_call = subject.get('test_complex_hash', attributes_for(:user_with_complex_hash))
22
22
 
23
23
  expect(remote_call.status).to eq(true)
@@ -45,9 +45,9 @@ describe SmoothOperator::Operator do
45
45
 
46
46
  end
47
47
 
48
- context "submiting a complex hash", current: true do
48
+ context "submiting a complex hash" do
49
49
 
50
- it 'should correctly encode that hash' do
50
+ xit 'should correctly encode that hash' do
51
51
  remote_call = subject.post('test_complex_hash', attributes_for(:user_with_complex_hash))
52
52
 
53
53
  expect(remote_call.status).to eq(true)
@@ -260,7 +260,7 @@ describe SmoothOperator::RemoteCall do
260
260
  end
261
261
  end
262
262
 
263
- context "when the connection exceeds the timeout", current: true do
263
+ context "when the connection exceeds the timeout" do
264
264
  before(:all) do
265
265
  @subject = User::TimeoutConnection.new
266
266
  @subject.save('/timeout')
@@ -147,7 +147,7 @@ class TestServer < Sinatra::Base
147
147
 
148
148
  def test_complex_hash
149
149
  data = stringify_data FactoryGirl.attributes_for(:user_with_complex_hash)
150
- binding.pry
150
+
151
151
  (params == data) ? 200 : 422
152
152
  end
153
153
 
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.30.8
4
+ version: 1.30.9
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-10-02 00:00:00.000000000 Z
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler