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
@@ -55,12 +55,15 @@ create table developers (
55
55
  id integer not null,
56
56
  name varchar(100) default null,
57
57
  salary integer default 70000,
58
+ created_at timestamp default null,
59
+ updated_at timestamp default null,
58
60
  primary key (id)
59
61
  );
60
62
 
61
63
  create table projects (
62
64
  id integer not null,
63
65
  name varchar(100) default null,
66
+ type varchar(255) default null,
64
67
  primary key (id)
65
68
  );
66
69
 
@@ -164,7 +167,8 @@ create table binaries (
164
167
 
165
168
  create table computers (
166
169
  id integer not null primary key,
167
- developer integer not null references developers initially deferred disable
170
+ developer integer not null references developers initially deferred disable,
171
+ extendedWarranty integer not null
168
172
  );
169
173
 
170
174
  create table posts (
@@ -195,7 +199,8 @@ create table tasks (
195
199
 
196
200
  create table categories (
197
201
  id integer not null primary key,
198
- name varchar(255) default null
202
+ name varchar(255) default null,
203
+ type varchar(255) default null
199
204
  );
200
205
 
201
206
  create table categories_posts (
@@ -21,4 +21,6 @@ DROP TABLE authors;
21
21
  DROP TABLE tasks;
22
22
  DROP TABLE categories;
23
23
  DROP TABLE categories_posts;
24
-
24
+ DROP TABLE defaults;
25
+ DROP TABLE fk_test_has_fk;
26
+ DROP TABLE fk_test_has_pk;
@@ -1,5 +1,3 @@
1
- SET search_path = public, pg_catalog;
2
-
3
1
  CREATE TABLE accounts (
4
2
  id serial,
5
3
  firm_id integer,
@@ -30,6 +28,8 @@ CREATE TABLE developers (
30
28
  id serial,
31
29
  name character varying(100),
32
30
  salary integer DEFAULT 70000,
31
+ created_at timestamp,
32
+ updated_at timestamp,
33
33
  PRIMARY KEY (id)
34
34
  );
35
35
  SELECT setval('developers_id_seq', 100);
@@ -37,6 +37,7 @@ SELECT setval('developers_id_seq', 100);
37
37
  CREATE TABLE projects (
38
38
  id serial,
39
39
  name character varying(100),
40
+ type varchar(255),
40
41
  PRIMARY KEY (id)
41
42
  );
42
43
  SELECT setval('projects_id_seq', 100);
@@ -50,10 +51,10 @@ CREATE TABLE topics (
50
51
  bonus_time time,
51
52
  last_read date,
52
53
  content text,
54
+ approved smallint DEFAULT 1,
53
55
  replies_count integer default 0,
54
56
  parent_id integer,
55
57
  "type" character varying(50),
56
- approved smallint DEFAULT 1,
57
58
  PRIMARY KEY (id)
58
59
  );
59
60
  SELECT setval('topics_id_seq', 100);
@@ -144,7 +145,8 @@ CREATE TABLE binaries (
144
145
 
145
146
  CREATE TABLE computers (
146
147
  id serial,
147
- developer integer NOT NULL
148
+ developer integer NOT NULL,
149
+ "extendedWarranty" integer NOT NULL
148
150
  );
149
151
 
150
152
  CREATE TABLE posts (
@@ -176,7 +178,8 @@ CREATE TABLE tasks (
176
178
 
177
179
  CREATE TABLE categories (
178
180
  id serial,
179
- name varchar(255)
181
+ name varchar(255),
182
+ type varchar(255)
180
183
  );
181
184
 
182
185
  CREATE TABLE categories_posts (
@@ -21,3 +21,5 @@ DROP TABLE comments;
21
21
  DROP TABLE authors;
22
22
  DROP TABLE categories;
23
23
  DROP TABLE categories_posts;
24
+ DROP TABLE fk_test_has_fk;
25
+ DROP TABLE fk_test_has_pk;
@@ -33,12 +33,15 @@ CREATE TABLE 'topics' (
33
33
  CREATE TABLE 'developers' (
34
34
  'id' INTEGER PRIMARY KEY NOT NULL,
35
35
  'name' TEXT DEFAULT NULL,
36
- 'salary' INTEGER DEFAULT 70000
36
+ 'salary' INTEGER DEFAULT 70000,
37
+ 'created_at' DATETIME DEFAULT NULL,
38
+ 'updated_at' DATETIME DEFAULT NULL
37
39
  );
38
40
 
39
41
  CREATE TABLE 'projects' (
40
42
  'id' INTEGER PRIMARY KEY NOT NULL,
41
- 'name' TEXT DEFAULT NULL
43
+ 'name' TEXT DEFAULT NULL,
44
+ 'type' VARCHAR(255) DEFAULT NULL
42
45
  );
43
46
 
44
47
  CREATE TABLE 'developers_projects' (
@@ -113,7 +116,8 @@ CREATE TABLE 'binaries' (
113
116
 
114
117
  CREATE TABLE 'computers' (
115
118
  'id' INTEGER NOT NULL PRIMARY KEY,
116
- 'developer' INTEGER NOT NULL
119
+ 'developer' INTEGER NOT NULL,
120
+ 'extendedWarranty' INTEGER NOT NULL
117
121
  );
118
122
 
119
123
  CREATE TABLE 'posts' (
@@ -144,7 +148,8 @@ CREATE TABLE 'tasks' (
144
148
 
145
149
  CREATE TABLE 'categories' (
146
150
  'id' INTEGER NOT NULL PRIMARY KEY,
147
- 'name' VARCHAR(255) NOT NULL
151
+ 'name' VARCHAR(255) NOT NULL,
152
+ 'type' VARCHAR(255) DEFAULT NULL
148
153
  );
149
154
 
150
155
  CREATE TABLE 'categories_posts' (
@@ -21,3 +21,5 @@ DROP TABLE authors;
21
21
  DROP TABLE tasks;
22
22
  DROP TABLE categories;
23
23
  DROP TABLE categories_posts;
24
+ DROP TABLE fk_test_has_pd;
25
+ DROP TABLE fk_test_has_fk;
@@ -2,7 +2,7 @@ CREATE TABLE accounts (
2
2
  id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
3
3
  firm_id int default NULL,
4
4
  credit_limit int default NULL
5
- )
5
+ );
6
6
 
7
7
  CREATE TABLE companies (
8
8
  id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
@@ -12,7 +12,7 @@ CREATE TABLE companies (
12
12
  name varchar(50) default NULL,
13
13
  client_of int default NULL,
14
14
  rating int default 1
15
- )
15
+ );
16
16
 
17
17
  CREATE TABLE topics (
18
18
  id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
@@ -27,17 +27,20 @@ CREATE TABLE topics (
27
27
  replies_count int default 0,
28
28
  parent_id int default NULL,
29
29
  type varchar(50) default NULL
30
- )
30
+ );
31
31
 
32
32
  CREATE TABLE developers (
33
33
  id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
34
34
  name varchar(100) default NULL,
35
- salary int default 70000
35
+ salary int default 70000,
36
+ created_at datetime default NULL,
37
+ updated_at datetime default NULL
36
38
  );
37
39
 
38
40
  CREATE TABLE projects (
39
41
  id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
40
- name varchar(100) default NULL
42
+ name varchar(100) default NULL,
43
+ type varchar(255) default NULL
41
44
  );
42
45
 
43
46
  CREATE TABLE developers_projects (
@@ -113,7 +116,8 @@ CREATE TABLE binaries (
113
116
 
114
117
  CREATE TABLE computers (
115
118
  id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
116
- developer int NOT NULL
119
+ developer int NOT NULL,
120
+ extendedWarranty int NOT NULL
117
121
  );
118
122
 
119
123
  CREATE TABLE posts (
@@ -144,7 +148,8 @@ CREATE TABLE tasks (
144
148
 
145
149
  CREATE TABLE categories (
146
150
  id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
147
- name varchar(255)
151
+ name varchar(255),
152
+ type varchar(255) default NULL
148
153
  );
149
154
 
150
155
  CREATE TABLE categories_posts (
@@ -1,6 +1,13 @@
1
1
  class Developer < ActiveRecord::Base
2
2
  has_and_belongs_to_many :projects
3
-
3
+ has_and_belongs_to_many :special_projects, :join_table => 'developers_projects', :association_foreign_key => 'project_id'
4
+
4
5
  validates_inclusion_of :salary, :in => 50000..200000
5
6
  validates_length_of :name, :within => 3..20
6
7
  end
8
+
9
+ DeveloperSalary = Struct.new(:amount)
10
+ class DeveloperWithAggregate < ActiveRecord::Base
11
+ self.table_name = 'developers'
12
+ composed_of :salary, :class_name => 'DeveloperSalary', :mapping => [%w(salary amount)]
13
+ end
@@ -0,0 +1,12 @@
1
+ class InnocentJointable < ActiveRecord::Migration
2
+ def self.up
3
+ create_table("people_reminders", :id => false) do |t|
4
+ t.column :reminder_id, :integer
5
+ t.column :person_id, :integer
6
+ end
7
+ end
8
+
9
+ def self.down
10
+ drop_table "people_reminders"
11
+ end
12
+ end
@@ -1,8 +1,14 @@
1
1
  class Post < ActiveRecord::Base
2
2
  belongs_to :author
3
3
  has_many :comments, :order => "body"
4
+ has_one :very_special_comment, :class_name => "VerySpecialComment"
5
+ has_many :special_comments, :class_name => "SpecialComment"
4
6
  has_and_belongs_to_many :categories
7
+ has_and_belongs_to_many :special_categories, :join_table => "categories_posts"
5
8
  end
6
9
 
7
- class SpecialPost < Post
8
- end
10
+ class SpecialPost < Post; end;
11
+
12
+ class StiPost < Post
13
+ has_one :special_comment, :class_name => "SpecialComment"
14
+ end
@@ -18,3 +18,24 @@ authorless:
18
18
  title: I don't have any comments
19
19
  body: I just don't want to
20
20
  type: Post
21
+
22
+ sti_comments:
23
+ id: 4
24
+ author_id: 1
25
+ title: sti comments
26
+ body: hello
27
+ type: Post
28
+
29
+ sti_post_and_comments:
30
+ id: 5
31
+ author_id: 1
32
+ title: sti me
33
+ body: hello
34
+ type: StiPost
35
+
36
+ sti_habtm:
37
+ id: 6
38
+ author_id: 1
39
+ title: habtm sti test
40
+ body: hello
41
+ type: Post
@@ -1,10 +1,23 @@
1
1
  class Project < ActiveRecord::Base
2
2
  has_and_belongs_to_many :developers, :uniq => true
3
3
  has_and_belongs_to_many :developers_named_david, :class_name => "Developer", :conditions => "name = 'David'", :uniq => true
4
+ has_and_belongs_to_many :salaried_developers, :class_name => "Developer", :conditions => "salary > 0"
5
+ has_and_belongs_to_many :developers_by_sql, :class_name => "Developer", :delete_sql => "DELETE FROM developers_projects WHERE project_id = \#{id} AND developer_id = \#{record.id}"
6
+ has_and_belongs_to_many :developers_with_callbacks, :class_name => "Developer", :before_add => Proc.new {|o, r| o.developers_log << "before_adding#{r.id}"},
7
+ :after_add => Proc.new {|o, r| o.developers_log << "after_adding#{r.id}"},
8
+ :before_remove => Proc.new {|o, r| o.developers_log << "before_removing#{r.id}"},
9
+ :after_remove => Proc.new {|o, r| o.developers_log << "after_removing#{r.id}"}
10
+
11
+ attr_accessor :developers_log
12
+
13
+ def after_initialize
14
+ @developers_log = []
15
+ end
16
+
4
17
  end
5
18
 
6
19
  class SpecialProject < Project
7
20
  def hello_world
8
21
  "hello there!"
9
22
  end
10
- end
23
+ end
@@ -3,3 +3,6 @@ class Subscriber < ActiveRecord::Base
3
3
  "nick"
4
4
  end
5
5
  end
6
+
7
+ class SpecialSubscriber < Subscriber
8
+ end
@@ -3,8 +3,12 @@ require 'fixtures/topic'
3
3
  require 'fixtures/developer'
4
4
  require 'fixtures/company'
5
5
  require 'fixtures/task'
6
+ require 'fixtures/reply'
6
7
 
7
8
  class FixturesTest < Test::Unit::TestCase
9
+ self.use_instantiated_fixtures = true
10
+ self.use_transactional_fixtures = false
11
+
8
12
  fixtures :topics, :developers, :accounts, :tasks
9
13
 
10
14
  FIXTURES = %w( accounts companies customers
@@ -130,11 +134,19 @@ class FixturesWithoutInstantiationTest < Test::Unit::TestCase
130
134
  def test_fixtures_from_root_yml_without_instantiation
131
135
  assert_nil @unknown
132
136
  end
137
+
138
+ def test_accessor_methods
139
+ assert_equal "The First Topic", topics(:first).title
140
+ assert_equal "Jamis", developers(:jamis).name
141
+ assert_equal 50, accounts(:signals37).credit_limit
142
+ end
133
143
  end
134
144
 
135
145
 
136
146
  class FixturesWithoutInstanceInstantiationTest < Test::Unit::TestCase
147
+ self.use_instantiated_fixtures = true
137
148
  self.use_instantiated_fixtures = :no_instances
149
+
138
150
  fixtures :topics, :developers, :accounts
139
151
 
140
152
  def test_without_instance_instantiation
@@ -147,7 +159,9 @@ end
147
159
 
148
160
 
149
161
  class TransactionalFixturesTest < Test::Unit::TestCase
162
+ self.use_instantiated_fixtures = true
150
163
  self.use_transactional_fixtures = true
164
+
151
165
  fixtures :topics
152
166
 
153
167
  def test_destroy
@@ -1,12 +1,21 @@
1
1
  require 'abstract_unit'
2
2
  require 'fixtures/company'
3
3
  require 'fixtures/project'
4
+ require 'fixtures/subscriber'
4
5
 
5
6
  class InheritanceTest < Test::Unit::TestCase
6
- fixtures :companies, :projects
7
+ fixtures :companies, :projects, :subscribers
7
8
 
8
9
  def test_a_bad_type_column
10
+ #SQLServer need to turn Identity Insert On before manually inserting into the Identity column
11
+ if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter and ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)
12
+ Company.connection.execute "SET IDENTITY_INSERT companies ON"
13
+ end
9
14
  Company.connection.insert "INSERT INTO companies (id, type, name) VALUES(100, 'bad_class!', 'Not happening')"
15
+ #We then need to turn it back Off before continuing.
16
+ if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter and ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)
17
+ Company.connection.execute "SET IDENTITY_INSERT companies OFF"
18
+ end
10
19
  assert_raises(ActiveRecord::SubclassNotFound) { Company.find(100) }
11
20
  end
12
21
 
@@ -23,7 +32,7 @@ class InheritanceTest < Test::Unit::TestCase
23
32
  end
24
33
 
25
34
  def test_inheritance_find_all
26
- companies = Company.find_all(nil, "id")
35
+ companies = Company.find(:all, :order => 'id')
27
36
  assert companies[0].kind_of?(Firm), "37signals should be a firm"
28
37
  assert companies[1].kind_of?(Client), "Summit should be a client"
29
38
  end
@@ -48,9 +57,9 @@ class InheritanceTest < Test::Unit::TestCase
48
57
  end
49
58
 
50
59
  def test_inheritance_condition
51
- assert_equal 3, Company.find_all.length
52
- assert_equal 1, Firm.find_all.length
53
- assert_equal 2, Client.find_all.length
60
+ assert_equal 5, Company.count
61
+ assert_equal 2, Firm.count
62
+ assert_equal 3, Client.count
54
63
  end
55
64
 
56
65
  def test_alt_inheritance_condition
@@ -70,8 +79,8 @@ class InheritanceTest < Test::Unit::TestCase
70
79
 
71
80
  def test_update_all_within_inheritance
72
81
  Client.update_all "name = 'I am a client'"
73
- assert_equal "I am a client", Client.find_all.first.name
74
- assert_equal "37signals", Firm.find_all.first.name
82
+ assert_equal "I am a client", Client.find(:all).first.name
83
+ assert_equal "37signals", Firm.find(:all).first.name
75
84
  end
76
85
 
77
86
  def test_alt_update_all_within_inheritance
@@ -81,8 +90,8 @@ class InheritanceTest < Test::Unit::TestCase
81
90
 
82
91
  def test_destroy_all_within_inheritance
83
92
  Client.destroy_all
84
- assert_equal 0, Client.find_all.length
85
- assert_equal 1, Firm.find_all.length
93
+ assert_equal 0, Client.count
94
+ assert_equal 2, Firm.count
86
95
  end
87
96
 
88
97
  def test_alt_destroy_all_within_inheritance
@@ -91,9 +100,9 @@ class InheritanceTest < Test::Unit::TestCase
91
100
  end
92
101
 
93
102
  def test_find_first_within_inheritance
94
- assert_kind_of Firm, Company.find_first("name = '37signals'")
95
- assert_kind_of Firm, Firm.find_first("name = '37signals'")
96
- assert_nil Client.find_first("name = '37signals'")
103
+ assert_kind_of Firm, Company.find(:first, :conditions => "name = '37signals'")
104
+ assert_kind_of Firm, Firm.find(:first, :conditions => "name = '37signals'")
105
+ assert_nil Client.find(:first, :conditions => "name = '37signals'")
97
106
  end
98
107
 
99
108
  def test_alt_find_first_within_inheritance
@@ -103,11 +112,11 @@ class InheritanceTest < Test::Unit::TestCase
103
112
 
104
113
  def test_complex_inheritance
105
114
  very_special_client = VerySpecialClient.create("name" => "veryspecial")
106
- assert_equal very_special_client, VerySpecialClient.find_first("name = 'veryspecial'")
107
- assert_equal very_special_client, SpecialClient.find_first("name = 'veryspecial'")
108
- assert_equal very_special_client, Company.find_first("name = 'veryspecial'")
109
- assert_equal very_special_client, Client.find_first("name = 'veryspecial'")
110
- assert_equal 1, Client.find_all("name = 'Summit'").size
115
+ assert_equal very_special_client, VerySpecialClient.find(:first, :conditions => "name = 'veryspecial'")
116
+ assert_equal very_special_client, SpecialClient.find(:first, :conditions => "name = 'veryspecial'")
117
+ assert_equal very_special_client, Company.find(:first, :conditions => "name = 'veryspecial'")
118
+ assert_equal very_special_client, Client.find(:first, :conditions => "name = 'veryspecial'")
119
+ assert_equal 1, Client.find(:all, :conditions => "name = 'Summit'").size
111
120
  assert_equal very_special_client, Client.find(very_special_client.id)
112
121
  end
113
122
 
@@ -117,19 +126,18 @@ class InheritanceTest < Test::Unit::TestCase
117
126
  end
118
127
 
119
128
  def test_inheritance_without_mapping
120
- assert_kind_of SpecialProject, SpecialProject.find(1)
121
- assert_nothing_raised { SpecialProject.create("name" => "And breaaaaathe!") }
122
-
129
+ assert_kind_of SpecialSubscriber, SpecialSubscriber.find("webster132")
130
+ assert_nothing_raised { SpecialSubscriber.create("name" => "And breaaaaathe!", "id" => "smartass") }
123
131
  end
124
132
 
125
133
  private
126
134
  def switch_to_alt_inheritance_column
127
135
  # we don't want misleading test results, so get rid of the values in the type column
128
- Company.find_all(nil, "id").each do |c|
136
+ Company.find(:all, :order => 'id').each do |c|
129
137
  c['type'] = nil
130
138
  c.save
131
139
  end
132
140
 
133
141
  def Company.inheritance_column() "ruby_type" end
134
142
  end
135
- end
143
+ end