hypertext_client 0.0.8 → 0.0.9

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/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.9 (October 11, 2010)
2
+
3
+ Prevented caching in base_uri for parent class ids
4
+
1
5
  ## 0.0.8 (October 11, 2010)
2
6
 
3
7
  Improved logic for processing id parameter to http methods
@@ -18,7 +18,7 @@
18
18
 
19
19
  # Hypertext provides an HTTP client based on HTTParty, with a few assumptions baked in.
20
20
  module HypertextClient
21
- VERSION = '0.0.8'
21
+ VERSION = '0.0.9'
22
22
 
23
23
  extend ActiveSupport::Concern
24
24
  # Include HTTParty
@@ -114,13 +114,15 @@ module HypertextClient
114
114
  end
115
115
 
116
116
  if self.parents.count > 0 && !(path =~ %r(http://))
117
+ full_uri = "#{base_uri}"
117
118
  options = args.first
118
119
  raise MissingArgumentError.new("Options hash required; must include parent ids") unless options.is_a? Hash
119
120
  self.parents.each do |parent|
120
121
  key = parent.model_name.demodulize.singularize.underscore.to_sym
121
122
  raise MissingArgumentError.new("Missing required argument: #{key}") unless options.has_key? key
122
- base_uri self.base_uri.gsub("|#{key}|", options[key])
123
+ full_uri.gsub!("|#{key}|", options[key])
123
124
  end
125
+ path = full_uri + path
124
126
  end
125
127
 
126
128
  response = super(path, *args)
@@ -47,10 +47,20 @@ FakeWeb.register_uri(:any,
47
47
  :body => [{:property => 'exists'}].to_json,
48
48
  :content_type => 'application/json')
49
49
 
50
+ FakeWeb.register_uri(:any,
51
+ FAKE_ENDPOINT + '/camel_cases/example/camel_case_inheritors',
52
+ :body => [{:property => 'exists'}].to_json,
53
+ :content_type => 'application/json')
54
+
50
55
  FakeWeb.register_uri(:any,
51
56
  FAKE_ENDPOINT + '/camel_cases/example/camel_case_inheritors/123',
52
57
  :body => {:property => 'exists'}.to_json,
53
58
  :content_type => 'application/json')
59
+
60
+ FakeWeb.register_uri(:any,
61
+ FAKE_ENDPOINT + '/camel_cases/different_example/camel_case_inheritors',
62
+ :body => {:property => 'exists'}.to_json,
63
+ :content_type => 'application/json')
54
64
 
55
65
 
56
66
  module SkynetClient
@@ -162,8 +172,20 @@ class HypertextClientTest < MiniTest::Unit::TestCase
162
172
  assert_equal '/camel_cases/example/camel_case_inheritors/123', FakeWeb.last_request.path
163
173
  end
164
174
 
175
+ def test_dont_duplicate_first_param_as_parent_id
176
+ example = SkynetClient::CamelCaseInheritor.delete(123, :camel_case => 'example')
177
+ assert_equal '/camel_cases/example/camel_case_inheritors/123', FakeWeb.last_request.path
178
+ end
179
+
165
180
  def test_build_collection_url_from_hash_for_sub_model
166
181
  example = SkynetClient::CamelCaseInheritor.get(:camel_case => 'example')
167
182
  assert_equal '/camel_cases/example/camel_case_inheritors', FakeWeb.last_request.path
168
183
  end
184
+
185
+ def test_base_uri_should_reset_after_call
186
+ example = SkynetClient::CamelCaseInheritor.get(:camel_case => 'example')
187
+ assert_equal '/camel_cases/example/camel_case_inheritors', FakeWeb.last_request.path
188
+ example = SkynetClient::CamelCaseInheritor.get(:camel_case => 'different_example')
189
+ assert_equal '/camel_cases/different_example/camel_case_inheritors', FakeWeb.last_request.path
190
+ end
169
191
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 8
9
- version: 0.0.8
8
+ - 9
9
+ version: 0.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Quid, Inc.