activerecord 1.12.2 → 1.13.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 (66) hide show
  1. data/CHANGELOG +92 -0
  2. data/README +9 -9
  3. data/lib/active_record/acts/list.rb +1 -1
  4. data/lib/active_record/acts/nested_set.rb +13 -13
  5. data/lib/active_record/acts/tree.rb +7 -6
  6. data/lib/active_record/aggregations.rb +4 -4
  7. data/lib/active_record/associations.rb +82 -21
  8. data/lib/active_record/associations/association_collection.rb +0 -8
  9. data/lib/active_record/associations/association_proxy.rb +5 -2
  10. data/lib/active_record/associations/belongs_to_association.rb +6 -2
  11. data/lib/active_record/associations/has_and_belongs_to_many_association.rb +11 -1
  12. data/lib/active_record/associations/has_many_association.rb +34 -5
  13. data/lib/active_record/associations/has_one_association.rb +1 -1
  14. data/lib/active_record/base.rb +144 -59
  15. data/lib/active_record/callbacks.rb +6 -6
  16. data/lib/active_record/connection_adapters/abstract/connection_specification.rb +3 -2
  17. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +4 -4
  18. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +10 -8
  19. data/lib/active_record/connection_adapters/abstract_adapter.rb +1 -1
  20. data/lib/active_record/connection_adapters/db2_adapter.rb +17 -1
  21. data/lib/active_record/connection_adapters/oci_adapter.rb +322 -185
  22. data/lib/active_record/connection_adapters/sqlite_adapter.rb +9 -8
  23. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +107 -14
  24. data/lib/active_record/fixtures.rb +10 -8
  25. data/lib/active_record/migration.rb +20 -6
  26. data/lib/active_record/observer.rb +4 -3
  27. data/lib/active_record/reflection.rb +5 -5
  28. data/lib/active_record/transactions.rb +2 -2
  29. data/lib/active_record/validations.rb +70 -40
  30. data/lib/active_record/vendor/mysql411.rb +9 -13
  31. data/lib/active_record/version.rb +2 -2
  32. data/rakefile +1 -1
  33. data/test/abstract_unit.rb +5 -0
  34. data/test/ar_schema_test.rb +1 -1
  35. data/test/associations_extensions_test.rb +37 -0
  36. data/test/associations_go_eager_test.rb +25 -0
  37. data/test/associations_test.rb +14 -6
  38. data/test/base_test.rb +63 -45
  39. data/test/connections/native_sqlite/connection.rb +2 -2
  40. data/test/connections/native_sqlite3/connection.rb +2 -2
  41. data/test/connections/native_sqlite3/in_memory_connection.rb +1 -1
  42. data/test/debug.log +2857 -0
  43. data/test/deprecated_finder_test.rb +3 -9
  44. data/test/finder_test.rb +27 -13
  45. data/test/fixtures/author.rb +4 -0
  46. data/test/fixtures/comment.rb +4 -8
  47. data/test/fixtures/db_definitions/create_oracle_db.bat +0 -5
  48. data/test/fixtures/db_definitions/create_oracle_db.sh +0 -5
  49. data/test/fixtures/db_definitions/db2.drop.sql +0 -1
  50. data/test/fixtures/db_definitions/oci.sql +2 -0
  51. data/test/fixtures/db_definitions/sqlserver.drop.sql +1 -1
  52. data/test/fixtures/developer.rb +18 -1
  53. data/test/fixtures/fixture_database.sqlite +0 -0
  54. data/test/fixtures/fixture_database_2.sqlite +0 -0
  55. data/test/fixtures/migrations_with_duplicate/1_people_have_last_names.rb +9 -0
  56. data/test/fixtures/migrations_with_duplicate/2_we_need_reminders.rb +12 -0
  57. data/test/fixtures/migrations_with_duplicate/3_foo.rb +7 -0
  58. data/test/fixtures/migrations_with_duplicate/3_innocent_jointable.rb +12 -0
  59. data/test/fixtures/post.rb +18 -4
  60. data/test/fixtures/reply.rb +3 -1
  61. data/test/inheritance_test.rb +3 -2
  62. data/test/{conditions_scoping_test.rb → method_scoping_test.rb} +55 -10
  63. data/test/migration_test.rb +68 -31
  64. data/test/readonly_test.rb +65 -5
  65. data/test/validations_test.rb +10 -2
  66. metadata +13 -4
@@ -1,12 +1,19 @@
1
1
  require 'abstract_unit'
2
+ require 'fixtures/post'
3
+ require 'fixtures/comment'
2
4
  require 'fixtures/developer'
3
5
  require 'fixtures/project'
4
6
 
7
+ # Dummy class methods to test implicit association scoping.
8
+ def Comment.foo() find :first end
9
+ def Project.foo() find :first end
10
+
11
+
5
12
  class ReadOnlyTest < Test::Unit::TestCase
6
- fixtures :developers, :projects, :developers_projects
13
+ fixtures :posts, :comments, :developers, :projects, :developers_projects
7
14
 
8
15
  def test_cant_save_readonly_record
9
- dev = Developer.find(:first)
16
+ dev = Developer.find(1)
10
17
  assert !dev.readonly?
11
18
 
12
19
  dev.readonly!
@@ -21,21 +28,74 @@ class ReadOnlyTest < Test::Unit::TestCase
21
28
  assert_raise(ActiveRecord::ReadOnlyRecord) { dev.save! }
22
29
  end
23
30
 
31
+
24
32
  def test_find_with_readonly_option
25
33
  Developer.find(:all).each { |d| assert !d.readonly? }
26
34
  Developer.find(:all, :readonly => false).each { |d| assert !d.readonly? }
27
35
  Developer.find(:all, :readonly => true).each { |d| assert d.readonly? }
28
36
  end
29
37
 
38
+
30
39
  def test_find_with_joins_option_implies_readonly
31
- Developer.find(:all, :joins => '').each { |d| assert d.readonly? }
32
- Developer.find(:all, :joins => '', :readonly => false).each { |d| assert !d.readonly? }
40
+ # Blank joins don't count.
41
+ Developer.find(:all, :joins => ' ').each { |d| assert !d.readonly? }
42
+ Developer.find(:all, :joins => ' ', :readonly => false).each { |d| assert !d.readonly? }
43
+
44
+ # Others do.
45
+ Developer.find(:all, :joins => ', projects').each { |d| assert d.readonly? }
46
+ Developer.find(:all, :joins => ', projects', :readonly => false).each { |d| assert !d.readonly? }
33
47
  end
34
48
 
49
+
35
50
  def test_habtm_find_readonly
36
- dev = Developer.find(:first)
51
+ dev = Developer.find(1)
52
+ assert !dev.projects.empty?
37
53
  dev.projects.each { |p| assert !p.readonly? }
38
54
  dev.projects.find(:all) { |p| assert !p.readonly? }
39
55
  dev.projects.find(:all, :readonly => true) { |p| assert p.readonly? }
40
56
  end
57
+
58
+ def test_has_many_find_readonly
59
+ post = Post.find(1)
60
+ assert !post.comments.empty?
61
+ post.comments.each { |r| assert !r.readonly? }
62
+ post.comments.find(:all) { |r| assert !r.readonly? }
63
+ post.comments.find(:all, :readonly => true) { |r| assert r.readonly? }
64
+ end
65
+
66
+
67
+ def test_readonly_scoping
68
+ Post.with_scope(:find => { :conditions => '1=1' }) do
69
+ assert !Post.find(1).readonly?
70
+ assert Post.find(1, :readonly => true).readonly?
71
+ assert !Post.find(1, :readonly => false).readonly?
72
+ end
73
+
74
+ Post.with_scope(:find => { :joins => ' ' }) do
75
+ assert !Post.find(1).readonly?
76
+ assert Post.find(1, :readonly => true).readonly?
77
+ assert !Post.find(1, :readonly => false).readonly?
78
+ end
79
+
80
+ # Oracle barfs on this because the join includes unqualified and
81
+ # conflicting column names
82
+ unless current_adapter?(:OCIAdapter)
83
+ Post.with_scope(:find => { :joins => ', developers' }) do
84
+ assert Post.find(1).readonly?
85
+ assert Post.find(1, :readonly => true).readonly?
86
+ assert !Post.find(1, :readonly => false).readonly?
87
+ end
88
+ end
89
+
90
+ Post.with_scope(:find => { :readonly => true }) do
91
+ assert Post.find(1).readonly?
92
+ assert Post.find(1, :readonly => true).readonly?
93
+ assert !Post.find(1, :readonly => false).readonly?
94
+ end
95
+ end
96
+
97
+ def test_association_collection_method_missing_scoping_not_readonly
98
+ assert !Developer.find(1).projects.foo.readonly?
99
+ assert !Post.find(1).comments.foo.readonly?
100
+ end
41
101
  end
@@ -76,8 +76,16 @@ class ValidationsTest < Test::Unit::TestCase
76
76
  end
77
77
 
78
78
  def test_invalid_record_exception
79
- r = Reply.new
80
- assert_raises(ActiveRecord::RecordInvalid) { r.save! }
79
+ assert_raises(ActiveRecord::RecordInvalid) { Reply.create! }
80
+ assert_raises(ActiveRecord::RecordInvalid) { Reply.new.save! }
81
+
82
+ begin
83
+ r = Reply.new
84
+ r.save!
85
+ flunk
86
+ rescue ActiveRecord::RecordInvalid => invalid
87
+ assert_equal r, invalid.record
88
+ end
81
89
  end
82
90
 
83
91
  def test_single_error_per_attr_iteration
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: activerecord
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.12.2
7
- date: 2005-10-26 00:00:00 +02:00
6
+ version: 1.13.0
7
+ date: 2005-11-07 00:00:00 +01:00
8
8
  summary: Implements the ActiveRecord pattern for ORM.
9
9
  require_paths:
10
10
  - lib
@@ -98,6 +98,7 @@ files:
98
98
  - test/ar_schema_test.rb
99
99
  - test/association_callbacks_test.rb
100
100
  - test/association_inheritance_reload.rb
101
+ - test/associations_extensions_test.rb
101
102
  - test/associations_go_eager_test.rb
102
103
  - test/associations_test.rb
103
104
  - test/base_test.rb
@@ -105,9 +106,9 @@ files:
105
106
  - test/callbacks_test.rb
106
107
  - test/class_inheritable_attributes_test.rb
107
108
  - test/column_alias_test.rb
108
- - test/conditions_scoping_test.rb
109
109
  - test/connections
110
110
  - test/copy_table_sqlite.rb
111
+ - test/debug.log
111
112
  - test/deprecated_associations_test.rb
112
113
  - test/deprecated_finder_test.rb
113
114
  - test/finder_test.rb
@@ -116,6 +117,7 @@ files:
116
117
  - test/inheritance_test.rb
117
118
  - test/lifecycle_test.rb
118
119
  - test/locking_test.rb
120
+ - test/method_scoping_test.rb
119
121
  - test/migration_test.rb
120
122
  - test/mixin_nested_set_test.rb
121
123
  - test/mixin_test.rb
@@ -178,11 +180,14 @@ files:
178
180
  - test/fixtures/developers_projects.yml
179
181
  - test/fixtures/entrant.rb
180
182
  - test/fixtures/entrants.yml
183
+ - test/fixtures/fixture_database.sqlite
184
+ - test/fixtures/fixture_database_2.sqlite
181
185
  - test/fixtures/fk_test_has_fk.yml
182
186
  - test/fixtures/fk_test_has_pk.yml
183
187
  - test/fixtures/flowers.jpg
184
188
  - test/fixtures/keyboard.rb
185
189
  - test/fixtures/migrations
190
+ - test/fixtures/migrations_with_duplicate
186
191
  - test/fixtures/mixin.rb
187
192
  - test/fixtures/mixins.yml
188
193
  - test/fixtures/movie.rb
@@ -240,6 +245,10 @@ files:
240
245
  - test/fixtures/migrations/1_people_have_last_names.rb
241
246
  - test/fixtures/migrations/2_we_need_reminders.rb
242
247
  - test/fixtures/migrations/3_innocent_jointable.rb
248
+ - test/fixtures/migrations_with_duplicate/1_people_have_last_names.rb
249
+ - test/fixtures/migrations_with_duplicate/2_we_need_reminders.rb
250
+ - test/fixtures/migrations_with_duplicate/3_foo.rb
251
+ - test/fixtures/migrations_with_duplicate/3_innocent_jointable.rb
243
252
  - test/fixtures/naked/csv
244
253
  - test/fixtures/naked/yml
245
254
  - test/fixtures/naked/csv/accounts.csv
@@ -270,5 +279,5 @@ dependencies:
270
279
  -
271
280
  - "="
272
281
  - !ruby/object:Gem::Version
273
- version: 1.2.2
282
+ version: 1.2.3
274
283
  version: