From e7a305f08d8f72f81449e1d8934fba31f038ad88 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 2 Jun 2008 21:58:42 -0500 Subject: Fixed Base#exists? to check status code as integer [#299 state:resolved] (Wes Oldenbeuving) --- activeresource/CHANGELOG | 5 +++++ activeresource/lib/active_resource/base.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'activeresource') diff --git a/activeresource/CHANGELOG b/activeresource/CHANGELOG index e124e40dd1..673e20de28 100644 --- a/activeresource/CHANGELOG +++ b/activeresource/CHANGELOG @@ -1,3 +1,8 @@ +*Edge* + +* Fixed Base#exists? to check status code as integer [#299 state:resolved] (Wes Oldenbeuving) + + *2.1.0 (May 31st, 2008)* * Fixed response logging to use length instead of the entire thing (seangeo) [#27] diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 463ee9f1e7..55dacfdf06 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -538,7 +538,7 @@ module ActiveResource prefix_options, query_options = split_options(options[:params]) path = element_path(id, prefix_options, query_options) response = connection.head(path, headers) - response.code == 200 + response.code.to_i == 200 end # id && !find_single(id, options).nil? rescue ActiveResource::ResourceNotFound -- cgit v1.2.3 From 225065709c43dacd57e0904aef2075024ccf2744 Mon Sep 17 00:00:00 2001 From: Luis Hurtado Date: Mon, 9 Jun 2008 21:39:39 -0500 Subject: Fixes parsing deep nested resources from XML. [#380 state:resolved] --- activeresource/lib/active_resource/base.rb | 6 +++- activeresource/test/base_test.rb | 48 ++++++++++++++++++++++++++++++ activeresource/test/fixtures/customer.rb | 3 ++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 activeresource/test/fixtures/customer.rb (limited to 'activeresource') diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 55dacfdf06..347dbb82aa 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -988,7 +988,11 @@ module ActiveResource self.class.const_get(resource_name) end rescue NameError - resource = self.class.const_set(resource_name, Class.new(ActiveResource::Base)) + if self.class.const_defined?(resource_name) + resource = self.class.const_get(resource_name) + else + resource = self.class.const_set(resource_name, Class.new(ActiveResource::Base)) + end resource.prefix = self.class.prefix resource.site = self.class.site resource diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb index 9e2f6c1831..4addd52636 100644 --- a/activeresource/test/base_test.rb +++ b/activeresource/test/base_test.rb @@ -1,5 +1,6 @@ require 'abstract_unit' require "fixtures/person" +require "fixtures/customer" require "fixtures/street_address" require "fixtures/beast" @@ -15,6 +16,37 @@ class BaseTest < Test::Unit::TestCase @people_david = [{ :id => 2, :name => 'David' }].to_xml(:root => 'people') @addresses = [{ :id => 1, :street => '12345 Street' }].to_xml(:root => 'addresses') + # - deep nested resource - + # - Luis (Customer) + # - JK (Customer::Friend) + # - Mateo (Customer::Friend::Brother) + # - Edith (Customer::Friend::Brother::Child) + # - Martha (Customer::Friend::Brother::Child) + # - Felipe (Customer::Friend::Brother) + # - Bryan (Customer::Friend::Brother::Child) + # - Luke (Customer::Friend::Brother::Child) + # - Eduardo (Customer::Friend) + # - Sebas (Customer::Friend::Brother) + # - Andres (Customer::Friend::Brother::Child) + # - Jorge (Customer::Friend::Brother::Child) + # - Elsa (Customer::Friend::Brother) + # - Natacha (Customer::Friend::Brother::Child) + # - Milena (Customer::Friend::Brother) + # + @luis = {:id => 1, :name => 'Luis', + :friends => [{:name => 'JK', + :brothers => [{:name => 'Mateo', + :children => [{:name => 'Edith'},{:name => 'Martha'}]}, + {:name => 'Felipe', + :children => [{:name => 'Bryan'},{:name => 'Luke'}]}]}, + {:name => 'Eduardo', + :brothers => [{:name => 'Sebas', + :children => [{:name => 'Andres'},{:name => 'Jorge'}]}, + {:name => 'Elsa', + :children => [{:name => 'Natacha'}]}, + {:name => 'Milena', + :children => []}]}]}.to_xml(:root => 'customer') + ActiveResource::HttpMock.respond_to do |mock| mock.get "/people/1.xml", {}, @matz mock.get "/people/2.xml", {}, @david @@ -46,6 +78,8 @@ class BaseTest < Test::Unit::TestCase mock.head "/people/1/addresses/2.xml", {}, nil, 404 mock.head "/people/2/addresses/1.xml", {}, nil, 404 mock.head "/people/Greg/addresses/1.xml", {}, nil, 200 + # customer + mock.get "/customers/1.xml", {}, @luis end Person.user = nil @@ -788,4 +822,18 @@ class BaseTest < Test::Unit::TestCase matz = Person.find(1) assert_equal '1', matz.to_param end + + def test_parse_deep_nested_resources + luis = Customer.find(1) + assert_kind_of Customer, luis + luis.friends.each do |friend| + assert_kind_of Customer::Friend, friend + friend.brothers.each do |brother| + assert_kind_of Customer::Friend::Brother, brother + brother.children.each do |child| + assert_kind_of Customer::Friend::Brother::Child, child + end + end + end + end end diff --git a/activeresource/test/fixtures/customer.rb b/activeresource/test/fixtures/customer.rb new file mode 100644 index 0000000000..845d5d11cb --- /dev/null +++ b/activeresource/test/fixtures/customer.rb @@ -0,0 +1,3 @@ +class Customer < ActiveResource::Base + self.site = "http://37s.sunrise.i:3000" +end -- cgit v1.2.3 From 231c2c57092abf4677673b4509c2d29e035e1b96 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 18 Jun 2008 19:56:22 -0700 Subject: Update Rakefiles to connect to wrath as current user. Use ssh config to set a different user. --- activeresource/Rakefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activeresource') diff --git a/activeresource/Rakefile b/activeresource/Rakefile index 9fd0ec4921..220156a718 100644 --- a/activeresource/Rakefile +++ b/activeresource/Rakefile @@ -114,13 +114,13 @@ end desc "Publish the beta gem" task :pgem => [:package] do - Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload - `ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'` + Rake::SshFilePublisher.new("wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload + `ssh wrath.rubyonrails.org './gemupdate.sh'` end desc "Publish the API documentation" task :pdoc => [:rdoc] do - Rake::SshDirPublisher.new("davidhh@wrath.rubyonrails.org", "public_html/ar", "doc").upload + Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ar", "doc").upload end desc "Publish the release files to RubyForge." -- cgit v1.2.3 From c52d9530c34d8b58ded1f11692984080913979df Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 18 Jun 2008 20:12:25 -0700 Subject: Exclude lib/activeresource.rb from rdoc --- activeresource/Rakefile | 1 + 1 file changed, 1 insertion(+) (limited to 'activeresource') diff --git a/activeresource/Rakefile b/activeresource/Rakefile index 220156a718..89901292a5 100644 --- a/activeresource/Rakefile +++ b/activeresource/Rakefile @@ -45,6 +45,7 @@ Rake::RDocTask.new { |rdoc| rdoc.template = "#{ENV['template']}.rb" if ENV['template'] rdoc.rdoc_files.include('README', 'CHANGELOG') rdoc.rdoc_files.include('lib/**/*.rb') + rdoc.rdoc_files.exclude('lib/activeresource.rb') } -- cgit v1.2.3 From a02d672cd7aead8a24e3b10a6b8e12dd91ee0a49 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 22 Jun 2008 10:38:25 -0700 Subject: Horo rdoc template --- activeresource/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activeresource') diff --git a/activeresource/Rakefile b/activeresource/Rakefile index 89901292a5..8c3ad36a02 100644 --- a/activeresource/Rakefile +++ b/activeresource/Rakefile @@ -42,7 +42,7 @@ Rake::RDocTask.new { |rdoc| rdoc.title = "Active Resource -- Object-oriented REST services" rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object' rdoc.options << '--charset' << 'utf-8' - rdoc.template = "#{ENV['template']}.rb" if ENV['template'] + rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo' rdoc.rdoc_files.include('README', 'CHANGELOG') rdoc.rdoc_files.include('lib/**/*.rb') rdoc.rdoc_files.exclude('lib/activeresource.rb') -- cgit v1.2.3