reactive_resource 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 192e1ce2551ece81aa583a972e8ab4eeff0a09f8
4
+ data.tar.gz: 727d9b8b1a90a9099084f737255bc362db82ec1a
5
+ SHA512:
6
+ metadata.gz: 33e0e21457396220e42ff5bf65c93bed5d115d778798b958ec47d91e91b6fc6eb4ed90e1e0c61a2c9087d6d1ae572b98fa3ba207547cdc5f0a3246784630190a
7
+ data.tar.gz: a696dea8f9ceb26fb3b3eaf074931f346b1afe6385cedcb77f2e244f4cda062b2494edbcdd58d175a29cb500daaddc8e9aab0f3607bab397ccc6403109deb6f0
@@ -1,10 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
3
  - 1.9.2
5
4
  - 1.9.3
6
- - rbx-18mode
7
5
  - rbx-19mode
8
6
  env:
9
7
  - RAILS_VERSION=3.1.0
10
- - RAILS_VERSION=3.2.0
8
+ - RAILS_VERSION=3.2.0
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in reactive_resource.gemspec
4
4
  gemspec
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- reactive_resource (0.7.1)
4
+ reactive_resource (0.7.3)
5
5
  activeresource (>= 3.1)
6
6
  activesupport (>= 3.1)
7
7
 
8
8
  GEM
9
- remote: http://rubygems.org/
9
+ remote: https://rubygems.org/
10
10
  specs:
11
11
  activemodel (3.2.12)
12
12
  activesupport (= 3.2.12)
@@ -20,7 +20,7 @@ GEM
20
20
  addressable (2.2.2)
21
21
  builder (3.0.4)
22
22
  crack (0.1.8)
23
- i18n (0.6.1)
23
+ i18n (0.6.4)
24
24
  multi_json (1.6.1)
25
25
  rake (0.9.2)
26
26
  shoulda (2.11.3)
@@ -137,7 +137,7 @@ module ReactiveResource
137
137
  used_association = nil
138
138
 
139
139
  belongs_to_associations.each do |association|
140
- if !used_association && param_value = options.delete("#{association.attribute}_id".intern) # only take the first one
140
+ if !used_association && (association.associated_class.singleton? || param_value = options.delete("#{association.attribute}_id".intern)) # only take the first one
141
141
  used_associations << association
142
142
  break
143
143
  end
@@ -160,8 +160,12 @@ module ReactiveResource
160
160
 
161
161
  association_prefix = used_associations.map do |association|
162
162
  collection_name = association.associated_class.collection_name
163
- value = options.delete("#{association.attribute}_id".intern)
164
- "#{collection_name}/#{value}"
163
+ if association.associated_class.singleton?
164
+ collection_name
165
+ else
166
+ value = options.delete("#{association.attribute}_id".intern)
167
+ "#{collection_name}/#{value}"
168
+ end
165
169
  end.join('/')
166
170
 
167
171
  # add trailing slash
@@ -280,7 +284,11 @@ module ReactiveResource
280
284
  # associations and merge them in. This allows us to have both
281
285
  # lawyer_id and address_id at url generation time.
282
286
  def self.belongs_to_with_parents
283
- belongs_to_associations.map(&:associated_attributes).flatten.uniq
287
+ @belongs_to_with_parents ||= begin
288
+ ret = belongs_to_associations.map(&:associated_attributes)
289
+ ret += parents.map(&:belongs_to_with_parents)
290
+ ret.flatten.uniq
291
+ end
284
292
  end
285
293
 
286
294
  # All the classes that this class references in its +belongs_to+,
@@ -1,4 +1,4 @@
1
1
  module ReactiveResource
2
2
  # The current version of ReactiveResource
3
- VERSION = "0.7.2"
3
+ VERSION = "0.7.3"
4
4
  end
@@ -20,6 +20,12 @@ class ReactiveResource::Headshot < ReactiveResource::Base
20
20
  singleton
21
21
  belongs_to :lawyer
22
22
  belongs_to :doctor
23
+ has_one :file
24
+ end
25
+
26
+ class ReactiveResource::File < ReactiveResource::Base
27
+ singleton
28
+ belongs_to :headshot
23
29
  end
24
30
 
25
31
  class ReactiveResource::Address < ReactiveResource::Base
@@ -63,6 +63,19 @@ class ReactiveResource::BaseTest < Test::Unit::TestCase
63
63
  end
64
64
  end
65
65
 
66
+ context "with a nested has_one relationships" do
67
+ should "hit the correct url" do
68
+ stub_request(:get, "https://api.avvo.com/api/1/lawyers/1/headshot.json")\
69
+ .to_return(:body => {:headshot => {:headshot_url => "blah"}}.to_json)
70
+ stub_request(:get, "https://api.avvo.com/api/1/lawyers/1/headshot/file.json")\
71
+ .to_return(:body => {:file => {:file_url => "blah"}}.to_json)
72
+ @object.id = 1
73
+ @object.headshot.file
74
+ assert_requested(:get, "https://api.avvo.com/api/1/lawyers/1/headshot.json")
75
+ assert_requested(:get, "https://api.avvo.com/api/1/lawyers/1/headshot/file.json")
76
+ end
77
+ end
78
+
66
79
  context "with a belongs_to association and correct parameters" do
67
80
  setup do
68
81
  @object = ReactiveResource::Address.new(:lawyer_id => 2)
metadata CHANGED
@@ -1,52 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reactive_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
5
- prerelease:
4
+ version: 0.7.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Justin Weiss
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-05 00:00:00.000000000 Z
11
+ date: 2013-03-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activeresource
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.1'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '3.1'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: activesupport
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '3.1'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '3.1'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: shoulda
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: webmock
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -104,27 +95,26 @@ files:
104
95
  - test/unit/base_test.rb
105
96
  homepage: ''
106
97
  licenses: []
98
+ metadata: {}
107
99
  post_install_message:
108
100
  rdoc_options: []
109
101
  require_paths:
110
102
  - lib
111
103
  required_ruby_version: !ruby/object:Gem::Requirement
112
- none: false
113
104
  requirements:
114
- - - ! '>='
105
+ - - '>='
115
106
  - !ruby/object:Gem::Version
116
107
  version: '0'
117
108
  required_rubygems_version: !ruby/object:Gem::Requirement
118
- none: false
119
109
  requirements:
120
- - - ! '>='
110
+ - - '>='
121
111
  - !ruby/object:Gem::Version
122
112
  version: '0'
123
113
  requirements: []
124
114
  rubyforge_project: reactive_resource
125
- rubygems_version: 1.8.24
115
+ rubygems_version: 2.0.2
126
116
  signing_key:
127
- specification_version: 3
117
+ specification_version: 4
128
118
  summary: ActiveRecord-like associations for ActiveResource
129
119
  test_files:
130
120
  - test/test_helper.rb