aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-12-07 03:05:03 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-12-07 03:05:03 +0100
commit8f1c229571b4db8dda144bf6eaa193799309e817 (patch)
tree592710207a614428d5cb809f6e13c8b546b58969 /activeresource
parent601e40e744f44fe8819be100a8c472ea161d13ab (diff)
parent9eca588bdfbb41f6b48477025d1cd8eea4a38296 (diff)
downloadrails-8f1c229571b4db8dda144bf6eaa193799309e817.tar.gz
rails-8f1c229571b4db8dda144bf6eaa193799309e817.tar.bz2
rails-8f1c229571b4db8dda144bf6eaa193799309e817.zip
Merge commit 'mainstream/master'
Conflicts: actionmailer/lib/action_mailer/base.rb actionpack/lib/action_controller/base.rb actionpack/lib/action_controller/mime_type.rb railties/doc/guides/html/activerecord_validations_callbacks.html railties/doc/guides/html/caching_with_rails.html railties/doc/guides/html/command_line.html railties/doc/guides/html/configuring.html railties/doc/guides/html/creating_plugins.html railties/doc/guides/html/finders.html railties/doc/guides/html/routing_outside_in.html railties/doc/guides/source/activerecord_validations_callbacks.txt railties/doc/guides/source/caching_with_rails.txt railties/doc/guides/source/command_line.txt railties/doc/guides/source/creating_plugins/acts_as_yaffle.txt railties/doc/guides/source/creating_plugins/controllers.txt railties/doc/guides/source/creating_plugins/core_ext.txt railties/doc/guides/source/creating_plugins/helpers.txt railties/doc/guides/source/creating_plugins/index.txt railties/doc/guides/source/creating_plugins/migration_generator.txt railties/doc/guides/source/creating_plugins/models.txt railties/doc/guides/source/creating_plugins/odds_and_ends.txt railties/doc/guides/source/creating_plugins/routes.txt railties/doc/guides/source/finders.txt railties/doc/guides/source/routing_outside_in.txt railties/doc/guides/source/testing_rails_applications.txt
Diffstat (limited to 'activeresource')
-rw-r--r--activeresource/Rakefile2
-rw-r--r--activeresource/lib/active_resource/base.rb1
-rw-r--r--activeresource/lib/active_resource/version.rb4
-rw-r--r--activeresource/test/base_test.rb86
-rw-r--r--activeresource/test/format_test.rb28
5 files changed, 61 insertions, 60 deletions
diff --git a/activeresource/Rakefile b/activeresource/Rakefile
index ef6efd4903..ef99caea67 100644
--- a/activeresource/Rakefile
+++ b/activeresource/Rakefile
@@ -65,7 +65,7 @@ spec = Gem::Specification.new do |s|
s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
end
- s.add_dependency('activesupport', '= 2.2.0' + PKG_BUILD)
+ s.add_dependency('activesupport', '= 2.3.0' + PKG_BUILD)
s.require_path = 'lib'
s.autorequire = 'active_resource'
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index 303b09ba76..4192fab525 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -706,6 +706,7 @@ module ActiveResource
def new?
id.nil?
end
+ alias :new_record? :new?
# Gets the <tt>\id</tt> attribute of the resource.
def id
diff --git a/activeresource/lib/active_resource/version.rb b/activeresource/lib/active_resource/version.rb
index 3747ffc63c..c420ac813e 100644
--- a/activeresource/lib/active_resource/version.rb
+++ b/activeresource/lib/active_resource/version.rb
@@ -1,8 +1,8 @@
module ActiveResource
module VERSION #:nodoc:
MAJOR = 2
- MINOR = 2
- TINY = 1
+ MINOR = 3
+ TINY = 0
STRING = [MAJOR, MINOR, TINY].join('.')
end
diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb
index bb08098683..d37a6d4ed2 100644
--- a/activeresource/test/base_test.rb
+++ b/activeresource/test/base_test.rb
@@ -688,39 +688,39 @@ class BaseTest < Test::Unit::TestCase
end
def test_clone
- matz = Person.find(1)
- matz_c = matz.clone
- assert matz_c.new?
- matz.attributes.each do |k, v|
- assert_equal v, matz_c.send(k) if k != Person.primary_key
- end
- end
-
- def test_nested_clone
- addy = StreetAddress.find(1, :params => {:person_id => 1})
- addy_c = addy.clone
- assert addy_c.new?
- addy.attributes.each do |k, v|
- assert_equal v, addy_c.send(k) if k != StreetAddress.primary_key
- end
- assert_equal addy.prefix_options, addy_c.prefix_options
- end
-
- def test_complex_clone
- matz = Person.find(1)
- matz.address = StreetAddress.find(1, :params => {:person_id => matz.id})
- matz.non_ar_hash = {:not => "an ARes instance"}
- matz.non_ar_arr = ["not", "ARes"]
- matz_c = matz.clone
- assert matz_c.new?
- assert_raises(NoMethodError) {matz_c.address}
- assert_equal matz.non_ar_hash, matz_c.non_ar_hash
- assert_equal matz.non_ar_arr, matz_c.non_ar_arr
-
- # Test that actual copy, not just reference copy
- matz.non_ar_hash[:not] = "changed"
- assert_not_equal matz.non_ar_hash, matz_c.non_ar_hash
- end
+ matz = Person.find(1)
+ matz_c = matz.clone
+ assert matz_c.new?
+ matz.attributes.each do |k, v|
+ assert_equal v, matz_c.send(k) if k != Person.primary_key
+ end
+ end
+
+ def test_nested_clone
+ addy = StreetAddress.find(1, :params => {:person_id => 1})
+ addy_c = addy.clone
+ assert addy_c.new?
+ addy.attributes.each do |k, v|
+ assert_equal v, addy_c.send(k) if k != StreetAddress.primary_key
+ end
+ assert_equal addy.prefix_options, addy_c.prefix_options
+ end
+
+ def test_complex_clone
+ matz = Person.find(1)
+ matz.address = StreetAddress.find(1, :params => {:person_id => matz.id})
+ matz.non_ar_hash = {:not => "an ARes instance"}
+ matz.non_ar_arr = ["not", "ARes"]
+ matz_c = matz.clone
+ assert matz_c.new?
+ assert_raises(NoMethodError) {matz_c.address}
+ assert_equal matz.non_ar_hash, matz_c.non_ar_hash
+ assert_equal matz.non_ar_arr, matz_c.non_ar_arr
+
+ # Test that actual copy, not just reference copy
+ matz.non_ar_hash[:not] = "changed"
+ assert_not_equal matz.non_ar_hash, matz_c.non_ar_hash
+ end
def test_update
matz = Person.find(:first)
@@ -811,9 +811,9 @@ class BaseTest < Test::Unit::TestCase
def test_exists_with_redefined_to_param
Person.module_eval do
alias_method :original_to_param_exists, :to_param
- def to_param
- name
- end
+ def to_param
+ name
+ end
end
# Class method.
@@ -828,13 +828,13 @@ class BaseTest < Test::Unit::TestCase
# Nested instance method.
assert StreetAddress.find(1, :params => { :person_id => Person.find('Greg').to_param }).exists?
- ensure
- # revert back to original
- Person.module_eval do
- # save the 'new' to_param so we don't get a warning about discarding the method
- alias_method :exists_to_param, :to_param
- alias_method :to_param, :original_to_param_exists
- end
+ ensure
+ # revert back to original
+ Person.module_eval do
+ # save the 'new' to_param so we don't get a warning about discarding the method
+ alias_method :exists_to_param, :to_param
+ alias_method :to_param, :original_to_param_exists
+ end
end
def test_to_xml
diff --git a/activeresource/test/format_test.rb b/activeresource/test/format_test.rb
index a564ee01b5..c3733e13d8 100644
--- a/activeresource/test/format_test.rb
+++ b/activeresource/test/format_test.rb
@@ -15,7 +15,7 @@ class FormatTest < Test::Unit::TestCase
assert_equal 'Accept', header_name
headers_names = [ActiveResource::Connection::HTTP_FORMAT_HEADER_NAMES[:put], ActiveResource::Connection::HTTP_FORMAT_HEADER_NAMES[:post]]
- headers_names.each{|header_name| assert_equal 'Content-Type', header_name}
+ headers_names.each{ |name| assert_equal 'Content-Type', name }
end
def test_formats_on_single_element
@@ -85,20 +85,20 @@ class FormatTest < Test::Unit::TestCase
end
def test_serialization_of_nested_resource
- address = { :street => '12345 Street' }
- person = { :name=> 'Rus', :address => address}
+ address = { :street => '12345 Street' }
+ person = { :name=> 'Rus', :address => address}
- [:json, :xml].each do |format|
- encoded_person = ActiveResource::Formats[format].encode(person)
- assert_match /12345 Street/, encoded_person
- remote_person = Person.new(person.update({:address => StreetAddress.new(address)}))
- assert_kind_of StreetAddress, remote_person.address
- using_format(Person, format) do
- ActiveResource::HttpMock.respond_to.post "/people.#{format}", {'Content-Type' => ActiveResource::Formats[format].mime_type}, encoded_person, 201, {'Location' => "/people/5.#{format}"}
- remote_person.save
- end
- end
- end
+ [:json, :xml].each do |format|
+ encoded_person = ActiveResource::Formats[format].encode(person)
+ assert_match(/12345 Street/, encoded_person)
+ remote_person = Person.new(person.update({:address => StreetAddress.new(address)}))
+ assert_kind_of StreetAddress, remote_person.address
+ using_format(Person, format) do
+ ActiveResource::HttpMock.respond_to.post "/people.#{format}", {'Content-Type' => ActiveResource::Formats[format].mime_type}, encoded_person, 201, {'Location' => "/people/5.#{format}"}
+ remote_person.save
+ end
+ end
+ end
private
def using_format(klass, mime_type_reference)