api-model 2.1.0 → 2.1.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: 4429aa28093885e9a1fe8ec0c21640866b2c9681
4
- data.tar.gz: 3a049bf4664ea95bf7510c8f925ef3a5d9a2152c
3
+ metadata.gz: f8273b2a0168dac33ede420787115f8cf034fedd
4
+ data.tar.gz: d4353c56c88b74051a74ab7d6dbb6385cd4e9e8a
5
5
  SHA512:
6
- metadata.gz: 4446f3269d881f915a7f0834d7c887811c1d3f346b7f06d598295495d16d988930355786b17d77aec397063a812fbe1010be42a05a6a7baa43419d71703b826b
7
- data.tar.gz: 1419d5dd05f5e6779fe3beed226aa4bcb2ada6d3e76905f1ae48f414d84d0545a970e48cf9d739daaf039a994168b2bd6754f16f290bd3dc7ab0b5f7782ad7a4
6
+ metadata.gz: dd797e47911ad4b432e3bf0c6da1a0ba456cd46891a1e935dd8598f97146c90bf74ac485eb13fe66641bddfc2c5be868c0a95f9d2a6b97a49872c422b9421f09
7
+ data.tar.gz: 2a0b2cab17ead05483a17b12f58b07a5609877cb82a1ffade8e05020c2d33afb4b4f6af0d7c1d2aaf6f72f0a33d5e8018dfeee7c41e0f9369f67aa5c3c223409
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- api-model (2.1.0)
4
+ api-model (2.1.1)
5
5
  activemodel (~> 4.1)
6
6
  activesupport (~> 4.1)
7
7
  hash-pipe (~> 0.0)
@@ -11,10 +11,10 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activemodel (4.1.0)
15
- activesupport (= 4.1.0)
14
+ activemodel (4.1.1)
15
+ activesupport (= 4.1.1)
16
16
  builder (~> 3.1)
17
- activesupport (4.1.0)
17
+ activesupport (4.1.1)
18
18
  i18n (~> 0.6, >= 0.6.9)
19
19
  json (~> 1.7, >= 1.7.7)
20
20
  minitest (~> 5.1)
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "api-model"
5
- s.version = "2.1.0"
5
+ s.version = "2.1.1"
6
6
  s.authors = ["Damien Timewell", "Erik Rothoff Andersson"]
7
7
  s.email = ["mail@damientimewell.com", "erik.rothoff@gmail.com"]
8
8
  s.licenses = ['MIT']
@@ -61,7 +61,7 @@ module ApiModel
61
61
 
62
62
  if response_success
63
63
  run_callbacks :successful_save do
64
- update_attributes response.response_body
64
+ update_attributes response.response_build_hash
65
65
  end
66
66
  else
67
67
  run_callbacks :unsuccessful_save do
@@ -77,8 +77,6 @@ module ApiModel
77
77
  end
78
78
  end
79
79
 
80
- private
81
-
82
80
  # If the model config defines a json root, use it on the response_body
83
81
  # to dig down in to the hash.
84
82
  def response_build_hash
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'support/mock_models/blog_post'
3
3
  require 'support/mock_models/car'
4
+ require 'support/mock_models/user'
4
5
 
5
6
  describe ApiModel do
6
7
 
@@ -188,10 +189,12 @@ describe ApiModel do
188
189
  describe "saving changes on an instance" do
189
190
  before do
190
191
  BlogPost.api_config { |config| config.host = "http://api-model-specs.com" }
192
+ User.api_config { |c| c.json_root = "users" }
191
193
  end
192
194
 
193
195
  after do
194
196
  BlogPost.reset_api_configuration
197
+ User.reset_api_configuration
195
198
  end
196
199
 
197
200
  let(:blog_post) { BlogPost.new }
@@ -215,6 +218,14 @@ describe ApiModel do
215
218
  VCR.use_cassette('posts') { blog_post.save "/post/2", name: "foobarbaz" }
216
219
  end
217
220
 
221
+ it 'should use the config.json_root value when updating attributes' do
222
+ user = User.new
223
+
224
+ expect {
225
+ VCR.use_cassette('users') { user.save "http://api-model-specs.com/create" }
226
+ }.to change{ user.name }.from(nil).to("foo")
227
+ end
228
+
218
229
  it 'should set errors on the instance if the response contains an errors hash' do
219
230
  expect {
220
231
  VCR.use_cassette('posts') { blog_post.save "/post/with_errors", name: "" }
@@ -54,4 +54,31 @@ http_interactions:
54
54
  http_version:
55
55
  recorded_at: Thu, 28 Nov 2013 16:02:20 GMT
56
56
 
57
+ - request:
58
+ method: put
59
+ uri: http://api-model-specs.com/create
60
+ headers:
61
+ User-Agent:
62
+ - Typhoeus - https://github.com/typhoeus/typhoeus
63
+ response:
64
+ status:
65
+ code: 200
66
+ message: OK
67
+ headers:
68
+ Server:
69
+ - nginx/1.4.1
70
+ Date:
71
+ - Thu, 28 Nov 2013 16:02:56 GMT
72
+ Content-Type:
73
+ - text/plain; charset=utf-8
74
+ Content-Length:
75
+ - '248'
76
+ Connection:
77
+ - keep-alive
78
+ body:
79
+ encoding: UTF-8
80
+ string: "{\"users\":{\"name\":\"foo\"}}"
81
+ http_version:
82
+ recorded_at: Thu, 28 Nov 2013 16:02:20 GMT
83
+
57
84
  recorded_with: VCR 2.8.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien Timewell
@@ -9,104 +9,104 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-28 00:00:00.000000000 Z
12
+ date: 2014-05-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '4.1'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '4.1'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: activemodel
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '4.1'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '4.1'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: typhoeus
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0.6'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0.6'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: virtus
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ~>
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '1.0'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ~>
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1.0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: hash-pipe
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ~>
74
+ - - "~>"
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0.0'
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ~>
81
+ - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0.0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rspec
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ~>
88
+ - - "~>"
89
89
  - !ruby/object:Gem::Version
90
90
  version: '2.14'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ~>
95
+ - - "~>"
96
96
  - !ruby/object:Gem::Version
97
97
  version: '2.14'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: pry
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ~>
102
+ - - "~>"
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0.9'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ~>
109
+ - - "~>"
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0.9'
112
112
  - !ruby/object:Gem::Dependency
@@ -147,9 +147,9 @@ executables: []
147
147
  extensions: []
148
148
  extra_rdoc_files: []
149
149
  files:
150
- - .gitignore
151
- - .rspec
152
- - .travis.yml
150
+ - ".gitignore"
151
+ - ".rspec"
152
+ - ".travis.yml"
153
153
  - Gemfile
154
154
  - Gemfile.lock
155
155
  - README.md
@@ -191,17 +191,17 @@ require_paths:
191
191
  - lib
192
192
  required_ruby_version: !ruby/object:Gem::Requirement
193
193
  requirements:
194
- - - '>='
194
+ - - ">="
195
195
  - !ruby/object:Gem::Version
196
196
  version: '0'
197
197
  required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - '>='
199
+ - - ">="
200
200
  - !ruby/object:Gem::Version
201
201
  version: '0'
202
202
  requirements: []
203
203
  rubyforge_project:
204
- rubygems_version: 2.1.11
204
+ rubygems_version: 2.2.2
205
205
  signing_key:
206
206
  specification_version: 4
207
207
  summary: A simple way of interacting with rest APIs