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.

Files changed (84) hide show
  1. data/CHANGELOG +187 -19
  2. data/RUNNING_UNIT_TESTS +11 -0
  3. data/lib/active_record.rb +3 -1
  4. data/lib/active_record/acts/list.rb +25 -14
  5. data/lib/active_record/acts/nested_set.rb +4 -4
  6. data/lib/active_record/acts/tree.rb +18 -1
  7. data/lib/active_record/associations.rb +90 -17
  8. data/lib/active_record/associations/association_collection.rb +44 -5
  9. data/lib/active_record/associations/has_and_belongs_to_many_association.rb +17 -4
  10. data/lib/active_record/associations/has_many_association.rb +13 -3
  11. data/lib/active_record/associations/has_one_association.rb +19 -0
  12. data/lib/active_record/base.rb +292 -268
  13. data/lib/active_record/callbacks.rb +14 -14
  14. data/lib/active_record/connection_adapters/abstract_adapter.rb +137 -75
  15. data/lib/active_record/connection_adapters/db2_adapter.rb +10 -8
  16. data/lib/active_record/connection_adapters/mysql_adapter.rb +91 -64
  17. data/lib/active_record/connection_adapters/oci_adapter.rb +6 -6
  18. data/lib/active_record/connection_adapters/postgresql_adapter.rb +113 -60
  19. data/lib/active_record/connection_adapters/sqlite_adapter.rb +15 -12
  20. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +159 -132
  21. data/lib/active_record/fixtures.rb +59 -12
  22. data/lib/active_record/locking.rb +10 -9
  23. data/lib/active_record/migration.rb +112 -5
  24. data/lib/active_record/query_cache.rb +64 -0
  25. data/lib/active_record/timestamp.rb +10 -8
  26. data/lib/active_record/validations.rb +121 -26
  27. data/rakefile +16 -10
  28. data/test/aaa_create_tables_test.rb +26 -48
  29. data/test/abstract_unit.rb +3 -0
  30. data/test/aggregations_test.rb +19 -19
  31. data/test/association_callbacks_test.rb +110 -0
  32. data/test/associations_go_eager_test.rb +48 -14
  33. data/test/associations_test.rb +344 -142
  34. data/test/base_test.rb +150 -31
  35. data/test/binary_test.rb +7 -0
  36. data/test/callbacks_test.rb +24 -5
  37. data/test/column_alias_test.rb +2 -2
  38. data/test/connections/native_sqlserver_odbc/connection.rb +26 -0
  39. data/test/deprecated_associations_test.rb +27 -28
  40. data/test/deprecated_finder_test.rb +8 -9
  41. data/test/finder_test.rb +52 -17
  42. data/test/fixtures/author.rb +39 -0
  43. data/test/fixtures/categories.yml +7 -0
  44. data/test/fixtures/categories_posts.yml +8 -0
  45. data/test/fixtures/category.rb +2 -0
  46. data/test/fixtures/comment.rb +3 -1
  47. data/test/fixtures/comments.yml +43 -1
  48. data/test/fixtures/companies.yml +14 -0
  49. data/test/fixtures/company.rb +1 -1
  50. data/test/fixtures/computers.yml +2 -1
  51. data/test/fixtures/db_definitions/db2.sql +7 -2
  52. data/test/fixtures/db_definitions/mysql.drop.sql +2 -0
  53. data/test/fixtures/db_definitions/mysql.sql +11 -6
  54. data/test/fixtures/db_definitions/oci.sql +7 -2
  55. data/test/fixtures/db_definitions/postgresql.drop.sql +3 -1
  56. data/test/fixtures/db_definitions/postgresql.sql +8 -5
  57. data/test/fixtures/db_definitions/sqlite.drop.sql +2 -0
  58. data/test/fixtures/db_definitions/sqlite.sql +9 -4
  59. data/test/fixtures/db_definitions/sqlserver.drop.sql +2 -0
  60. data/test/fixtures/db_definitions/sqlserver.sql +12 -7
  61. data/test/fixtures/developer.rb +8 -1
  62. data/test/fixtures/migrations/3_innocent_jointable.rb +12 -0
  63. data/test/fixtures/post.rb +8 -2
  64. data/test/fixtures/posts.yml +21 -0
  65. data/test/fixtures/project.rb +14 -1
  66. data/test/fixtures/subscriber.rb +3 -0
  67. data/test/fixtures_test.rb +14 -0
  68. data/test/inheritance_test.rb +30 -22
  69. data/test/lifecycle_test.rb +3 -4
  70. data/test/locking_test.rb +2 -4
  71. data/test/migration_test.rb +186 -0
  72. data/test/mixin_nested_set_test.rb +19 -19
  73. data/test/mixin_test.rb +88 -88
  74. data/test/modules_test.rb +5 -10
  75. data/test/multiple_db_test.rb +2 -0
  76. data/test/pk_test.rb +8 -12
  77. data/test/reflection_test.rb +8 -4
  78. data/test/schema_test_postgresql.rb +63 -0
  79. data/test/thread_safety_test.rb +4 -1
  80. data/test/transactions_test.rb +9 -2
  81. data/test/unconnected_test.rb +1 -0
  82. data/test/validations_test.rb +151 -8
  83. metadata +11 -5
  84. data/test/migration_mysql.rb +0 -104
@@ -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