activerecord 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- data/CHANGELOG +55 -0
- data/lib/active_record.rb +5 -7
- data/lib/active_record/aggregations.rb +2 -1
- data/lib/active_record/associations.rb +2 -1
- data/lib/active_record/associations/association_proxy.rb +4 -0
- data/lib/active_record/associations/has_many_association.rb +6 -4
- data/lib/active_record/associations/has_one_association.rb +7 -2
- data/lib/active_record/base.rb +36 -5
- data/lib/active_record/connection_adapters/abstract_adapter.rb +58 -10
- data/lib/active_record/connection_adapters/mysql_adapter.rb +30 -9
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +3 -2
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +17 -0
- data/lib/active_record/fixtures.rb +108 -31
- data/lib/active_record/migration.rb +94 -0
- data/lib/active_record/reflection.rb +10 -4
- data/lib/active_record/validations.rb +76 -42
- data/rakefile +2 -2
- data/test/aaa_create_tables_test.rb +4 -4
- data/test/aggregations_test.rb +18 -4
- data/test/associations_test.rb +2 -1
- data/test/base_test.rb +10 -0
- data/test/fixtures/company.rb +1 -1
- data/test/fixtures/customer.rb +17 -0
- data/test/fixtures/customers.yml +1 -0
- data/test/fixtures/db_definitions/db2.sql +1 -0
- data/test/fixtures/db_definitions/mysql.sql +1 -0
- data/test/fixtures/db_definitions/oci.sql +1 -0
- data/test/fixtures/db_definitions/postgresql.sql +1 -0
- data/test/fixtures/db_definitions/sqlite.sql +2 -1
- data/test/fixtures/db_definitions/sqlserver.sql +1 -0
- data/test/fixtures/fixture_database.sqlite +0 -0
- data/test/fixtures/fixture_database_2.sqlite +0 -0
- data/test/fixtures/migrations/1_people_have_last_names.rb +9 -0
- data/test/fixtures/migrations/2_we_need_reminders.rb +12 -0
- data/test/fixtures_test.rb +30 -1
- data/test/migration_mysql.rb +104 -0
- data/test/reflection_test.rb +8 -4
- data/test/validations_test.rb +38 -0
- metadata +9 -4
    
        data/rakefile
    CHANGED
    
    | @@ -8,7 +8,7 @@ require 'rake/contrib/rubyforgepublisher' | |
| 8 8 |  | 
| 9 9 | 
             
            PKG_BUILD     = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
         | 
| 10 10 | 
             
            PKG_NAME      = 'activerecord'
         | 
| 11 | 
            -
            PKG_VERSION   = '1. | 
| 11 | 
            +
            PKG_VERSION   = '1.8.0' + PKG_BUILD
         | 
| 12 12 | 
             
            PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
         | 
| 13 13 |  | 
| 14 14 | 
             
            PKG_FILES = FileList[
         | 
| @@ -117,7 +117,7 @@ spec = Gem::Specification.new do |s| | |
| 117 117 | 
             
                s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
         | 
| 118 118 | 
             
              end
         | 
| 119 119 |  | 
| 120 | 
            -
              s.add_dependency('activesupport', '= 1.0. | 
| 120 | 
            +
              s.add_dependency('activesupport', '= 1.0.1' + PKG_BUILD)
         | 
| 121 121 |  | 
| 122 122 | 
             
              s.files.delete "test/fixtures/fixture_database.sqlite"
         | 
| 123 123 | 
             
              s.files.delete "test/fixtures/fixture_database_2.sqlite"
         | 
| @@ -45,13 +45,13 @@ class CreateTablesTest < Test::Unit::TestCase | |
| 45 45 |  | 
| 46 46 | 
             
              def test_table_creation
         | 
| 47 47 | 
             
                adapter_name = ActiveRecord::Base.connection.adapter_name.downcase
         | 
| 48 | 
            -
                run_sql_file ActiveRecord::Base.connection, " | 
| 49 | 
            -
                run_sql_file ActiveRecord::Base.connection, " | 
| 48 | 
            +
                run_sql_file ActiveRecord::Base.connection, "#{File.dirname(__FILE__)}/fixtures/db_definitions/" + adapter_name + ".drop.sql"
         | 
| 49 | 
            +
                run_sql_file ActiveRecord::Base.connection, "#{File.dirname(__FILE__)}/fixtures/db_definitions/" + adapter_name + ".sql"
         | 
| 50 50 |  | 
| 51 51 | 
             
                # Now do the same thing with the connection used by multiple_db_test.rb
         | 
| 52 52 | 
             
                adapter_name = Course.retrieve_connection.adapter_name.downcase
         | 
| 53 | 
            -
                run_sql_file Course.retrieve_connection, " | 
| 54 | 
            -
                run_sql_file Course.retrieve_connection, " | 
| 53 | 
            +
                run_sql_file Course.retrieve_connection, "#{File.dirname(__FILE__)}/fixtures/db_definitions/" + adapter_name + "2.drop.sql"
         | 
| 54 | 
            +
                run_sql_file Course.retrieve_connection, "#{File.dirname(__FILE__)}/fixtures/db_definitions/" + adapter_name + "2.sql"
         | 
| 55 55 |  | 
| 56 56 | 
             
                assert_equal 1,1
         | 
| 57 57 | 
             
              end
         | 
    
        data/test/aggregations_test.rb
    CHANGED
    
    | @@ -2,10 +2,7 @@ require 'abstract_unit' | |
| 2 2 | 
             
            require 'fixtures/customer'
         | 
| 3 3 |  | 
| 4 4 | 
             
            class AggregationsTest < Test::Unit::TestCase
         | 
| 5 | 
            -
               | 
| 6 | 
            -
                @customers = create_fixtures "customers"
         | 
| 7 | 
            -
                @david = Customer.find(1)
         | 
| 8 | 
            -
              end
         | 
| 5 | 
            +
              fixtures :customers
         | 
| 9 6 |  | 
| 10 7 | 
             
              def test_find_single_value_object
         | 
| 11 8 | 
             
                assert_equal 50, @david.balance.amount
         | 
| @@ -30,4 +27,21 @@ class AggregationsTest < Test::Unit::TestCase | |
| 30 27 | 
             
                @david.balance = Money.new(100)
         | 
| 31 28 | 
             
                assert_raises(TypeError) {  @david.balance.instance_eval { @amount = 20 } }
         | 
| 32 29 | 
             
              end  
         | 
| 30 | 
            +
              
         | 
| 31 | 
            +
              def test_inferred_mapping
         | 
| 32 | 
            +
                assert_equal "35.544623640962634", @david.gps_location.latitude
         | 
| 33 | 
            +
                assert_equal "-105.9309951055148", @david.gps_location.longitude
         | 
| 34 | 
            +
                
         | 
| 35 | 
            +
                @david.gps_location = GpsLocation.new("39x-110")
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                assert_equal "39", @david.gps_location.latitude
         | 
| 38 | 
            +
                assert_equal "-110", @david.gps_location.longitude
         | 
| 39 | 
            +
                
         | 
| 40 | 
            +
                @david.save
         | 
| 41 | 
            +
                
         | 
| 42 | 
            +
                @david.reload
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                assert_equal "39", @david.gps_location.latitude
         | 
| 45 | 
            +
                assert_equal "-110", @david.gps_location.longitude
         | 
| 46 | 
            +
              end
         | 
| 33 47 | 
             
            end
         | 
    
        data/test/associations_test.rb
    CHANGED
    
    | @@ -94,7 +94,8 @@ class HasOneAssociationsTest < Test::Unit::TestCase | |
| 94 94 | 
             
                @signals37.account = nil
         | 
| 95 95 | 
             
                @signals37.save
         | 
| 96 96 | 
             
                assert_nil @signals37.account
         | 
| 97 | 
            -
                 | 
| 97 | 
            +
                # account is dependent, therefore is destroyed when reference to owner is lost
         | 
| 98 | 
            +
                assert_raises(ActiveRecord::RecordNotFound) { Account.find(old_account_id) } 
         | 
| 98 99 | 
             
              end
         | 
| 99 100 |  | 
| 100 101 | 
             
              def test_dependence
         | 
    
        data/test/base_test.rb
    CHANGED
    
    | @@ -216,6 +216,16 @@ class BasicsTest < Test::Unit::TestCase | |
| 216 216 | 
             
                assert_equal("initialized from attributes", topic.title)
         | 
| 217 217 | 
             
              end
         | 
| 218 218 |  | 
| 219 | 
            +
              def test_initialize_with_invalid_attribute
         | 
| 220 | 
            +
                begin
         | 
| 221 | 
            +
                  topic = Topic.new({ "title" => "test", 
         | 
| 222 | 
            +
                    "last_read(1i)" => "2005", "last_read(2i)" => "2", "last_read(3i)" => "31"})
         | 
| 223 | 
            +
                rescue ActiveRecord::MultiparameterAssignmentErrors => ex
         | 
| 224 | 
            +
                  assert_equal(1, ex.errors.size)
         | 
| 225 | 
            +
                  assert_equal("last_read", ex.errors[0].attribute)
         | 
| 226 | 
            +
                end
         | 
| 227 | 
            +
              end
         | 
| 228 | 
            +
              
         | 
| 219 229 | 
             
              def test_load
         | 
| 220 230 | 
             
                topics = Topic.find_all nil, "id"    
         | 
| 221 231 | 
             
                assert_equal(2, topics.size)
         | 
    
        data/test/fixtures/company.rb
    CHANGED
    
    | @@ -6,7 +6,7 @@ end | |
| 6 6 |  | 
| 7 7 |  | 
| 8 8 | 
             
            class Firm < Company
         | 
| 9 | 
            -
              has_many :clients, :order => "id", :dependent => true
         | 
| 9 | 
            +
              has_many :clients, :order => "id", :dependent => true, :counter_sql => "SELECT COUNT(*) FROM companies WHERE firm_id = 1 AND (type = 'Client' OR type = 'SpecialClient' OR type = 'VerySpecialClient' )"
         | 
| 10 10 | 
             
              has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC"
         | 
| 11 11 | 
             
              has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id"
         | 
| 12 12 | 
             
              has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
         | 
    
        data/test/fixtures/customer.rb
    CHANGED
    
    | @@ -1,6 +1,7 @@ | |
| 1 1 | 
             
            class Customer < ActiveRecord::Base
         | 
| 2 2 | 
             
              composed_of :address, :mapping => [ %w(address_street street), %w(address_city city), %w(address_country country) ]
         | 
| 3 3 | 
             
              composed_of :balance, :class_name => "Money", :mapping => %w(balance amount)
         | 
| 4 | 
            +
              composed_of :gps_location
         | 
| 4 5 | 
             
            end
         | 
| 5 6 |  | 
| 6 7 | 
             
            class Address
         | 
| @@ -27,4 +28,20 @@ class Money | |
| 27 28 | 
             
              def exchange_to(other_currency)
         | 
| 28 29 | 
             
                Money.new((amount * EXCHANGE_RATES["#{currency}_TO_#{other_currency}"]).floor, other_currency)
         | 
| 29 30 | 
             
              end
         | 
| 31 | 
            +
            end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            class GpsLocation
         | 
| 34 | 
            +
              attr_reader :gps_location
         | 
| 35 | 
            +
              
         | 
| 36 | 
            +
              def initialize(gps_location)
         | 
| 37 | 
            +
                @gps_location = gps_location
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
              
         | 
| 40 | 
            +
              def latitude
         | 
| 41 | 
            +
                gps_location.split("x").first
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
              
         | 
| 44 | 
            +
              def longitude
         | 
| 45 | 
            +
                gps_location.split("x").last
         | 
| 46 | 
            +
              end
         | 
| 30 47 | 
             
            end
         | 
    
        data/test/fixtures/customers.yml
    CHANGED
    
    
| @@ -53,7 +53,8 @@ CREATE TABLE 'customers' ( | |
| 53 53 | 
             
              'balance' INTEGER DEFAULT 0,
         | 
| 54 54 | 
             
              'address_street' TEXT DEFAULT NULL,
         | 
| 55 55 | 
             
              'address_city' TEXT DEFAULT NULL,
         | 
| 56 | 
            -
              'address_country' TEXT DEFAULT NULL
         | 
| 56 | 
            +
              'address_country' TEXT DEFAULT NULL,
         | 
| 57 | 
            +
              'gps_location' TEXT DEFAULT NULL
         | 
| 57 58 | 
             
            );
         | 
| 58 59 |  | 
| 59 60 | 
             
            CREATE TABLE 'movies' (
         | 
| Binary file | 
| Binary file | 
    
        data/test/fixtures_test.rb
    CHANGED
    
    | @@ -105,5 +105,34 @@ class FixturesTest < Test::Unit::TestCase | |
| 105 105 | 
             
              def test_empty_csv_fixtures
         | 
| 106 106 | 
             
                assert_not_nil Fixtures.new( Account.connection, "accounts", File.dirname(__FILE__) + "/fixtures/naked/csv/accounts")
         | 
| 107 107 | 
             
              end
         | 
| 108 | 
            -
             | 
| 108 | 
            +
            end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
             | 
| 111 | 
            +
            class FixturesWithoutInstantiationTest < Test::Unit::TestCase
         | 
| 112 | 
            +
              self.use_instantiated_fixtures = false
         | 
| 113 | 
            +
              fixtures :topics, :developers, :accounts
         | 
| 114 | 
            +
             | 
| 115 | 
            +
              def test_without_complete_instantiation
         | 
| 116 | 
            +
                assert_nil @topics
         | 
| 117 | 
            +
                assert_nil @first
         | 
| 118 | 
            +
              end
         | 
| 119 | 
            +
             | 
| 120 | 
            +
              def test_fixtures_from_root_yml_without_instantiation
         | 
| 121 | 
            +
                assert_nil @unknown
         | 
| 122 | 
            +
              end
         | 
| 123 | 
            +
            end
         | 
| 124 | 
            +
             | 
| 125 | 
            +
             | 
| 126 | 
            +
            class TransactionalFixturesTest < Test::Unit::TestCase
         | 
| 127 | 
            +
              self.use_transactional_fixtures = true
         | 
| 128 | 
            +
              fixtures :topics
         | 
| 129 | 
            +
             | 
| 130 | 
            +
              def test_destroy
         | 
| 131 | 
            +
                assert_not_nil @first
         | 
| 132 | 
            +
                @first.destroy
         | 
| 133 | 
            +
              end
         | 
| 134 | 
            +
             | 
| 135 | 
            +
              def test_destroy_just_kidding
         | 
| 136 | 
            +
                assert_not_nil @first
         | 
| 137 | 
            +
              end
         | 
| 109 138 | 
             
            end
         | 
| @@ -0,0 +1,104 @@ | |
| 1 | 
            +
            require 'abstract_unit'
         | 
| 2 | 
            +
            require 'fixtures/person'
         | 
| 3 | 
            +
            require File.dirname(__FILE__) + '/fixtures/migrations/1_people_have_last_names'
         | 
| 4 | 
            +
            require File.dirname(__FILE__) + '/fixtures/migrations/2_we_need_reminders'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            class Reminder < ActiveRecord::Base; end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            class MigrationTest < Test::Unit::TestCase
         | 
| 9 | 
            +
              def setup
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def teardown
         | 
| 13 | 
            +
                ActiveRecord::Base.connection.initialize_schema_information
         | 
| 14 | 
            +
                ActiveRecord::Base.connection.update "UPDATE schema_info SET version = 0"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                Reminder.connection.drop_table("reminders") rescue nil
         | 
| 17 | 
            +
                Reminder.reset_column_information
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                Person.connection.remove_column("people", "last_name") rescue nil
         | 
| 20 | 
            +
                Person.reset_column_information
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              def test_add_remove_single_field
         | 
| 24 | 
            +
                assert !Person.column_methods_hash.include?(:last_name)
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                PeopleHaveLastNames.up
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                Person.reset_column_information
         | 
| 29 | 
            +
                assert Person.column_methods_hash.include?(:last_name)
         | 
| 30 | 
            +
                
         | 
| 31 | 
            +
                PeopleHaveLastNames.down
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                Person.reset_column_information
         | 
| 34 | 
            +
                assert !Person.column_methods_hash.include?(:last_name)
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              def test_add_table
         | 
| 38 | 
            +
                assert_raises(ActiveRecord::StatementInvalid) { Reminder.column_methods_hash }
         | 
| 39 | 
            +
                
         | 
| 40 | 
            +
                WeNeedReminders.up
         | 
| 41 | 
            +
                
         | 
| 42 | 
            +
                assert Reminder.create("content" => "hello world", "remind_at" => Time.now)
         | 
| 43 | 
            +
                assert "hello world", Reminder.find_first
         | 
| 44 | 
            +
                
         | 
| 45 | 
            +
                WeNeedReminders.down
         | 
| 46 | 
            +
                assert_raises(ActiveRecord::StatementInvalid) { Reminder.find_first }
         | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
              def test_migrator
         | 
| 50 | 
            +
                assert !Person.column_methods_hash.include?(:last_name)
         | 
| 51 | 
            +
                assert_raises(ActiveRecord::StatementInvalid) { Reminder.column_methods_hash }
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/fixtures/migrations/')
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                assert_equal 2, ActiveRecord::Migrator.current_version
         | 
| 56 | 
            +
                Person.reset_column_information
         | 
| 57 | 
            +
                assert Person.column_methods_hash.include?(:last_name)
         | 
| 58 | 
            +
                assert Reminder.create("content" => "hello world", "remind_at" => Time.now)
         | 
| 59 | 
            +
                assert "hello world", Reminder.find_first
         | 
| 60 | 
            +
             | 
| 61 | 
            +
             | 
| 62 | 
            +
                ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/fixtures/migrations/')
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                assert_equal 0, ActiveRecord::Migrator.current_version
         | 
| 65 | 
            +
                Person.reset_column_information
         | 
| 66 | 
            +
                assert !Person.column_methods_hash.include?(:last_name)
         | 
| 67 | 
            +
                assert_raises(ActiveRecord::StatementInvalid) { Reminder.find_first }
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              def test_migrator_one_up
         | 
| 71 | 
            +
                assert !Person.column_methods_hash.include?(:last_name)
         | 
| 72 | 
            +
                assert_raises(ActiveRecord::StatementInvalid) { Reminder.column_methods_hash }
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/fixtures/migrations/', 1)
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                Person.reset_column_information
         | 
| 77 | 
            +
                assert Person.column_methods_hash.include?(:last_name)
         | 
| 78 | 
            +
                assert_raises(ActiveRecord::StatementInvalid) { Reminder.column_methods_hash }
         | 
| 79 | 
            +
             | 
| 80 | 
            +
             | 
| 81 | 
            +
                ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/fixtures/migrations/', 2)
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                assert Reminder.create("content" => "hello world", "remind_at" => Time.now)
         | 
| 84 | 
            +
                assert "hello world", Reminder.find_first
         | 
| 85 | 
            +
              end
         | 
| 86 | 
            +
              
         | 
| 87 | 
            +
              def test_migrator_one_down
         | 
| 88 | 
            +
                ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/fixtures/migrations/')
         | 
| 89 | 
            +
                
         | 
| 90 | 
            +
                ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/fixtures/migrations/', 1)
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                Person.reset_column_information
         | 
| 93 | 
            +
                assert Person.column_methods_hash.include?(:last_name)
         | 
| 94 | 
            +
                assert_raises(ActiveRecord::StatementInvalid) { Reminder.column_methods_hash }
         | 
| 95 | 
            +
              end
         | 
| 96 | 
            +
              
         | 
| 97 | 
            +
              def test_migrator_one_up_one_down
         | 
| 98 | 
            +
                ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/fixtures/migrations/', 1)
         | 
| 99 | 
            +
                ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/fixtures/migrations/', 0)
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                assert !Person.column_methods_hash.include?(:last_name)
         | 
| 102 | 
            +
                assert_raises(ActiveRecord::StatementInvalid) { Reminder.column_methods_hash }
         | 
| 103 | 
            +
              end
         | 
| 104 | 
            +
            end
         | 
    
        data/test/reflection_test.rb
    CHANGED
    
    | @@ -42,15 +42,19 @@ class ReflectionTest < Test::Unit::TestCase | |
| 42 42 |  | 
| 43 43 | 
             
              def test_aggregation_reflection
         | 
| 44 44 | 
             
                reflection_for_address = ActiveRecord::Reflection::AggregateReflection.new(
         | 
| 45 | 
            -
                  :address, { :mapping => [ %w(address_street street), %w(address_city city), %w(address_country country) ] }, Customer
         | 
| 45 | 
            +
                  :composed_of, :address, { :mapping => [ %w(address_street street), %w(address_city city), %w(address_country country) ] }, Customer
         | 
| 46 46 | 
             
                )
         | 
| 47 47 |  | 
| 48 48 | 
             
                reflection_for_balance = ActiveRecord::Reflection::AggregateReflection.new(
         | 
| 49 | 
            -
                  :balance, { :class_name => "Money", :mapping => %w(balance amount) }, Customer
         | 
| 49 | 
            +
                  :composed_of, :balance, { :class_name => "Money", :mapping => %w(balance amount) }, Customer
         | 
| 50 | 
            +
                )
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                reflection_for_gps_location = ActiveRecord::Reflection::AggregateReflection.new(
         | 
| 53 | 
            +
                  :composed_of, :gps_location, { }, Customer
         | 
| 50 54 | 
             
                )
         | 
| 51 55 |  | 
| 52 56 | 
             
                assert_equal(
         | 
| 53 | 
            -
                  [ reflection_for_address, reflection_for_balance ],
         | 
| 57 | 
            +
                  [ reflection_for_address, reflection_for_balance, reflection_for_gps_location ],
         | 
| 54 58 | 
             
                  Customer.reflect_on_all_aggregations
         | 
| 55 59 | 
             
                )
         | 
| 56 60 |  | 
| @@ -61,7 +65,7 @@ class ReflectionTest < Test::Unit::TestCase | |
| 61 65 |  | 
| 62 66 | 
             
              def test_association_reflection
         | 
| 63 67 | 
             
                reflection_for_clients = ActiveRecord::Reflection::AssociationReflection.new(
         | 
| 64 | 
            -
                  :clients, { :order => "id", :dependent => true }, Firm
         | 
| 68 | 
            +
                  :has_many, :clients, { :order => "id", :dependent => true }, Firm
         | 
| 65 69 | 
             
                )
         | 
| 66 70 |  | 
| 67 71 | 
             
                assert_equal reflection_for_clients, Firm.reflect_on_association(:clients)
         | 
    
        data/test/validations_test.rb
    CHANGED
    
    | @@ -604,4 +604,42 @@ class ValidationsTest < Test::Unit::TestCase | |
| 604 604 | 
             
                assert !r.valid?
         | 
| 605 605 | 
             
                assert_equal r.errors.on(:topic).first, "This string contains 'single' and \"double\" quotes"
         | 
| 606 606 | 
             
              end
         | 
| 607 | 
            +
             | 
| 608 | 
            +
              def test_validates_numericality_of_with_string
         | 
| 609 | 
            +
                Topic.validates_numericality_of( :replies_count )
         | 
| 610 | 
            +
                ["not a number","42 not a number","0xdeadbeef","00-1","-+019.0","12.12.13.12",nil].each do |v|
         | 
| 611 | 
            +
                    t = Topic.create("title" => "numeric test", "content" => "whatever", "replies_count" => "not a number")
         | 
| 612 | 
            +
                    assert !t.valid?, "#{v} not rejected as a number"
         | 
| 613 | 
            +
                    assert t.errors.on(:replies_count)
         | 
| 614 | 
            +
                end
         | 
| 615 | 
            +
              end
         | 
| 616 | 
            +
             | 
| 617 | 
            +
              def test_validates_numericality_of
         | 
| 618 | 
            +
                Topic.validates_numericality_of( :replies_count )
         | 
| 619 | 
            +
                ["10", "10.0", "10.5", "-10.5", "-0.0001","0090","-090","-090.1"].each do |v|
         | 
| 620 | 
            +
                    t = Topic.create("title" => "numeric test", "content" => "whatever", "replies_count" => v)
         | 
| 621 | 
            +
                    assert t.valid?, "#{v} not recognized as a number"
         | 
| 622 | 
            +
                    # we cannot check this as replies_count is actually an integer field
         | 
| 623 | 
            +
                    #assert_in_delta v.to_f, t.replies_count, 0.0000001
         | 
| 624 | 
            +
                end
         | 
| 625 | 
            +
              end
         | 
| 626 | 
            +
              
         | 
| 627 | 
            +
              def test_validates_numericality_of_int_with_string
         | 
| 628 | 
            +
                Topic.validates_numericality_of( :replies_count, :only_integer => true )
         | 
| 629 | 
            +
                ["not a number","42 not a number","0xdeadbeef","0-1","--3","+-3","+3-1",nil].each do |v|
         | 
| 630 | 
            +
                    t = Topic.create("title" => "numeric test", "content" => "whatever", "replies_count" => v)
         | 
| 631 | 
            +
                    assert !t.valid?, "#{v} not rejected as integer"
         | 
| 632 | 
            +
                    assert t.errors.on(:replies_count)
         | 
| 633 | 
            +
                end
         | 
| 634 | 
            +
              end
         | 
| 635 | 
            +
              
         | 
| 636 | 
            +
              def test_validates_numericality_of_int
         | 
| 637 | 
            +
                Topic.validates_numericality_of( :replies_count, :only_integer => true )
         | 
| 638 | 
            +
                ["42", "+42", "-42", "042", "0042", "-042", 42].each do |v|
         | 
| 639 | 
            +
                    t = Topic.create("title" => "numeric test", "content" => "whatever", "replies_count" => v)
         | 
| 640 | 
            +
                    assert t.valid?, "#{v} not recognized as integer"
         | 
| 641 | 
            +
                    assert_equal v.to_i, t.replies_count
         | 
| 642 | 
            +
                end
         | 
| 643 | 
            +
              end
         | 
| 644 | 
            +
              
         | 
| 607 645 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,10 +1,10 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            -
            rubygems_version: 0.8. | 
| 2 | 
            +
            rubygems_version: 0.8.6
         | 
| 3 3 | 
             
            specification_version: 1
         | 
| 4 4 | 
             
            name: activerecord
         | 
| 5 5 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 6 | 
            -
              version: 1. | 
| 7 | 
            -
            date: 2005- | 
| 6 | 
            +
              version: 1.8.0
         | 
| 7 | 
            +
            date: 2005-03-07
         | 
| 8 8 | 
             
            summary: Implements the ActiveRecord pattern for ORM.
         | 
| 9 9 | 
             
            require_paths: 
         | 
| 10 10 | 
             
              - lib
         | 
| @@ -46,6 +46,7 @@ files: | |
| 46 46 | 
             
              - lib/active_record/deprecated_associations.rb
         | 
| 47 47 | 
             
              - lib/active_record/fixtures.rb
         | 
| 48 48 | 
             
              - lib/active_record/locking.rb
         | 
| 49 | 
            +
              - lib/active_record/migration.rb
         | 
| 49 50 | 
             
              - lib/active_record/observer.rb
         | 
| 50 51 | 
             
              - lib/active_record/reflection.rb
         | 
| 51 52 | 
             
              - lib/active_record/timestamp.rb
         | 
| @@ -93,6 +94,7 @@ files: | |
| 93 94 | 
             
              - test/inheritance_test.rb
         | 
| 94 95 | 
             
              - test/lifecycle_test.rb
         | 
| 95 96 | 
             
              - test/locking_test.rb
         | 
| 97 | 
            +
              - test/migration_mysql.rb
         | 
| 96 98 | 
             
              - test/mixin_test.rb
         | 
| 97 99 | 
             
              - test/modules_test.rb
         | 
| 98 100 | 
             
              - test/multiple_db_test.rb
         | 
| @@ -141,6 +143,7 @@ files: | |
| 141 143 | 
             
              - test/fixtures/entrants.yml
         | 
| 142 144 | 
             
              - test/fixtures/fixture_database.sqlite
         | 
| 143 145 | 
             
              - test/fixtures/fixture_database_2.sqlite
         | 
| 146 | 
            +
              - test/fixtures/migrations
         | 
| 144 147 | 
             
              - test/fixtures/mixin.rb
         | 
| 145 148 | 
             
              - test/fixtures/mixins.yml
         | 
| 146 149 | 
             
              - test/fixtures/movie.rb
         | 
| @@ -191,6 +194,8 @@ files: | |
| 191 194 | 
             
              - test/fixtures/developers_projects/david_action_controller
         | 
| 192 195 | 
             
              - test/fixtures/developers_projects/david_active_record
         | 
| 193 196 | 
             
              - test/fixtures/developers_projects/jamis_active_record
         | 
| 197 | 
            +
              - test/fixtures/migrations/1_people_have_last_names.rb
         | 
| 198 | 
            +
              - test/fixtures/migrations/2_we_need_reminders.rb
         | 
| 194 199 | 
             
              - test/fixtures/naked/csv
         | 
| 195 200 | 
             
              - test/fixtures/naked/yml
         | 
| 196 201 | 
             
              - test/fixtures/naked/csv/accounts.csv
         | 
| @@ -221,5 +226,5 @@ dependencies: | |
| 221 226 | 
             
                    - 
         | 
| 222 227 | 
             
                      - "="
         | 
| 223 228 | 
             
                      - !ruby/object:Gem::Version 
         | 
| 224 | 
            -
                        version: 1.0. | 
| 229 | 
            +
                        version: 1.0.1
         | 
| 225 230 | 
             
                  version: 
         |