activeresource-response 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -43,7 +43,7 @@ module ActiveResourceResponse
|
|
43
43
|
|
44
44
|
|
45
45
|
class << self
|
46
|
-
alias find_without_http_response find
|
46
|
+
alias :find_without_http_response :find
|
47
47
|
|
48
48
|
def find(*arguments)
|
49
49
|
result = find_without_http_response(*arguments)
|
@@ -55,6 +55,18 @@ module ActiveResourceResponse
|
|
55
55
|
end
|
56
56
|
|
57
57
|
|
58
|
+
|
59
|
+
def remove_response_method
|
60
|
+
class << self
|
61
|
+
undef :find
|
62
|
+
alias :find :find_without_http_response
|
63
|
+
undef :find_without_http_response
|
64
|
+
undef :http_response_method
|
65
|
+
undef :http_response_method=
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
58
70
|
def merge_response_to_result(result)
|
59
71
|
result.instance_variable_set(:@http_response, connection.http_response)
|
60
72
|
(class << result; self; end).send(:define_method, self.http_response_method) do
|
@@ -32,8 +32,8 @@ require 'active_resource/http_mock'
|
|
32
32
|
require 'active_resource_response'
|
33
33
|
require "fixtures/country"
|
34
34
|
require "fixtures/city"
|
35
|
-
|
36
35
|
require "fixtures/region"
|
36
|
+
require "fixtures/street"
|
37
37
|
|
38
38
|
class ActiveResourceResponseTest < Test::Unit::TestCase
|
39
39
|
|
@@ -43,6 +43,7 @@ class ActiveResourceResponseTest < Test::Unit::TestCase
|
|
43
43
|
@country = {:country => {:id => 1, :name => "Ukraine", :iso=>"UA"}}
|
44
44
|
@city = {:city => {:id => 1, :name => "Odessa", :population => 2500000}}
|
45
45
|
@region = {:region => {:id => 1, :name => "Odessa region", :population => 4500000}}
|
46
|
+
@street = {:street => {:id => 1, :name => "Deribasovskaya", :population => 2300}}
|
46
47
|
ActiveResource::HttpMock.respond_to do |mock|
|
47
48
|
|
48
49
|
|
@@ -59,6 +60,9 @@ class ActiveResourceResponseTest < Test::Unit::TestCase
|
|
59
60
|
mock.get "/cities/1/population.json", {}, {:count => 2500000}.to_json, 200, {"X-total"=>'1'}
|
60
61
|
mock.get "/cities/1.json", {}, @city.to_json, 200, {"X-total"=>'1'}
|
61
62
|
mock.get "/cities.json", {}, [@city].to_json, 200, {"X-total"=>'1'}
|
63
|
+
mock.get "/streets.json", {}, [@street].to_json, 200, {"X-total"=>'1'}
|
64
|
+
mock.get "/streets/1/city.json", {}, @city.to_json, 200, {"X-total"=>'1'}
|
65
|
+
mock.get "/streets/1.json", {}, @street.to_json, 200, {"X-total"=>'1'}
|
62
66
|
end
|
63
67
|
|
64
68
|
|
@@ -150,4 +154,20 @@ class ActiveResourceResponseTest < Test::Unit::TestCase
|
|
150
154
|
end
|
151
155
|
|
152
156
|
|
157
|
+
def test_remove_method
|
158
|
+
|
159
|
+
street = Street.find(:first)
|
160
|
+
assert !(street.respond_to?(ActiveResourceResponseBase.http_response_method))
|
161
|
+
city = Street.find(1).get('city')
|
162
|
+
assert !(city.respond_to?(ActiveResourceResponseBase.http_response_method))
|
163
|
+
#test if all ok in base class
|
164
|
+
country = Country.find(1)
|
165
|
+
assert country.respond_to?(Country.http_response_method)
|
166
|
+
region = Region.find(1)
|
167
|
+
assert region.respond_to?(ActiveResourceResponseBase.http_response_method)
|
168
|
+
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
|
153
173
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeresource-response
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activeresource
|
16
|
-
requirement: &
|
16
|
+
requirement: &70232052579580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70232052579580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: test-unit
|
27
|
-
requirement: &
|
27
|
+
requirement: &70232052578700 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70232052578700
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70232052577620 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70232052577620
|
47
47
|
description: ! 'This gem adds possibility to access http response object from result
|
48
48
|
of ActiveResource::Base find method '
|
49
49
|
email:
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- test/fixtures/city.rb
|
72
72
|
- test/fixtures/country.rb
|
73
73
|
- test/fixtures/region.rb
|
74
|
+
- test/fixtures/street.rb
|
74
75
|
homepage: http://fivell.github.com/activeresource-response/
|
75
76
|
licenses: []
|
76
77
|
post_install_message:
|
@@ -102,3 +103,4 @@ test_files:
|
|
102
103
|
- test/fixtures/city.rb
|
103
104
|
- test/fixtures/country.rb
|
104
105
|
- test/fixtures/region.rb
|
106
|
+
- test/fixtures/street.rb
|