From 508fba9e070e09f0a321f2dd7acf7938967468f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 21 Jul 2010 12:51:14 +0200 Subject: Add .rdoc extension to README files. --- activeresource/README | 165 --------------------------------------------- activeresource/README.rdoc | 165 +++++++++++++++++++++++++++++++++++++++++++++ activeresource/Rakefile | 2 +- 3 files changed, 166 insertions(+), 166 deletions(-) delete mode 100644 activeresource/README create mode 100644 activeresource/README.rdoc (limited to 'activeresource') diff --git a/activeresource/README b/activeresource/README deleted file mode 100644 index 127ac5b4a9..0000000000 --- a/activeresource/README +++ /dev/null @@ -1,165 +0,0 @@ -= Active Resource - -Active Resource (ARes) connects business objects and Representational State Transfer (REST) -web services. It implements object-relational mapping for REST web services to provide transparent -proxying capabilities between a client (ActiveResource) and a RESTful service (which is provided by Simply RESTful routing -in ActionController::Resources). - -== Philosophy - -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 -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. - -== Overview - -Model classes are mapped to remote REST resources by Active Resource much the same way Active Record maps model classes to database -tables. When a request is made to a remote resource, a REST XML request is generated, transmitted, and the result -received and serialized into a usable Ruby object. - -=== Configuration and Usage - -Putting Active Resource to use is very similar to Active Record. It's as simple as creating a model class -that inherits from ActiveResource::Base and providing a site class variable to it: - - class Person < ActiveResource::Base - self.site = "http://api.people.com:3000/" - end - -Now the Person class is REST enabled and can invoke REST services very similarly to how Active Record invokes -lifecycle methods that operate against a persistent store. - - # Find a person with id = 1 - ryan = Person.find(1) - Person.exists?(1) #=> true - -As you can see, the methods are quite similar to Active Record's methods for dealing with database -records. But rather than dealing directly with a database record, you're dealing with HTTP resources (which may or may not be database records). - -==== Protocol - -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. - -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]. - -==== Find - -Find requests use the GET method and expect the XML form of whatever resource/resources is/are being requested. So, -for a request for a single element, the XML of that item is expected in response: - - # Expects a response of - # - # 1value1.. - # - # for GET http://api.people.com:3000/people/1.xml - # - ryan = Person.find(1) - -The XML document that is received is used to build a new object of type Person, with each -XML element becoming an attribute on the object. - - ryan.is_a? Person #=> true - ryan.attribute1 #=> 'value1' - -Any complex element (one that contains other elements) becomes its own object: - - # With this response: - # - # 1value1value2 - # - # for GET http://api.people.com:3000/people/1.xml - # - ryan = Person.find(1) - ryan.complex #=> - ryan.complex.attribute2 #=> 'value2' - -Collections can also be requested in a similar fashion - - # Expects a response of - # - # - # 1Ryan - # 2Jim - # - # - # for GET http://api.people.com:3000/people.xml - # - people = Person.find(:all) - people.first #=> 'Ryan' ...> - people.last #=> 'Jim' ...> - -==== Create - -Creating a new resource submits the XML form of the resource as the body of the request and expects -a 'Location' header in the response with the RESTful URL location of the newly created resource. The -id of the newly created resource is parsed out of the Location response header and automatically set -as the id of the ARes object. - - # Ryan - # - # 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: - # - # Response (201): Location: http://api.people.com:3000/people/2 - # - ryan = Person.new(:first => 'Ryan') - ryan.new? #=> true - ryan.save #=> true - ryan.new? #=> false - ryan.id #=> 2 - -==== Update - -'save' is also used to update an existing resource - and follows the same protocol as creating a resource -with the exception that no response headers are needed - just an empty response when the update on the -server side was successful. - - # Ryan - # - # is submitted as the body on - # - # PUT http://api.people.com:3000/people/1.xml - # - # when save is called on an existing Person object. An empty response is - # is expected with code (204) - # - ryan = Person.find(1) - ryan.first #=> 'Ryan' - ryan.first = 'Rizzle' - ryan.save #=> true - -==== Delete - -Destruction of a resource can be invoked as a class and instance method of the resource. - - # A request is made to - # - # DELETE http://api.people.com:3000/people/1.xml - # - # for both of these forms. An empty response with - # is expected with response code (200) - # - ryan = Person.find(1) - ryan.destroy #=> true - ryan.exists? #=> false - Person.delete(2) #=> true - Person.exists?(2) #=> false - - -You can find more usage information in the ActiveResource::Base documentation. - diff --git a/activeresource/README.rdoc b/activeresource/README.rdoc new file mode 100644 index 0000000000..127ac5b4a9 --- /dev/null +++ b/activeresource/README.rdoc @@ -0,0 +1,165 @@ += Active Resource + +Active Resource (ARes) connects business objects and Representational State Transfer (REST) +web services. It implements object-relational mapping for REST web services to provide transparent +proxying capabilities between a client (ActiveResource) and a RESTful service (which is provided by Simply RESTful routing +in ActionController::Resources). + +== Philosophy + +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 +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. + +== Overview + +Model classes are mapped to remote REST resources by Active Resource much the same way Active Record maps model classes to database +tables. When a request is made to a remote resource, a REST XML request is generated, transmitted, and the result +received and serialized into a usable Ruby object. + +=== Configuration and Usage + +Putting Active Resource to use is very similar to Active Record. It's as simple as creating a model class +that inherits from ActiveResource::Base and providing a site class variable to it: + + class Person < ActiveResource::Base + self.site = "http://api.people.com:3000/" + end + +Now the Person class is REST enabled and can invoke REST services very similarly to how Active Record invokes +lifecycle methods that operate against a persistent store. + + # Find a person with id = 1 + ryan = Person.find(1) + Person.exists?(1) #=> true + +As you can see, the methods are quite similar to Active Record's methods for dealing with database +records. But rather than dealing directly with a database record, you're dealing with HTTP resources (which may or may not be database records). + +==== Protocol + +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. + +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]. + +==== Find + +Find requests use the GET method and expect the XML form of whatever resource/resources is/are being requested. So, +for a request for a single element, the XML of that item is expected in response: + + # Expects a response of + # + # 1value1.. + # + # for GET http://api.people.com:3000/people/1.xml + # + ryan = Person.find(1) + +The XML document that is received is used to build a new object of type Person, with each +XML element becoming an attribute on the object. + + ryan.is_a? Person #=> true + ryan.attribute1 #=> 'value1' + +Any complex element (one that contains other elements) becomes its own object: + + # With this response: + # + # 1value1value2 + # + # for GET http://api.people.com:3000/people/1.xml + # + ryan = Person.find(1) + ryan.complex #=> + ryan.complex.attribute2 #=> 'value2' + +Collections can also be requested in a similar fashion + + # Expects a response of + # + # + # 1Ryan + # 2Jim + # + # + # for GET http://api.people.com:3000/people.xml + # + people = Person.find(:all) + people.first #=> 'Ryan' ...> + people.last #=> 'Jim' ...> + +==== Create + +Creating a new resource submits the XML form of the resource as the body of the request and expects +a 'Location' header in the response with the RESTful URL location of the newly created resource. The +id of the newly created resource is parsed out of the Location response header and automatically set +as the id of the ARes object. + + # Ryan + # + # 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: + # + # Response (201): Location: http://api.people.com:3000/people/2 + # + ryan = Person.new(:first => 'Ryan') + ryan.new? #=> true + ryan.save #=> true + ryan.new? #=> false + ryan.id #=> 2 + +==== Update + +'save' is also used to update an existing resource - and follows the same protocol as creating a resource +with the exception that no response headers are needed - just an empty response when the update on the +server side was successful. + + # Ryan + # + # is submitted as the body on + # + # PUT http://api.people.com:3000/people/1.xml + # + # when save is called on an existing Person object. An empty response is + # is expected with code (204) + # + ryan = Person.find(1) + ryan.first #=> 'Ryan' + ryan.first = 'Rizzle' + ryan.save #=> true + +==== Delete + +Destruction of a resource can be invoked as a class and instance method of the resource. + + # A request is made to + # + # DELETE http://api.people.com:3000/people/1.xml + # + # for both of these forms. An empty response with + # is expected with response code (200) + # + ryan = Person.find(1) + ryan.destroy #=> true + ryan.exists? #=> false + Person.delete(2) #=> true + Person.exists?(2) #=> false + + +You can find more usage information in the ActiveResource::Base documentation. + diff --git a/activeresource/Rakefile b/activeresource/Rakefile index 04b08ed8cb..b1e5ca91d3 100644 --- a/activeresource/Rakefile +++ b/activeresource/Rakefile @@ -35,7 +35,7 @@ Rake::RDocTask.new { |rdoc| rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object' rdoc.options << '--charset' << 'utf-8' rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo' - rdoc.rdoc_files.include('README', 'CHANGELOG') + rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG') rdoc.rdoc_files.include('lib/**/*.rb') rdoc.rdoc_files.exclude('lib/activeresource.rb') } -- cgit v1.2.3 From d16c5cc99b4ac5a5517b643aabb3b31bf0f0f1b6 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 22 Jul 2010 01:00:01 +0800 Subject: Change some missing README -> README.rdoc --- activeresource/activeresource.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activeresource') diff --git a/activeresource/activeresource.gemspec b/activeresource/activeresource.gemspec index ca74c0dd7d..a71168722b 100644 --- a/activeresource/activeresource.gemspec +++ b/activeresource/activeresource.gemspec @@ -14,12 +14,12 @@ Gem::Specification.new do |s| s.homepage = 'http://www.rubyonrails.org' s.rubyforge_project = 'activeresource' - s.files = Dir['CHANGELOG', 'README', 'examples/**/*', 'lib/**/*'] + s.files = Dir['CHANGELOG', 'README.rdoc', 'examples/**/*', 'lib/**/*'] s.require_path = 'lib' s.has_rdoc = true - s.extra_rdoc_files = %w( README ) - s.rdoc_options.concat ['--main', 'README'] + s.extra_rdoc_files = %w( README.rdoc ) + s.rdoc_options.concat ['--main', 'README.rdoc'] s.add_dependency('activesupport', version) s.add_dependency('activemodel', version) -- cgit v1.2.3 From 30df88ae06182a72ae7f959dce8d8df4a7adb99a Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 21 Jul 2010 21:00:11 -0300 Subject: These tests are trusting in the order of the elements so use OrderedHash instead of Hash --- activeresource/test/cases/base_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activeresource') diff --git a/activeresource/test/cases/base_test.rb b/activeresource/test/cases/base_test.rb index 4d036d73cc..a176c037d5 100644 --- a/activeresource/test/cases/base_test.rb +++ b/activeresource/test/cases/base_test.rb @@ -6,6 +6,7 @@ require "fixtures/sound" require "fixtures/beast" require "fixtures/proxy" require 'active_support/json' +require 'active_support/ordered_hash' require 'active_support/core_ext/hash/conversions' require 'mocha' @@ -555,7 +556,7 @@ class BaseTest < Test::Unit::TestCase assert_equal '/people.xml?name[]=bob&name[]=your+uncle%2Bme&name[]=&name[]=false', Person.collection_path(:name => ['bob', 'your uncle+me', nil, false]) - assert_equal '/people.xml?struct[a][]=2&struct[a][]=1&struct[b]=fred', Person.collection_path(:struct => {:a => [2,1], 'b' => 'fred'}) + assert_equal '/people.xml?struct[a][]=2&struct[a][]=1&struct[b]=fred', Person.collection_path(:struct => ActiveSupport::OrderedHash[:a, [2,1], 'b', 'fred']) end def test_custom_element_path -- cgit v1.2.3 From b378b19430a4d2ee54cbe7f1935fbd4f8b3b331b Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 22 Jul 2010 18:56:00 -0300 Subject: Makes Rakefile activate rdoc >= 2.5.9 Signed-off-by: Xavier Noria --- activeresource/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activeresource') diff --git a/activeresource/Rakefile b/activeresource/Rakefile index b1e5ca91d3..43b2d15916 100644 --- a/activeresource/Rakefile +++ b/activeresource/Rakefile @@ -1,4 +1,4 @@ -gem 'rdoc', '= 2.2' +gem 'rdoc', '>= 2.5.9' require 'rdoc' require 'rake' require 'rake/testtask' -- cgit v1.2.3 From b50635a59f7d2fab2cdba348c4169536fbbb77f4 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 23 Jul 2010 21:11:29 +0200 Subject: update Rakefiles for RDoc 2.5 --- activeresource/Rakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'activeresource') diff --git a/activeresource/Rakefile b/activeresource/Rakefile index 43b2d15916..63444be1d0 100644 --- a/activeresource/Rakefile +++ b/activeresource/Rakefile @@ -2,7 +2,7 @@ gem 'rdoc', '>= 2.5.9' require 'rdoc' require 'rake' require 'rake/testtask' -require 'rake/rdoctask' +require 'rdoc/task' require 'rake/packagetask' require 'rake/gempackagetask' @@ -29,12 +29,12 @@ end # Generate the RDoc documentation -Rake::RDocTask.new { |rdoc| +RDoc::Task.new { |rdoc| rdoc.rdoc_dir = 'doc' rdoc.title = "Active Resource -- Object-oriented REST services" - rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object' + rdoc.options << '-f' << 'horo' + rdoc.options << '--main' << 'README.rdoc' rdoc.options << '--charset' << 'utf-8' - rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo' rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG') rdoc.rdoc_files.include('lib/**/*.rb') rdoc.rdoc_files.exclude('lib/activeresource.rb') -- cgit v1.2.3 From b0b9bf320409b66c6c6b680371aca590297cd4cc Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sun, 25 Jul 2010 18:12:20 -0300 Subject: Object#returning removed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activeresource/lib/active_resource/base.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'activeresource') diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 6c494a8bcc..1557e090e1 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -7,7 +7,6 @@ require 'active_support/core_ext/module/attr_accessor_with_default' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/module/aliasing' require 'active_support/core_ext/object/blank' -require 'active_support/core_ext/object/misc' require 'active_support/core_ext/object/to_query' require 'active_support/core_ext/object/duplicable' require 'set' -- cgit v1.2.3 From dcb7832ed51b2aeb2ea7386e2f07fcb5d7eb0c6d Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 26 Jul 2010 00:01:23 +0200 Subject: APIs for individual components are no longer published --- activeresource/Rakefile | 6 ------ 1 file changed, 6 deletions(-) (limited to 'activeresource') diff --git a/activeresource/Rakefile b/activeresource/Rakefile index 63444be1d0..2145f1017c 100644 --- a/activeresource/Rakefile +++ b/activeresource/Rakefile @@ -80,9 +80,3 @@ task :release => :package do Rake::Gemcutter::Tasks.new(spec).define Rake::Task['gem:push'].invoke end - -desc "Publish the API documentation" -task :pdoc => [:rdoc] do - require 'rake/contrib/sshpublisher' - Rake::SshDirPublisher.new("rails@api.rubyonrails.org", "public_html/ar", "doc").upload -end -- cgit v1.2.3 From 0e969bdaf8ff2e3384350687aa0b583f94d6dfbc Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Thu, 22 Jul 2010 08:42:02 +0200 Subject: fix escaping id and parameters in path [#5137 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activeresource/lib/active_resource/base.rb | 4 ++-- activeresource/test/cases/base_test.rb | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'activeresource') diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 1557e090e1..72ad2f5872 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -577,7 +577,7 @@ module ActiveResource # Default value is site.path. def prefix=(value = '/') # Replace :placeholders with '#{embedded options[:lookups]}' - prefix_call = value.gsub(/:\w+/) { |key| "\#{options[#{key}]}" } + prefix_call = value.gsub(/:\w+/) { |key| "\#{URI.escape options[#{key}].to_s}" } # Clear prefix parameters in case they have been cached @prefix_parameters = nil @@ -622,7 +622,7 @@ module ActiveResource # def element_path(id, prefix_options = {}, query_options = nil) prefix_options, query_options = split_options(prefix_options) if query_options.nil? - "#{prefix(prefix_options)}#{collection_name}/#{id}.#{format.extension}#{query_string(query_options)}" + "#{prefix(prefix_options)}#{collection_name}/#{URI.escape id.to_s}.#{format.extension}#{query_string(query_options)}" end # Gets the new element path for REST resources. diff --git a/activeresource/test/cases/base_test.rb b/activeresource/test/cases/base_test.rb index a176c037d5..91b375681b 100644 --- a/activeresource/test/cases/base_test.rb +++ b/activeresource/test/cases/base_test.rb @@ -563,6 +563,7 @@ class BaseTest < Test::Unit::TestCase assert_equal '/people/1/addresses/1.xml', StreetAddress.element_path(1, :person_id => 1) assert_equal '/people/1/addresses/1.xml', StreetAddress.element_path(1, 'person_id' => 1) assert_equal '/people/Greg/addresses/1.xml', StreetAddress.element_path(1, 'person_id' => 'Greg') + assert_equal '/people/ann%20mary/addresses/ann%20mary.xml', StreetAddress.element_path(:'ann mary', 'person_id' => 'ann mary') end def test_module_element_path -- cgit v1.2.3 From 856fc4bbc379b330d11702adbc2b26850dca6206 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 26 Jul 2010 12:52:34 -0500 Subject: Prep for RC --- activeresource/CHANGELOG | 5 +++++ activeresource/lib/active_resource/version.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'activeresource') diff --git a/activeresource/CHANGELOG b/activeresource/CHANGELOG index 2b2092b9fe..8fa1b0b4b3 100644 --- a/activeresource/CHANGELOG +++ b/activeresource/CHANGELOG @@ -1,3 +1,8 @@ +*Rails 3.0.0 [release candidate] (July 26th, 2010)* + +* No material changes + + *Rails 3.0.0 [beta 4] (June 8th, 2010)* * JSON: set Base.include_root_in_json = true to include a root value in the JSON: {"post": {"title": ...}}. Mirrors the Active Record option. [Santiago Pastorino] diff --git a/activeresource/lib/active_resource/version.rb b/activeresource/lib/active_resource/version.rb index 198e77a3d1..43c00e9cf1 100644 --- a/activeresource/lib/active_resource/version.rb +++ b/activeresource/lib/active_resource/version.rb @@ -3,7 +3,7 @@ module ActiveResource MAJOR = 3 MINOR = 0 TINY = 0 - BUILD = "beta4" + BUILD = "rc" STRING = [MAJOR, MINOR, TINY, BUILD].join('.') end -- cgit v1.2.3 From 59693c4c49cce5e4cf53eb54e42e3da07a98467e Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Tue, 27 Jul 2010 09:55:33 +0200 Subject: fix loading of different elements in array then int and string [#5036 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activeresource/lib/active_resource/base.rb | 6 +++--- activeresource/test/cases/base/load_test.rb | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'activeresource') diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 72ad2f5872..62420725ad 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -1222,10 +1222,10 @@ module ActiveResource when Array resource = find_or_create_resource_for_collection(key) value.map do |attrs| - if attrs.is_a?(String) || attrs.is_a?(Numeric) - attrs.duplicable? ? attrs.dup : attrs - else + if attrs.is_a?(Hash) resource.new(attrs) + else + attrs.duplicable? ? attrs.dup : attrs end end when Hash diff --git a/activeresource/test/cases/base/load_test.rb b/activeresource/test/cases/base/load_test.rb index 7745a9439b..228dc36d9b 100644 --- a/activeresource/test/cases/base/load_test.rb +++ b/activeresource/test/cases/base/load_test.rb @@ -47,6 +47,8 @@ class BaseLoadTest < Test::Unit::TestCase { :id => 1, :name => 'Willamette' }, { :id => 2, :name => 'Columbia', :rafted_by => @matz }], :postal_codes => [ 97018, 1234567890 ], + :dates => [ Time.now ], + :votes => [ true, false, true ], :places => [ "Columbia City", "Unknown" ]}}} @person = Person.new @@ -149,6 +151,16 @@ class BaseLoadTest < Test::Unit::TestCase assert_kind_of Array, places assert_kind_of String, places.first assert_equal @deep[:street][:state][:places].first, places.first + + dates = state.dates + assert_kind_of Array, dates + assert_kind_of Time, dates.first + assert_equal @deep[:street][:state][:dates].first, dates.first + + votes = state.votes + assert_kind_of Array, votes + assert_kind_of TrueClass, votes.first + assert_equal @deep[:street][:state][:votes].first, votes.first end def test_nested_collections_within_the_same_namespace -- cgit v1.2.3 From 4f7565c4de1f877547a6b901a8416b18c613acc9 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 9 Aug 2010 15:14:00 +0200 Subject: adds missing requires for Object#try --- activeresource/lib/active_resource/http_mock.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activeresource') diff --git a/activeresource/lib/active_resource/http_mock.rb b/activeresource/lib/active_resource/http_mock.rb index f192c53b4f..75425c01c0 100644 --- a/activeresource/lib/active_resource/http_mock.rb +++ b/activeresource/lib/active_resource/http_mock.rb @@ -123,7 +123,11 @@ module ActiveResource # def post(path, body, headers) # request = ActiveResource::Request.new(:post, path, body, headers) # self.class.requests << request - # self.class.responses.assoc(request).try(:second) || raise(InvalidRequestError.new("No response recorded for #{request}")) + # if response = self.class.responses.assoc(request) + # response[1] + # else + # raise InvalidRequestError.new("No response recorded for #{request}") + # end # end module_eval <<-EOE, __FILE__, __LINE__ + 1 def #{method}(path, #{'body, ' if has_body}headers) -- cgit v1.2.3