activerecord 1.10.1 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- data/CHANGELOG +187 -19
- data/RUNNING_UNIT_TESTS +11 -0
- data/lib/active_record.rb +3 -1
- data/lib/active_record/acts/list.rb +25 -14
- data/lib/active_record/acts/nested_set.rb +4 -4
- data/lib/active_record/acts/tree.rb +18 -1
- data/lib/active_record/associations.rb +90 -17
- data/lib/active_record/associations/association_collection.rb +44 -5
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +17 -4
- data/lib/active_record/associations/has_many_association.rb +13 -3
- data/lib/active_record/associations/has_one_association.rb +19 -0
- data/lib/active_record/base.rb +292 -268
- data/lib/active_record/callbacks.rb +14 -14
- data/lib/active_record/connection_adapters/abstract_adapter.rb +137 -75
- data/lib/active_record/connection_adapters/db2_adapter.rb +10 -8
- data/lib/active_record/connection_adapters/mysql_adapter.rb +91 -64
- data/lib/active_record/connection_adapters/oci_adapter.rb +6 -6
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +113 -60
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +15 -12
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +159 -132
- data/lib/active_record/fixtures.rb +59 -12
- data/lib/active_record/locking.rb +10 -9
- data/lib/active_record/migration.rb +112 -5
- data/lib/active_record/query_cache.rb +64 -0
- data/lib/active_record/timestamp.rb +10 -8
- data/lib/active_record/validations.rb +121 -26
- data/rakefile +16 -10
- data/test/aaa_create_tables_test.rb +26 -48
- data/test/abstract_unit.rb +3 -0
- data/test/aggregations_test.rb +19 -19
- data/test/association_callbacks_test.rb +110 -0
- data/test/associations_go_eager_test.rb +48 -14
- data/test/associations_test.rb +344 -142
- data/test/base_test.rb +150 -31
- data/test/binary_test.rb +7 -0
- data/test/callbacks_test.rb +24 -5
- data/test/column_alias_test.rb +2 -2
- data/test/connections/native_sqlserver_odbc/connection.rb +26 -0
- data/test/deprecated_associations_test.rb +27 -28
- data/test/deprecated_finder_test.rb +8 -9
- data/test/finder_test.rb +52 -17
- data/test/fixtures/author.rb +39 -0
- data/test/fixtures/categories.yml +7 -0
- data/test/fixtures/categories_posts.yml +8 -0
- data/test/fixtures/category.rb +2 -0
- data/test/fixtures/comment.rb +3 -1
- data/test/fixtures/comments.yml +43 -1
- data/test/fixtures/companies.yml +14 -0
- data/test/fixtures/company.rb +1 -1
- data/test/fixtures/computers.yml +2 -1
- data/test/fixtures/db_definitions/db2.sql +7 -2
- data/test/fixtures/db_definitions/mysql.drop.sql +2 -0
- data/test/fixtures/db_definitions/mysql.sql +11 -6
- data/test/fixtures/db_definitions/oci.sql +7 -2
- data/test/fixtures/db_definitions/postgresql.drop.sql +3 -1
- data/test/fixtures/db_definitions/postgresql.sql +8 -5
- data/test/fixtures/db_definitions/sqlite.drop.sql +2 -0
- data/test/fixtures/db_definitions/sqlite.sql +9 -4
- data/test/fixtures/db_definitions/sqlserver.drop.sql +2 -0
- data/test/fixtures/db_definitions/sqlserver.sql +12 -7
- data/test/fixtures/developer.rb +8 -1
- data/test/fixtures/migrations/3_innocent_jointable.rb +12 -0
- data/test/fixtures/post.rb +8 -2
- data/test/fixtures/posts.yml +21 -0
- data/test/fixtures/project.rb +14 -1
- data/test/fixtures/subscriber.rb +3 -0
- data/test/fixtures_test.rb +14 -0
- data/test/inheritance_test.rb +30 -22
- data/test/lifecycle_test.rb +3 -4
- data/test/locking_test.rb +2 -4
- data/test/migration_test.rb +186 -0
- data/test/mixin_nested_set_test.rb +19 -19
- data/test/mixin_test.rb +88 -88
- data/test/modules_test.rb +5 -10
- data/test/multiple_db_test.rb +2 -0
- data/test/pk_test.rb +8 -12
- data/test/reflection_test.rb +8 -4
- data/test/schema_test_postgresql.rb +63 -0
- data/test/thread_safety_test.rb +4 -1
- data/test/transactions_test.rb +9 -2
- data/test/unconnected_test.rb +1 -0
- data/test/validations_test.rb +151 -8
- metadata +11 -5
- data/test/migration_mysql.rb +0 -104
data/test/migration_mysql.rb
DELETED
@@ -1,104 +0,0 @@
|
|
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
|