her 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 72114f9b29011146dffc658a0e7d4e4982ded486
4
- data.tar.gz: c2118def58a8024890fba2115b921adeee329783
3
+ metadata.gz: 109d53a5d927fd7ee67674af4b5944f06c2c6de4
4
+ data.tar.gz: cef631d95fa6b495bd92c354e5a9122d296b42a6
5
5
  SHA512:
6
- metadata.gz: 110eb7da65e83503c0922e787999ea4125886d105ea0e70f23abed9539ea6342f288953c69445b1664b7680c2e96884777ef2aaf5af1bbfda9b629c67fa557ea
7
- data.tar.gz: 39020447959095c9b29b270102f64648b272520e4d88f7e2e3f4ae7e3f8212b74c07e323b44b8702272d79237d20f3a5386e8436d5a367bfa9f87f7d830f0bb7
6
+ metadata.gz: 4e229413c7297cd7c5864880d6a98658fd194eb2deac87724841e4bc6f58dfa7a7a42056d092a9250f0f99506a4e6d67051ce63f2970d0e1281ac881b37bc587
7
+ data.tar.gz: b5fb836f54c4fbd89c201f4a213078900357eb0dfe57e3977ff2966daec1c5e7a7a0236d016bb055a45ce8a1d342e3d4dcdbd217ce7fe5cb8887a122f343efe5
@@ -145,7 +145,8 @@ module Her
145
145
 
146
146
  # @private
147
147
  def root_element_included?(data)
148
- data.keys.to_s.include? @_her_root_element.to_s
148
+ element = data[root_element]
149
+ element.is_a?(Hash) || element.is_a?(Array)
149
150
  end
150
151
 
151
152
  # @private
@@ -1,3 +1,3 @@
1
1
  module Her
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -493,4 +493,25 @@ describe Her::Model::Parse do
493
493
  expect(user.to_params).to eq(model: { name: 'foo' })
494
494
  end
495
495
  end
496
+
497
+ context "when attribute uses the same name as root element" do
498
+ before do
499
+ Her::API.setup url: "https://api.example.com" do |builder|
500
+ builder.use Her::Middleware::FirstLevelParseJSON
501
+ builder.use Faraday::Request::UrlEncoded
502
+ end
503
+
504
+ Her::API.default_api.connection.adapter :test do |stub|
505
+ stub.post("/users") { |env| [200, {}, { user: "foobar", id: 1, fullname: params(env)[:fullname] }.to_json] }
506
+ end
507
+
508
+ spawn_model "Foo::User"
509
+ end
510
+
511
+ it "parses as attribute instead of root element" do
512
+ user = Foo::User.create(fullname: "barfoo")
513
+ expect(user.fullname).to eq "barfoo"
514
+ expect(user.user).to eq "foobar"
515
+ end
516
+ end
496
517
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: her
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rémi Prévost
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-26 00:00:00.000000000 Z
11
+ date: 2018-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake