From b95d6e84b00bd926b1118f6a820eca7a870b8c35 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sat, 14 Aug 2010 02:13:00 -0300 Subject: Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;) --- activeresource/CHANGELOG | 22 +++++++++++----------- activeresource/README.rdoc | 8 ++++---- activeresource/lib/active_resource/http_mock.rb | 8 ++++---- activeresource/lib/active_resource/validations.rb | 16 ++++++++-------- .../test/cases/base/custom_methods_test.rb | 10 +++++----- activeresource/test/cases/validations_test.rb | 2 +- activeresource/test/connection_test.rb | 4 ++-- 7 files changed, 35 insertions(+), 35 deletions(-) (limited to 'activeresource') diff --git a/activeresource/CHANGELOG b/activeresource/CHANGELOG index 8fa1b0b4b3..605f751c5c 100644 --- a/activeresource/CHANGELOG +++ b/activeresource/CHANGELOG @@ -87,7 +87,7 @@ ActiveResource::HttpMock.respond_to do |mock| mock.get "/people/1.xml", {}, "David" end - + Now: ActiveResource::HttpMock.respond_to.get "/people/1.xml", {}, "David" @@ -97,14 +97,14 @@ self.site = "http://app/" self.format = :json end - + person = Person.find(1) # => GET http://app/people/1.json person.name = "David" person.save # => PUT http://app/people/1.json {name: "David"} - + Person.format = :xml person.name = "Mary" - person.save # => PUT http://app/people/1.json Mary + person.save # => PUT http://app/people/1.json Mary * Fix reload error when path prefix is used. #8727 [Ian Warshak] @@ -133,7 +133,7 @@ class Project headers['X-Token'] = 'foo' end - + # makes the GET request with the custom X-Token header Project.find(:all) @@ -156,7 +156,7 @@ end assert_kind_of Highrise::Comment, Note.find(1).comments.first - + * Added load_attributes_from_response as a way of loading attributes from other responses than just create [David Heinemeier Hansson] @@ -248,8 +248,8 @@ d * Basic validation support [Rick Olson] - Parses the xml response of ActiveRecord::Errors#to_xml with a similar interface to ActiveRecord::Errors. - + Parses the xml response of ActiveRecord::Errors#to_xml with a similar interface to ActiveRecord::Errors. + render :xml => @person.errors.to_xml, :status => '400 Validation Error' * Deep hashes are converted into collections of resources. [Jeremy Kemper] @@ -267,12 +267,12 @@ d * Add support for specifying prefixes. * Allow overriding of element_name, collection_name, and primary key * Provide simpler HTTP mock interface for testing - + # rails routing code map.resources :posts do |post| post.resources :comments end - + # ActiveResources class Post < ActiveResource::Base self.site = "http://37s.sunrise.i:3000/" @@ -281,7 +281,7 @@ d class Comment < ActiveResource::Base self.site = "http://37s.sunrise.i:3000/posts/:post_id/" end - + @post = Post.find 5 @comments = Comment.find :all, :post_id => @post.id diff --git a/activeresource/README.rdoc b/activeresource/README.rdoc index ad58eaf5fd..02398d969d 100644 --- a/activeresource/README.rdoc +++ b/activeresource/README.rdoc @@ -9,7 +9,7 @@ in ActionController::Resources). Active Resource attempts to provide a coherent wrapper object-relational mapping for REST web services. It follows the same philosophy as Active Record, in that one of its prime aims -is to reduce the amount of code needed to map to these resources. This is made possible +is to reduce the amount of code needed to map to these resources. This is made possible by relying on a number of code- and protocol-based conventions that make it easy for Active Resource to infer complex relations and structures. These conventions are outlined in detail in the documentation for ActiveResource::Base. @@ -41,14 +41,14 @@ records. But rather than dealing directly with a database record, you're dealin ==== Protocol -Active Resource is built on a standard XML format for requesting and submitting resources over HTTP. It mirrors the RESTful routing +Active Resource is built on a standard XML format for requesting and submitting resources over HTTP. It mirrors the RESTful routing built into Action Controller but will also work with any other REST service that properly implements the protocol. REST uses HTTP, but unlike "typical" web applications, it makes use of all the verbs available in the HTTP specification: * GET requests are used for finding and retrieving resources. * POST requests are used to create new resources. * PUT requests are used to update existing resources. -* DELETE requests are used to delete resources. +* DELETE requests are used to delete resources. For more information on how this protocol works with Active Resource, see the ActiveResource::Base documentation; for more general information on REST web services, see the article here[http://en.wikipedia.org/wiki/Representational_State_Transfer]. @@ -111,7 +111,7 @@ as the id of the ARes object. # is submitted as the body on # # POST http://api.people.com:3000/people.xml - # + # # when save is called on a new Person object. An empty response is # is expected with a 'Location' header value: # diff --git a/activeresource/lib/active_resource/http_mock.rb b/activeresource/lib/active_resource/http_mock.rb index 75425c01c0..a98af88a37 100644 --- a/activeresource/lib/active_resource/http_mock.rb +++ b/activeresource/lib/active_resource/http_mock.rb @@ -41,7 +41,7 @@ module ActiveResource # mock.delete "/people/1.xml", {}, nil, 200 # end # end - # + # # def test_get_matz # person = Person.find(1) # assert_equal "Matz", person.name @@ -77,13 +77,13 @@ module ActiveResource # mock.get "/people/1.xml", {}, @matz # end # end - # + # # def test_should_request_remote_service # person = Person.find(1) # Call the remote service - # + # # # This request object has the same HTTP method and path as declared by the mock # expected_request = ActiveResource::Request.new(:get, "/people/1.xml") - # + # # # Assert that the mock received, and responded to, the expected request from the model # assert ActiveResource::HttpMock.requests.include?(expected_request) # end diff --git a/activeresource/lib/active_resource/validations.rb b/activeresource/lib/active_resource/validations.rb index 026d81e44a..adceac2f61 100644 --- a/activeresource/lib/active_resource/validations.rb +++ b/activeresource/lib/active_resource/validations.rb @@ -6,7 +6,7 @@ module ActiveResource end # Active Resource validation is reported to and from this object, which is used by Base#save - # to determine whether the object in a valid state to be saved. See usage example in Validations. + # to determine whether the object in a valid state to be saved. See usage example in Validations. class Errors < ActiveModel::Errors # Grabs errors from an array of messages (like ActiveRecord::Validations) # The second parameter directs the errors cache to be cleared (default) @@ -20,7 +20,7 @@ module ActiveResource add humanized_attributes[attr_name], message[(attr_name.size + 1)..-1] end end - + self[:base] << message if attr_message.nil? end end @@ -37,15 +37,15 @@ module ActiveResource from_array array, save_cache end end - + # Module to support validation and errors with Active Resource objects. The module overrides - # Base#save to rescue ActiveResource::ResourceInvalid exceptions and parse the errors returned - # in the web service response. The module also adds an +errors+ collection that mimics the interface + # Base#save to rescue ActiveResource::ResourceInvalid exceptions and parse the errors returned + # in the web service response. The module also adds an +errors+ collection that mimics the interface # of the errors provided by ActiveRecord::Errors. # # ==== Example # - # Consider a Person resource on the server requiring both a +first_name+ and a +last_name+ with a + # Consider a Person resource on the server requiring both a +first_name+ and a +last_name+ with a # validates_presence_of :first_name, :last_name declaration in the model: # # person = Person.new(:first_name => "Jim", :last_name => "") @@ -55,7 +55,7 @@ module ActiveResource # person.errors.count # => 1 # person.errors.full_messages # => ["Last name can't be empty"] # person.errors[:last_name] # => ["can't be empty"] - # person.last_name = "Halpert" + # person.last_name = "Halpert" # person.save # => true (and person is now saved to the remote service) # module Validations @@ -118,7 +118,7 @@ module ActiveResource # also any errors returned from the remote system the last time we # saved. # Remote errors can only be cleared by trying to re-save the resource. - # + # # ==== Examples # my_person = Person.create(params[:person]) # my_person.valid? diff --git a/activeresource/test/cases/base/custom_methods_test.rb b/activeresource/test/cases/base/custom_methods_test.rb index 2d81549a65..459d33c24f 100644 --- a/activeresource/test/cases/base/custom_methods_test.rb +++ b/activeresource/test/cases/base/custom_methods_test.rb @@ -35,7 +35,7 @@ class CustomMethodsTest < Test::Unit::TestCase Person.user = nil Person.password = nil - end + end def teardown ActiveResource::HttpMock.reset! @@ -64,13 +64,13 @@ class CustomMethodsTest < Test::Unit::TestCase # Test GET against an element URL assert_equal Person.find(1).get(:shallow), {"id" => 1, "name" => 'Matz'} assert_equal Person.find(1).get(:deep), {"id" => 1, "name" => 'Matz', "other" => 'other'} - + # Test PUT against an element URL assert_equal ActiveResource::Response.new("", 204, {}), Person.find(1).put(:promote, {:position => 'Manager'}, 'body') - + # Test DELETE against an element URL assert_equal ActiveResource::Response.new("", 200, {}), Person.find(1).delete(:deactivate) - + # With nested resources assert_equal StreetAddress.find(1, :params => { :person_id => 1 }).get(:deep), { "id" => 1, "street" => '12345 Street', "zip" => "27519" } @@ -87,7 +87,7 @@ class CustomMethodsTest < Test::Unit::TestCase # Test POST against a nested collection URL addy = StreetAddress.new(:street => '123 Test Dr.', :person_id => 1) - assert_equal ActiveResource::Response.new({ :street => '12345 Street' }.to_xml(:root => 'address'), + assert_equal ActiveResource::Response.new({ :street => '12345 Street' }.to_xml(:root => 'address'), 201, {'Location' => '/people/1/addresses/2.xml'}), addy.post(:link) diff --git a/activeresource/test/cases/validations_test.rb b/activeresource/test/cases/validations_test.rb index 82546424f2..87c5c8c611 100644 --- a/activeresource/test/cases/validations_test.rb +++ b/activeresource/test/cases/validations_test.rb @@ -24,7 +24,7 @@ class ValidationsTest < ActiveModel::TestCase assert p.save, "should have saved after fixing the validation, but had: #{p.errors.inspect}" end - + def test_fails_save! p = new_project(:name => nil) assert_raise(ActiveResource::ResourceInvalid) { p.save! } diff --git a/activeresource/test/connection_test.rb b/activeresource/test/connection_test.rb index a2744d7531..1b4b61899d 100644 --- a/activeresource/test/connection_test.rb +++ b/activeresource/test/connection_test.rb @@ -140,12 +140,12 @@ class ConnectionTest < Test::Unit::TestCase assert_equal "Matz", people[0]["name"] assert_equal "David", people[1]["name"] end - + def test_get_collection_single people = @conn.get("/people_single_elements.xml") assert_equal "Matz", people[0]["name"] end - + def test_get_collection_empty people = @conn.get("/people_empty_elements.xml") assert_equal [], people -- cgit v1.2.3