Changeset 8827
- Timestamp:
- 02/09/08 22:21:55 (1 year ago)
- Files:
-
- trunk/activeresource/CHANGELOG (modified) (1 diff)
- trunk/activeresource/lib/active_resource/base.rb (modified) (1 diff)
- trunk/activeresource/lib/active_resource/connection.rb (modified) (1 diff)
- trunk/activeresource/lib/active_resource/http_mock.rb (modified) (2 diffs)
- trunk/activeresource/test/base_test.rb (modified) (1 diff)
- trunk/activeresource/test/connection_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activeresource/CHANGELOG
r8528 r8827 1 1 *SVN* 2 3 * Use HEAD instead of GET in exists? [bscofield] 2 4 3 5 * Fix small documentation typo. Closes #10670 [l.guidi] trunk/activeresource/lib/active_resource/base.rb
r8528 r8827 437 437 # # => false 438 438 def exists?(id, options = {}) 439 id && !find_single(id, options).nil? 439 if id 440 prefix_options, query_options = split_options(options[:params]) 441 path = element_path(id, prefix_options, query_options) 442 response = connection.head(path, headers) 443 response.code == 200 444 end 445 # id && !find_single(id, options).nil? 440 446 rescue ActiveResource::ResourceNotFound 441 447 false trunk/activeresource/lib/active_resource/connection.rb
r8390 r8827 102 102 end 103 103 104 # Execute a HEAD request. 105 # Used to ... 106 def head(path, headers= {}) 107 request(:head, path, build_request_headers(headers)) 108 end 109 104 110 105 111 private trunk/activeresource/lib/active_resource/http_mock.rb
r8462 r8827 10 10 end 11 11 12 for method in [ :post, :put, :get, :delete ]12 for method in [ :post, :put, :get, :delete, :head ] 13 13 module_eval <<-EOE, __FILE__, __LINE__ 14 14 def #{method}(path, request_headers = {}, body = nil, status = 200, response_headers = {}) … … 57 57 end 58 58 59 for method in [ :get, :delete ]59 for method in [ :get, :delete, :head ] 60 60 module_eval <<-EOE, __FILE__, __LINE__ 61 61 def #{method}(path, headers) trunk/activeresource/test/base_test.rb
r8566 r8827 37 37 mock.delete "/people//addresses/1.xml", {}, nil, 404 38 38 mock.post "/people//addresses.xml", {}, nil, 404 39 mock.head "/people/1.xml", {}, nil, 200 40 mock.head "/people/99.xml", {}, nil, 404 41 mock.head "/people/1/addresses/1.xml", {}, nil, 200 42 mock.head "/people/1/addresses/2.xml", {}, nil, 404 43 mock.head "/people/2/addresses/1.xml", {}, nil, 404 39 44 end 40 45 end trunk/activeresource/test/connection_test.rb
r8566 r8827 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 … … 106 107 end 107 108 109 def test_head 110 response = @conn.head("/people/1.xml") 111 assert response.body.blank? 112 assert_equal 200, response.code 113 end 114 108 115 def test_get_with_header 109 116 david = @conn.get("/people/2.xml", @header)