her 0.10.1 → 0.10.2

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: b1d26b46a64420261f94f9394f9552d0f6152d27
4
- data.tar.gz: '009e2b3a0c746e2ff24d2c96e7b3e110852b6e5c'
3
+ metadata.gz: e628f5db6baa8daefe84a2ad28e8d538b4e50b40
4
+ data.tar.gz: 54e12aa3f8c46c79dc447a18108a135621fd7dc8
5
5
  SHA512:
6
- metadata.gz: 119265f2cfea3d575768faf7f5b9dbec5e88da8536068dd51957251cdf921b275e4527767ca57f647172951341bfcca6a3d0363ff0091cbb2f40b0ec89c922fc
7
- data.tar.gz: d74157011df12022512bc46df0ae02cc48f69bd89753a72eac0e32b88921d9356e2073c8b63e238d925304f3bf4ba07418d7c58898bf87308e8deebbacc46b48
6
+ metadata.gz: ac64ae278cd0c9927d790a9139e9e7afdd54230c4d54da1e865f8bd729e7742dd511210cce6a9ac8f211977805b38dfe979be88ee5d69684288c0a591128f17c
7
+ data.tar.gz: 18e8f64882b5a3c7829a102de8e4738bc4b094ae2e773b90077663d91a4db96ea1bda3359168d15c55955a9457c882d0a240d36fc204070eaa53d3a7db1a117c
@@ -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
data/lib/her/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Her
2
- VERSION = "0.10.1"
2
+ VERSION = "0.10.2"
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: 0.10.1
4
+ version: 0.10.2
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-25 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