acfs 0.23.1 → 0.23.2.b199
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +14 -6
- data/CHANGELOG.md +12 -0
- data/lib/acfs/model/query_methods.rb +6 -1
- data/lib/acfs/version.rb +1 -1
- data/spec/acfs/model/query_methods_spec.rb +27 -1
- data/spec/support/service.rb +1 -1
- metadata +16 -17
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MjA0OGFmMDhhMGZhMDY5Zjc0YmEzNzNhMDg5MDA2MThjOGUzZTg5ZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OWNhYzY2MzM1YjQ1YmVkNzY0ODg5OTcyZjA5NTdjYjBkZTY0YjZmYw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NjU4ZTllOWQ4MmE4ZDM2YjA2YTFhMjA3NGM5ZmY1ZGM4NDY1NTBjNTFhMTcx
|
10
|
+
ZGI3YTNhMmM2OTc3NDYwOTEwZjI4YzNkMjEwMWY1NDc1NjdkYmYyNjJjZTU1
|
11
|
+
ZDgzNmRjOWU1NTkyZGM0M2YyOWRkZDY2YTQwNDUzY2M1ZDAzNzk=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NWExMGY4MjIzZGMyNzQyMjk4ZmM4NzkxOGJlZGY4MWIzZDE5NzE0YTQ4YWVh
|
14
|
+
NThjN2JkMTA4MTdhNmFmZGM5ZWJmYzJkMTljZTg4ZmNkOGFjNGFmMTUxZWEx
|
15
|
+
MDI1YzZiMjIxYWE4YjUxMTE2NGM0MjJmNjY2NjY0NzAyZGJhOWY=
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.23.2
|
4
|
+
|
5
|
+
* Fix regression in delegator usage by #find due to resource type inheritance.
|
6
|
+
|
7
|
+
## 0.23.1
|
8
|
+
|
9
|
+
* Fix error class name typo
|
10
|
+
|
11
|
+
## 0.23.0
|
12
|
+
|
13
|
+
* Add Resource Type Inheritance
|
14
|
+
|
3
15
|
## 0.22.2
|
4
16
|
|
5
17
|
* Preserve errors received from service on revalidation (2f1fc178)
|
@@ -86,9 +86,14 @@ module Acfs::Model
|
|
86
86
|
end
|
87
87
|
alias :where :all
|
88
88
|
|
89
|
+
# TODO: Replace delegator with promise or future for the long run.
|
90
|
+
class ResourceDelegator < SimpleDelegator
|
91
|
+
delegate :class, :is_a?, :kind_of?, to: :__getobj__
|
92
|
+
end
|
93
|
+
|
89
94
|
private
|
90
95
|
def find_single(id, opts, &block)
|
91
|
-
model =
|
96
|
+
model = ResourceDelegator.new self.new
|
92
97
|
|
93
98
|
opts[:params] ||= {}
|
94
99
|
opts[:params].merge!({ id: id })
|
data/lib/acfs/version.rb
CHANGED
@@ -8,6 +8,7 @@ describe Acfs::Model::QueryMethods do
|
|
8
8
|
context 'with successful response' do
|
9
9
|
before do
|
10
10
|
stub_request(:get, 'http://users.example.org/users/1').to_return response({ id: 1, name: 'Anon', age: 12 })
|
11
|
+
stub_request(:get, 'http://users.example.org/users/2').to_return response({ id: 2, type: 'Customer', name: 'Clare Customer', age: 24 })
|
11
12
|
end
|
12
13
|
|
13
14
|
it 'should load a single remote resource' do
|
@@ -20,13 +21,28 @@ describe Acfs::Model::QueryMethods do
|
|
20
21
|
it 'should invoke callback after model is loaded' do
|
21
22
|
proc = Proc.new { }
|
22
23
|
proc.should_receive(:call) do |user|
|
23
|
-
expect(user
|
24
|
+
expect(user).to equal @user
|
24
25
|
expect(user).to be_loaded
|
25
26
|
end
|
26
27
|
|
27
28
|
@user = model.find 1, &proc
|
28
29
|
Acfs.run
|
29
30
|
end
|
31
|
+
|
32
|
+
context 'with resource type inheritance' do
|
33
|
+
let!(:user) { MyUser.find 2 }
|
34
|
+
subject { user }
|
35
|
+
before { Acfs.run }
|
36
|
+
|
37
|
+
it 'should respect resource type inheritance' do
|
38
|
+
expect(subject).to be_a Customer
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should implement ActiveModel class interface' do
|
42
|
+
expect(subject.class).to be_a ActiveModel::Naming
|
43
|
+
expect(subject.class).to be_a ActiveModel::Translation
|
44
|
+
end
|
45
|
+
end
|
30
46
|
end
|
31
47
|
|
32
48
|
context 'with 404 response' do
|
@@ -62,6 +78,8 @@ describe Acfs::Model::QueryMethods do
|
|
62
78
|
before do
|
63
79
|
stub_request(:get, 'http://users.example.org/users/1').to_return response({ id: 1, name: 'Anon', age: 12 })
|
64
80
|
stub_request(:get, 'http://users.example.org/users/2').to_return response({ id: 2, name: 'Johnny', age: 42 })
|
81
|
+
stub_request(:get, 'http://users.example.org/users/3').to_return response({ id: 3, type: 'Customer', name: 'Anon', age: 12 })
|
82
|
+
stub_request(:get, 'http://users.example.org/users/4').to_return response({ id: 4, name: 'Johnny', age: 42 })
|
65
83
|
end
|
66
84
|
|
67
85
|
context 'with successful response' do
|
@@ -85,6 +103,14 @@ describe Acfs::Model::QueryMethods do
|
|
85
103
|
@users = model.find 1, 2, &proc
|
86
104
|
Acfs.run
|
87
105
|
end
|
106
|
+
|
107
|
+
it 'should respect resource type inheritance' do
|
108
|
+
customers = MyUser.find 3, 4
|
109
|
+
Acfs.run
|
110
|
+
|
111
|
+
expect(customers[0]).to be_a Customer
|
112
|
+
expect(customers[1]).to be_a MyUser
|
113
|
+
end
|
88
114
|
end
|
89
115
|
|
90
116
|
context 'with one 404 response' do
|
data/spec/support/service.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acfs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.23.
|
4
|
+
version: 0.23.2.b199
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
@@ -14,84 +14,84 @@ dependencies:
|
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - '>='
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - '>='
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - '>='
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '3.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - '>='
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: actionpack
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - '>='
|
45
|
+
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '3.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - '>='
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: multi_json
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - '>='
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - '>='
|
66
|
+
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: typhoeus
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - '>='
|
73
|
+
- - ! '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - '>='
|
80
|
+
- - ! '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rack
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - '>='
|
87
|
+
- - ! '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - '>='
|
94
|
+
- - ! '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
@@ -212,14 +212,14 @@ require_paths:
|
|
212
212
|
- lib
|
213
213
|
required_ruby_version: !ruby/object:Gem::Requirement
|
214
214
|
requirements:
|
215
|
-
- - '>='
|
215
|
+
- - ! '>='
|
216
216
|
- !ruby/object:Gem::Version
|
217
217
|
version: '0'
|
218
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
|
-
- - '
|
220
|
+
- - ! '>'
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version:
|
222
|
+
version: 1.3.1
|
223
223
|
requirements: []
|
224
224
|
rubyforge_project:
|
225
225
|
rubygems_version: 2.0.3
|
@@ -253,4 +253,3 @@ test_files:
|
|
253
253
|
- spec/spec_helper.rb
|
254
254
|
- spec/support/response.rb
|
255
255
|
- spec/support/service.rb
|
256
|
-
has_rdoc:
|