activeresource-response 1.2.0 → 1.3.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/activeresource-response.gemspec +1 -0
- data/lib/active_resource_response/response_method.rb +1 -1
- data/lib/active_resource_response/version.rb +1 -1
- data/test/active_resource_response_test.rb +12 -2
- data/test/fixtures/status.rb +26 -0
- data/test/test_helper.rb +1 -0
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6001c653f7f44c7c8216111159eda9a0c007d50caf2cd6ac79787419f197b690
|
4
|
+
data.tar.gz: b03396852f3125a076238f45c2bab5be01ccc504500dab658c6bb139fd1196b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb0a148ded6376a68e1aee1f72a1330a114e993ca4e886de26cce43f66e6da04ce8fe9e3640f212be42a8164ef0af40c7f88afae594bfacca749347ca1f469f5
|
7
|
+
data.tar.gz: e8b3dce231e5ec7f39105636bbc00173965a8939d1fbd94dd7ada22d296a535fc4886bb676d1b82386a1808e9fc29a1e2bca3ff236ebc520e3c357044c124748
|
data/.travis.yml
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.add_dependency "jruby-openssl" if RUBY_PLATFORM == "java"
|
18
18
|
s.add_development_dependency "minitest" , '~> 5.3'
|
19
19
|
s.add_development_dependency 'rake', '~> 10'
|
20
|
+
s.add_development_dependency 'byebug'
|
20
21
|
|
21
22
|
|
22
23
|
s.files = `git ls-files | sed '/.gitignore/d'`.split("\n")
|
@@ -59,7 +59,7 @@ module ActiveResourceResponse
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def wrap_result(result)
|
62
|
-
result = SimpleDelegator.new(result)
|
62
|
+
result = SimpleDelegator.new(result) if result.frozen?
|
63
63
|
result.instance_variable_set(:@http_response, connection.http_response)
|
64
64
|
result.singleton_class.send(:define_method, self.http_response_method) do
|
65
65
|
@http_response
|
@@ -21,7 +21,6 @@
|
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
#++
|
23
23
|
require_relative 'test_helper'
|
24
|
-
|
25
24
|
class ActiveResourceResponseTest < MiniTest::Test
|
26
25
|
|
27
26
|
|
@@ -38,7 +37,8 @@ class ActiveResourceResponseTest < MiniTest::Test
|
|
38
37
|
mock.get "/regions/1.json", {}, @region.to_json, 200, {"X-total"=>'1'}
|
39
38
|
mock.get "/regions/population.json", {}, {:count => 45000000}.to_json, 200, {"X-total"=>'1'}
|
40
39
|
mock.get "/regions/cities.json", {}, [@city].to_json, 200, {"X-total"=>'2'}
|
41
|
-
mock.get "/countries/1.json", {},
|
40
|
+
mock.get "/countries/1/statuses.json", {}, nil, 404
|
41
|
+
mock.get "/countries/1.json", {}, @country.to_json, 200, {"X-total"=>'1', 'Set-Cookie'=>['path=/; expires=Tue, 20-Jan-2015 15:03:14 GMT; foo=bar; bar=foo']}
|
42
42
|
mock.get "/countries/1/population.json", {}, {:count => 45000000}.to_json, 200, {"X-total"=>'1'}
|
43
43
|
mock.post "/countries.json", {}, @country_create_error.to_json, 422, {"X-total"=>'1'}
|
44
44
|
mock.get "/countries/1/cities.json", {}, [@city].to_json, 200, {"X-total"=>'1'}
|
@@ -109,6 +109,16 @@ class ActiveResourceResponseTest < MiniTest::Test
|
|
109
109
|
assert_equal country.http.headers[:x_total], ['1']
|
110
110
|
end
|
111
111
|
|
112
|
+
def test_get_headers_from_find_when_404_custom_get
|
113
|
+
Country.find(1).get(:statuses) rescue nil
|
114
|
+
assert_equal Country.http_response.code, 404
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_get_headers_from_find_when_404_custom_prefix
|
118
|
+
Status.all params: { country_id: 1 }
|
119
|
+
assert_equal Status.http_response.code, 404
|
120
|
+
end
|
121
|
+
|
112
122
|
def test_get_cookies
|
113
123
|
country = Country.find(1)
|
114
124
|
assert_equal country.http.cookies['foo'], 'bar'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012 Igor Fedoronchuk
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
class Status < ActiveResourceResponseBase
|
24
|
+
self.element_name = 'status'
|
25
|
+
self.prefix += 'countries/:country_id/'
|
26
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeresource-response
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Fedoronchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|
@@ -58,6 +58,20 @@ dependencies:
|
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '10'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: byebug
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
61
75
|
description: 'This gem adds possibility to access http response object from result
|
62
76
|
of ActiveResource::Base find method '
|
63
77
|
email:
|
@@ -85,6 +99,7 @@ files:
|
|
85
99
|
- test/fixtures/city.rb
|
86
100
|
- test/fixtures/country.rb
|
87
101
|
- test/fixtures/region.rb
|
102
|
+
- test/fixtures/status.rb
|
88
103
|
- test/fixtures/street.rb
|
89
104
|
- test/lint_test.rb
|
90
105
|
- test/test_helper.rb
|
@@ -108,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
123
|
version: '0'
|
109
124
|
requirements: []
|
110
125
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.7.
|
126
|
+
rubygems_version: 2.7.9
|
112
127
|
signing_key:
|
113
128
|
specification_version: 4
|
114
129
|
summary: activeresource extension
|
@@ -117,6 +132,7 @@ test_files:
|
|
117
132
|
- test/fixtures/city.rb
|
118
133
|
- test/fixtures/country.rb
|
119
134
|
- test/fixtures/region.rb
|
135
|
+
- test/fixtures/status.rb
|
120
136
|
- test/fixtures/street.rb
|
121
137
|
- test/lint_test.rb
|
122
138
|
- test/test_helper.rb
|