activeresource 2.0.5 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activeresource might be problematic. Click here for more details.
- data/CHANGELOG +6 -3
- data/Rakefile +4 -4
- data/lib/active_resource/base.rb +257 -138
- data/lib/active_resource/connection.rb +41 -6
- data/lib/active_resource/custom_methods.rb +7 -7
- data/lib/active_resource/formats/xml_format.rb +1 -1
- data/lib/active_resource/http_mock.rb +76 -5
- data/lib/active_resource/validations.rb +2 -2
- data/lib/active_resource/version.rb +2 -2
- data/test/abstract_unit.rb +13 -1
- data/test/authorization_test.rb +42 -1
- data/test/base/custom_methods_test.rb +6 -3
- data/test/base/equality_test.rb +1 -1
- data/test/base/load_test.rb +1 -1
- data/test/base_errors_test.rb +1 -1
- data/test/base_test.rb +364 -27
- data/test/connection_test.rb +22 -1
- data/test/format_test.rb +2 -2
- data/test/setter_trap.rb +1 -1
- metadata +4 -5
data/test/connection_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'abstract_unit'
|
2
2
|
|
3
3
|
class ConnectionTest < Test::Unit::TestCase
|
4
4
|
ResponseCodeStub = Struct.new(:code)
|
@@ -27,6 +27,7 @@ class ConnectionTest < Test::Unit::TestCase
|
|
27
27
|
mock.delete "/people/2.xml", @header, nil, 200
|
28
28
|
mock.post "/people.xml", {}, nil, 201, 'Location' => '/people/5.xml'
|
29
29
|
mock.post "/members.xml", {}, @header, 201, 'Location' => '/people/6.xml'
|
30
|
+
mock.head "/people/1.xml", {}, nil, 200
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
@@ -100,11 +101,22 @@ class ConnectionTest < Test::Unit::TestCase
|
|
100
101
|
assert_equal site, @conn.site
|
101
102
|
end
|
102
103
|
|
104
|
+
def test_timeout_accessor
|
105
|
+
@conn.timeout = 5
|
106
|
+
assert_equal 5, @conn.timeout
|
107
|
+
end
|
108
|
+
|
103
109
|
def test_get
|
104
110
|
matz = @conn.get("/people/1.xml")
|
105
111
|
assert_equal "Matz", matz["name"]
|
106
112
|
end
|
107
113
|
|
114
|
+
def test_head
|
115
|
+
response = @conn.head("/people/1.xml")
|
116
|
+
assert response.body.blank?
|
117
|
+
assert_equal 200, response.code
|
118
|
+
end
|
119
|
+
|
108
120
|
def test_get_with_header
|
109
121
|
david = @conn.get("/people/2.xml", @header)
|
110
122
|
assert_equal "David", david["name"]
|
@@ -156,6 +168,15 @@ class ConnectionTest < Test::Unit::TestCase
|
|
156
168
|
assert_equal 200, response.code
|
157
169
|
end
|
158
170
|
|
171
|
+
uses_mocha('test_timeout') do
|
172
|
+
def test_timeout
|
173
|
+
@http = mock('new Net::HTTP')
|
174
|
+
@conn.expects(:http).returns(@http)
|
175
|
+
@http.expects(:get).raises(Timeout::Error, 'execution expired')
|
176
|
+
assert_raises(ActiveResource::TimeoutError) { @conn.get('/people_timeout.xml') }
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
159
180
|
protected
|
160
181
|
def assert_response_raises(klass, code)
|
161
182
|
assert_raise(klass, "Expected response code #{code} to raise #{klass}") do
|
data/test/format_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'abstract_unit'
|
2
2
|
require "fixtures/person"
|
3
3
|
|
4
4
|
class FormatTest < Test::Unit::TestCase
|
@@ -80,4 +80,4 @@ class FormatTest < Test::Unit::TestCase
|
|
80
80
|
ensure
|
81
81
|
klass.format = previous_format
|
82
82
|
end
|
83
|
-
end
|
83
|
+
end
|
data/test/setter_trap.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeresource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -9,18 +9,17 @@ autorequire: active_resource
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-05-31 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
17
|
-
type: :runtime
|
18
17
|
version_requirement:
|
19
18
|
version_requirements: !ruby/object:Gem::Requirement
|
20
19
|
requirements:
|
21
20
|
- - "="
|
22
21
|
- !ruby/object:Gem::Version
|
23
|
-
version: 2.0
|
22
|
+
version: 2.1.0
|
24
23
|
version:
|
25
24
|
description: Wraps web resources in model classes that can be manipulated through XML over REST.
|
26
25
|
email: david@loudthinking.com
|
@@ -85,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
84
|
requirements: []
|
86
85
|
|
87
86
|
rubyforge_project: activeresource
|
88
|
-
rubygems_version: 1.
|
87
|
+
rubygems_version: 1.0.1
|
89
88
|
signing_key:
|
90
89
|
specification_version: 2
|
91
90
|
summary: Think Active Record for web resources.
|