reactive_resource 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'bundler'
2
2
  require 'rake/testtask'
3
- require 'rake/rdoctask'
3
+ require 'rdoc/task'
4
4
  Bundler::GemHelper.install_tasks
5
5
 
6
6
  task :default => :test
@@ -289,5 +289,18 @@ module ReactiveResource
289
289
  @parents ||= belongs_to_associations.map(&:associated_class)
290
290
  end
291
291
 
292
+ private
293
+
294
+ # Same as element_path, except with an extra +method_name+ on
295
+ # the end to support custom methods
296
+ def custom_method_element_url(method_name, options = {})
297
+ prefix_options, query_options = split_options(options)
298
+ "#{self.class.prefix(prefix_options)}#{self.class.association_prefix(prefix_options)}#{self.class.collection_name}/#{id}/#{method_name}#{self.class.extension}#{self.class.__send__(:query_string, query_options)}"
299
+ end
300
+ def custom_method_new_element_url(method_name, options = {})
301
+ prefix_options, query_options = split_options(options)
302
+ "#{self.class.prefix(prefix_options)}#{self.class.association_prefix(prefix_options)}#{self.class.collection_name}/new/#{method_name}#{self.class.extension}#{self.class.__send__(:query_string, query_options)}"
303
+ end
304
+
292
305
  end
293
306
  end
@@ -1,4 +1,4 @@
1
1
  module ReactiveResource
2
2
  # The current version of ReactiveResource
3
- VERSION = "0.7.1"
3
+ VERSION = "0.7.2"
4
4
  end
@@ -162,6 +162,31 @@ class ReactiveResource::BaseTest < Test::Unit::TestCase
162
162
  end
163
163
  end
164
164
 
165
+ context "with custom methods" do
166
+
167
+ should "hit the correct collection urls" do
168
+ stub_request(:post, "https://api.avvo.com/api/1/lawyers/search.json")\
169
+ .to_return(:body => {:lawyers => [{:id => 2}, {:id => 4}]}.to_json)
170
+ ReactiveResource::Lawyer.post(:search, {}, {:first_name => "Bob"})
171
+ assert_requested(:post, "https://api.avvo.com/api/1/lawyers/search.json")
172
+ end
173
+
174
+ should "hit the correct nested collection url" do
175
+ stub_request(:post, "https://api.avvo.com/api/1/lawyers/1/addresses/search.json")\
176
+ .to_return(:body => {:addresses => [{:id => 1}, {:id => 3}]}.to_json)
177
+ ReactiveResource::Address.post(:search, {:lawyer_id => 1}, {:street_name => "21st Ave NE"})
178
+ assert_requested(:post, "https://api.avvo.com/api/1/lawyers/1/addresses/search.json")
179
+ end
180
+
181
+ should "hit the correct member urls" do
182
+ stub_request(:get, "https://api.avvo.com/api/1/lawyers/1/billing_plan.json")\
183
+ .to_return(:body => {:billing_plan => {:type => "hourly", :rate => "200"}}.to_json)
184
+ @object.id = 1
185
+ @object.get(:billing_plan, {})
186
+ assert_requested(:get, "https://api.avvo.com/api/1/lawyers/1/billing_plan.json")
187
+ end
188
+ end
189
+
165
190
  end
166
191
 
167
192
  context "A resource without an extension" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reactive_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-15 00:00:00.000000000 Z
12
+ date: 2013-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activeresource
@@ -114,21 +114,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
114
  - - ! '>='
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
- segments:
118
- - 0
119
- hash: 2162483585092170846
120
117
  required_rubygems_version: !ruby/object:Gem::Requirement
121
118
  none: false
122
119
  requirements:
123
120
  - - ! '>='
124
121
  - !ruby/object:Gem::Version
125
122
  version: '0'
126
- segments:
127
- - 0
128
- hash: 2162483585092170846
129
123
  requirements: []
130
124
  rubyforge_project: reactive_resource
131
- rubygems_version: 1.8.25
125
+ rubygems_version: 1.8.24
132
126
  signing_key:
133
127
  specification_version: 3
134
128
  summary: ActiveRecord-like associations for ActiveResource