activerecord 1.11.1 → 1.12.1
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 +198 -0
- data/lib/active_record.rb +19 -14
- data/lib/active_record/acts/list.rb +8 -6
- data/lib/active_record/acts/tree.rb +33 -10
- data/lib/active_record/aggregations.rb +1 -7
- data/lib/active_record/associations.rb +151 -82
- data/lib/active_record/associations/association_collection.rb +25 -0
- data/lib/active_record/associations/association_proxy.rb +9 -8
- data/lib/active_record/associations/belongs_to_association.rb +19 -5
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +44 -69
- data/lib/active_record/associations/has_many_association.rb +6 -14
- data/lib/active_record/associations/has_one_association.rb +5 -3
- data/lib/active_record/base.rb +344 -130
- data/lib/active_record/callbacks.rb +2 -2
- data/lib/active_record/connection_adapters/abstract/connection_specification.rb +128 -0
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +104 -0
- data/lib/active_record/connection_adapters/abstract/quoting.rb +51 -0
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +249 -0
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +245 -0
- data/lib/active_record/connection_adapters/abstract_adapter.rb +29 -464
- data/lib/active_record/connection_adapters/db2_adapter.rb +40 -10
- data/lib/active_record/connection_adapters/mysql_adapter.rb +131 -60
- data/lib/active_record/connection_adapters/oci_adapter.rb +106 -26
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +211 -62
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +193 -44
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +24 -15
- data/lib/active_record/fixtures.rb +47 -24
- data/lib/active_record/migration.rb +34 -5
- data/lib/active_record/observer.rb +32 -2
- data/lib/active_record/query_cache.rb +12 -11
- data/lib/active_record/schema.rb +58 -0
- data/lib/active_record/schema_dumper.rb +84 -0
- data/lib/active_record/transactions.rb +1 -3
- data/lib/active_record/validations.rb +40 -26
- data/lib/active_record/vendor/mysql.rb +6 -0
- data/lib/active_record/version.rb +9 -0
- data/rakefile +5 -16
- data/test/abstract_unit.rb +6 -11
- data/test/adapter_test.rb +58 -0
- data/test/ar_schema_test.rb +33 -0
- data/test/association_callbacks_test.rb +14 -0
- data/test/associations_go_eager_test.rb +56 -14
- data/test/associations_test.rb +245 -25
- data/test/base_test.rb +205 -34
- data/test/binary_test.rb +25 -42
- data/test/callbacks_test.rb +75 -0
- data/test/conditions_scoping_test.rb +136 -0
- data/test/connections/native_mysql/connection.rb +0 -4
- data/test/connections/native_sqlite3/in_memory_connection.rb +17 -0
- data/test/copy_table_sqlite.rb +64 -0
- data/test/deprecated_associations_test.rb +7 -6
- data/test/deprecated_finder_test.rb +3 -3
- data/test/finder_test.rb +33 -3
- data/test/fixtures/accounts.yml +5 -0
- data/test/fixtures/categories_ordered.yml +7 -0
- data/test/fixtures/category.rb +11 -1
- data/test/fixtures/comment.rb +22 -2
- data/test/fixtures/comments.yml +6 -0
- data/test/fixtures/companies.yml +15 -0
- data/test/fixtures/company.rb +24 -1
- data/test/fixtures/db_definitions/db2.drop.sql +5 -1
- data/test/fixtures/db_definitions/db2.sql +15 -1
- data/test/fixtures/db_definitions/mysql.drop.sql +2 -0
- data/test/fixtures/db_definitions/mysql.sql +17 -2
- data/test/fixtures/db_definitions/oci.drop.sql +37 -5
- data/test/fixtures/db_definitions/oci.sql +47 -4
- data/test/fixtures/db_definitions/oci2.drop.sql +1 -1
- data/test/fixtures/db_definitions/oci2.sql +2 -2
- data/test/fixtures/db_definitions/postgresql.drop.sql +4 -0
- data/test/fixtures/db_definitions/postgresql.sql +33 -4
- data/test/fixtures/db_definitions/sqlite.drop.sql +2 -0
- data/test/fixtures/db_definitions/sqlite.sql +16 -2
- data/test/fixtures/db_definitions/sqlserver.drop.sql +2 -0
- data/test/fixtures/db_definitions/sqlserver.sql +16 -2
- data/test/fixtures/developer.rb +1 -1
- data/test/fixtures/flowers.jpg +0 -0
- data/test/fixtures/keyboard.rb +3 -0
- data/test/fixtures/mixins.yml +11 -1
- data/test/fixtures/order.rb +4 -0
- data/test/fixtures/post.rb +4 -0
- data/test/fixtures/posts.yml +7 -0
- data/test/fixtures/project.rb +1 -0
- data/test/fixtures/subject.rb +4 -0
- data/test/fixtures/subscriber.rb +2 -4
- data/test/fixtures/topics.yml +2 -2
- data/test/fixtures_test.rb +79 -7
- data/test/inheritance_test.rb +2 -2
- data/test/lifecycle_test.rb +14 -6
- data/test/migration_test.rb +164 -6
- data/test/mixin_test.rb +78 -2
- data/test/pk_test.rb +25 -1
- data/test/readonly_test.rb +31 -0
- data/test/reflection_test.rb +4 -1
- data/test/schema_dumper_test.rb +19 -0
- data/test/schema_test_postgresql.rb +3 -2
- data/test/synonym_test_oci.rb +17 -0
- data/test/threaded_connections_test.rb +2 -1
- data/test/transactions_test.rb +109 -10
- data/test/validations_test.rb +70 -42
- metadata +25 -5
- data/test/fixtures/associations.png +0 -0
- data/test/thread_safety_test.rb +0 -36
@@ -1,2 +1,2 @@
|
|
1
1
|
drop table courses;
|
2
|
-
drop sequence
|
2
|
+
drop sequence courses_seq;
|
@@ -1,10 +1,12 @@
|
|
1
1
|
DROP TABLE accounts;
|
2
2
|
DROP TABLE companies;
|
3
|
+
DROP SEQUENCE companies_nonstd_seq;
|
3
4
|
DROP TABLE topics;
|
4
5
|
DROP TABLE developers;
|
5
6
|
DROP TABLE projects;
|
6
7
|
DROP TABLE developers_projects;
|
7
8
|
DROP TABLE customers;
|
9
|
+
DROP TABLE orders;
|
8
10
|
DROP TABLE movies;
|
9
11
|
DROP TABLE subscribers;
|
10
12
|
DROP TABLE booleantests;
|
@@ -24,3 +26,5 @@ DROP TABLE categories_posts;
|
|
24
26
|
DROP TABLE defaults;
|
25
27
|
DROP TABLE fk_test_has_fk;
|
26
28
|
DROP TABLE fk_test_has_pk;
|
29
|
+
DROP TABLE geometrics;
|
30
|
+
DROP TABLE keyboards;
|
@@ -6,8 +6,10 @@ CREATE TABLE accounts (
|
|
6
6
|
);
|
7
7
|
SELECT setval('accounts_id_seq', 100);
|
8
8
|
|
9
|
+
CREATE SEQUENCE companies_nonstd_seq START 101;
|
10
|
+
|
9
11
|
CREATE TABLE companies (
|
10
|
-
id
|
12
|
+
id integer DEFAULT nextval('companies_nonstd_seq'),
|
11
13
|
"type" character varying(50),
|
12
14
|
"ruby_type" character varying(50),
|
13
15
|
firm_id integer,
|
@@ -16,12 +18,12 @@ CREATE TABLE companies (
|
|
16
18
|
rating integer default 1,
|
17
19
|
PRIMARY KEY (id)
|
18
20
|
);
|
19
|
-
SELECT setval('companies_id_seq', 100);
|
20
21
|
|
21
22
|
CREATE TABLE developers_projects (
|
22
23
|
developer_id integer NOT NULL,
|
23
24
|
project_id integer NOT NULL,
|
24
|
-
joined_on date
|
25
|
+
joined_on date,
|
26
|
+
access_level integer default 1
|
25
27
|
);
|
26
28
|
|
27
29
|
CREATE TABLE developers (
|
@@ -51,7 +53,7 @@ CREATE TABLE topics (
|
|
51
53
|
bonus_time time,
|
52
54
|
last_read date,
|
53
55
|
content text,
|
54
|
-
approved
|
56
|
+
approved boolean default true,
|
55
57
|
replies_count integer default 0,
|
56
58
|
parent_id integer,
|
57
59
|
"type" character varying(50),
|
@@ -71,6 +73,15 @@ CREATE TABLE customers (
|
|
71
73
|
);
|
72
74
|
SELECT setval('customers_id_seq', 100);
|
73
75
|
|
76
|
+
CREATE TABLE orders (
|
77
|
+
id serial,
|
78
|
+
name character varying,
|
79
|
+
billing_customer_id integer,
|
80
|
+
shipping_customer_id integer,
|
81
|
+
PRIMARY KEY (id)
|
82
|
+
);
|
83
|
+
SELECT setval('orders_id_seq', 100);
|
84
|
+
|
74
85
|
CREATE TABLE movies (
|
75
86
|
movieid serial,
|
76
87
|
name text,
|
@@ -92,8 +103,10 @@ CREATE TABLE booleantests (
|
|
92
103
|
CREATE TABLE defaults (
|
93
104
|
id serial,
|
94
105
|
modified_date date default CURRENT_DATE,
|
106
|
+
modified_date_function date default now(),
|
95
107
|
fixed_date date default '2004-01-01',
|
96
108
|
modified_time timestamp default CURRENT_TIMESTAMP,
|
109
|
+
modified_time_function timestamp default now(),
|
97
110
|
fixed_time timestamp default '2004-01-01 00:00:00.000000-00',
|
98
111
|
char1 char(1) default 'Y',
|
99
112
|
char2 character varying(50) default 'a varchar field',
|
@@ -195,3 +208,19 @@ CREATE TABLE fk_test_has_fk (
|
|
195
208
|
id INTEGER NOT NULL PRIMARY KEY,
|
196
209
|
fk_id INTEGER NOT NULL REFERENCES fk_test_has_fk(id)
|
197
210
|
);
|
211
|
+
|
212
|
+
CREATE TABLE geometrics (
|
213
|
+
id serial primary key,
|
214
|
+
a_point point,
|
215
|
+
-- a_line line, (the line type is currently not implemented in postgresql)
|
216
|
+
a_line_segment lseg,
|
217
|
+
a_box box,
|
218
|
+
a_path path,
|
219
|
+
a_polygon polygon,
|
220
|
+
a_circle circle
|
221
|
+
);
|
222
|
+
|
223
|
+
CREATE TABLE keyboards (
|
224
|
+
key_number serial primary key,
|
225
|
+
"name" character varying(50)
|
226
|
+
);
|
@@ -5,6 +5,7 @@ DROP TABLE developers;
|
|
5
5
|
DROP TABLE projects;
|
6
6
|
DROP TABLE developers_projects;
|
7
7
|
DROP TABLE customers;
|
8
|
+
DROP TABLE orders;
|
8
9
|
DROP TABLE movies;
|
9
10
|
DROP TABLE subscribers;
|
10
11
|
DROP TABLE booleantests;
|
@@ -23,3 +24,4 @@ DROP TABLE categories;
|
|
23
24
|
DROP TABLE categories_posts;
|
24
25
|
DROP TABLE fk_test_has_fk;
|
25
26
|
DROP TABLE fk_test_has_pk;
|
27
|
+
DROP TABLE keyboards;
|
@@ -24,7 +24,7 @@ CREATE TABLE 'topics' (
|
|
24
24
|
'bonus_time' TIME DEFAULT NULL,
|
25
25
|
'last_read' DATE DEFAULT NULL,
|
26
26
|
'content' TEXT,
|
27
|
-
'approved'
|
27
|
+
'approved' boolean DEFAULT 't',
|
28
28
|
'replies_count' INTEGER DEFAULT 0,
|
29
29
|
'parent_id' INTEGER DEFAULT NULL,
|
30
30
|
'type' VARCHAR(255) DEFAULT NULL
|
@@ -47,7 +47,16 @@ CREATE TABLE 'projects' (
|
|
47
47
|
CREATE TABLE 'developers_projects' (
|
48
48
|
'developer_id' INTEGER NOT NULL,
|
49
49
|
'project_id' INTEGER NOT NULL,
|
50
|
-
'joined_on' DATE DEFAULT NULL
|
50
|
+
'joined_on' DATE DEFAULT NULL,
|
51
|
+
'access_level' INTEGER DEFAULT 1
|
52
|
+
);
|
53
|
+
|
54
|
+
|
55
|
+
CREATE TABLE 'orders' (
|
56
|
+
'id' INTEGER PRIMARY KEY NOT NULL,
|
57
|
+
'name' VARCHAR(255) DEFAULT NULL,
|
58
|
+
'billing_customer_id' INTEGER DEFAULT NULL,
|
59
|
+
'shipping_customer_id' INTEGER DEFAULT NULL
|
51
60
|
);
|
52
61
|
|
53
62
|
CREATE TABLE 'customers' (
|
@@ -167,3 +176,8 @@ CREATE TABLE 'fk_test_has_fk' (
|
|
167
176
|
|
168
177
|
FOREIGN KEY ('fk_id') REFERENCES 'fk_test_has_pk'('id')
|
169
178
|
);
|
179
|
+
|
180
|
+
CREATE TABLE 'keyboards' (
|
181
|
+
'key_number' INTEGER PRIMARY KEY NOT NULL,
|
182
|
+
'name' VARCHAR(255) DEFAULT NULL
|
183
|
+
);
|
@@ -5,6 +5,7 @@ DROP TABLE developers;
|
|
5
5
|
DROP TABLE projects;
|
6
6
|
DROP TABLE developers_projects;
|
7
7
|
DROP TABLE customers;
|
8
|
+
DROP TABLE orders;
|
8
9
|
DROP TABLE movies;
|
9
10
|
DROP TABLE subscribers;
|
10
11
|
DROP TABLE booleantests;
|
@@ -23,3 +24,4 @@ DROP TABLE categories;
|
|
23
24
|
DROP TABLE categories_posts;
|
24
25
|
DROP TABLE fk_test_has_pd;
|
25
26
|
DROP TABLE fk_test_has_fk;
|
27
|
+
DROP TABLE keyboards;
|
@@ -22,7 +22,7 @@ CREATE TABLE topics (
|
|
22
22
|
written_on datetime default NULL,
|
23
23
|
bonus_time datetime default NULL,
|
24
24
|
last_read datetime default NULL,
|
25
|
-
content
|
25
|
+
content varchar(255) default NULL,
|
26
26
|
approved tinyint default 1,
|
27
27
|
replies_count int default 0,
|
28
28
|
parent_id int default NULL,
|
@@ -46,9 +46,18 @@ CREATE TABLE projects (
|
|
46
46
|
CREATE TABLE developers_projects (
|
47
47
|
developer_id int NOT NULL,
|
48
48
|
project_id int NOT NULL,
|
49
|
-
joined_on datetime default NULL
|
49
|
+
joined_on datetime default NULL,
|
50
|
+
access_level int default 1
|
50
51
|
);
|
51
52
|
|
53
|
+
CREATE TABLE orders (
|
54
|
+
id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
|
55
|
+
name varchar(100) default NULL,
|
56
|
+
billing_customer_id int default NULL,
|
57
|
+
shipping_customer_id int default NULL
|
58
|
+
);
|
59
|
+
|
60
|
+
|
52
61
|
CREATE TABLE customers (
|
53
62
|
id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
|
54
63
|
name varchar(100) default NULL,
|
@@ -167,3 +176,8 @@ CREATE TABLE fk_test_has_fk (
|
|
167
176
|
|
168
177
|
FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
|
169
178
|
);
|
179
|
+
|
180
|
+
CREATE TABLE keyboards (
|
181
|
+
key_number int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
|
182
|
+
name varchar(50) default NULL
|
183
|
+
);
|
data/test/fixtures/developer.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
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
5
|
validates_inclusion_of :salary, :in => 50000..200000
|
6
6
|
validates_length_of :name, :within => 3..20
|
7
7
|
end
|
Binary file
|
data/test/fixtures/mixins.yml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
tree_1:
|
3
3
|
id: 1001
|
4
4
|
type: TreeMixin
|
5
|
-
parent_id:
|
5
|
+
parent_id:
|
6
6
|
|
7
7
|
tree_2:
|
8
8
|
id: 1002
|
@@ -18,6 +18,16 @@ tree_4:
|
|
18
18
|
id: 1004
|
19
19
|
type: TreeMixin
|
20
20
|
parent_id: 1001
|
21
|
+
|
22
|
+
tree2_1:
|
23
|
+
id: 1005
|
24
|
+
type: TreeMixin
|
25
|
+
parent_id:
|
26
|
+
|
27
|
+
tree3_1:
|
28
|
+
id: 1006
|
29
|
+
type: TreeMixin
|
30
|
+
parent_id:
|
21
31
|
|
22
32
|
# List mixins
|
23
33
|
|
data/test/fixtures/post.rb
CHANGED
@@ -5,6 +5,10 @@ class Post < ActiveRecord::Base
|
|
5
5
|
has_many :special_comments, :class_name => "SpecialComment"
|
6
6
|
has_and_belongs_to_many :categories
|
7
7
|
has_and_belongs_to_many :special_categories, :join_table => "categories_posts"
|
8
|
+
|
9
|
+
def self.what_are_you
|
10
|
+
'a post...'
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
14
|
class SpecialPost < Post; end;
|
data/test/fixtures/posts.yml
CHANGED
data/test/fixtures/project.rb
CHANGED
@@ -2,6 +2,7 @@ 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
4
|
has_and_belongs_to_many :salaried_developers, :class_name => "Developer", :conditions => "salary > 0"
|
5
|
+
has_and_belongs_to_many :developers_with_finder_sql, :class_name => "Developer", :finder_sql => 'SELECT t.*, j.* FROM developers_projects j, developers t WHERE t.id = j.developer_id AND j.project_id = #{id}'
|
5
6
|
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
7
|
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
8
|
:after_add => Proc.new {|o, r| o.developers_log << "after_adding#{r.id}"},
|
data/test/fixtures/subscriber.rb
CHANGED
data/test/fixtures/topics.yml
CHANGED
@@ -7,7 +7,7 @@ first:
|
|
7
7
|
last_read: 2004-04-15
|
8
8
|
bonus_time: 2005-01-30t15:28:00.00+01:00
|
9
9
|
content: Have a nice day
|
10
|
-
approved:
|
10
|
+
approved: false
|
11
11
|
replies_count: 0
|
12
12
|
|
13
13
|
second:
|
@@ -16,6 +16,6 @@ second:
|
|
16
16
|
author_name: Mary
|
17
17
|
written_on: 2003-07-15t15:28:00.00+01:00
|
18
18
|
content: Have a nice day
|
19
|
-
approved:
|
19
|
+
approved: true
|
20
20
|
replies_count: 2
|
21
21
|
parent_id: 1
|
data/test/fixtures_test.rb
CHANGED
@@ -51,6 +51,44 @@ class FixturesTest < Test::Unit::TestCase
|
|
51
51
|
assert_nil(secondRow["author_email_address"])
|
52
52
|
end
|
53
53
|
|
54
|
+
def test_inserts_with_pre_and_suffix
|
55
|
+
ActiveRecord::Base.connection.create_table :prefix_topics_suffix do |t|
|
56
|
+
t.column :title, :string
|
57
|
+
t.column :author_name, :string
|
58
|
+
t.column :author_email_address, :string
|
59
|
+
t.column :written_on, :datetime
|
60
|
+
t.column :bonus_time, :time
|
61
|
+
t.column :last_read, :date
|
62
|
+
t.column :content, :text
|
63
|
+
t.column :approved, :boolean, :default => true
|
64
|
+
t.column :replies_count, :integer, :default => 0
|
65
|
+
t.column :parent_id, :integer
|
66
|
+
t.column :type, :string, :limit => 50
|
67
|
+
end
|
68
|
+
|
69
|
+
# Store existing prefix/suffix
|
70
|
+
old_prefix = ActiveRecord::Base.table_name_prefix
|
71
|
+
old_suffix = ActiveRecord::Base.table_name_suffix
|
72
|
+
|
73
|
+
# Set a prefix/suffix we can test against
|
74
|
+
ActiveRecord::Base.table_name_prefix = 'prefix_'
|
75
|
+
ActiveRecord::Base.table_name_suffix = '_suffix'
|
76
|
+
|
77
|
+
topics = create_fixtures("topics")
|
78
|
+
|
79
|
+
# Restore prefix/suffix to its previous values
|
80
|
+
ActiveRecord::Base.table_name_prefix = old_prefix
|
81
|
+
ActiveRecord::Base.table_name_suffix = old_suffix
|
82
|
+
|
83
|
+
firstRow = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'David'")
|
84
|
+
assert_equal("The First Topic", firstRow["title"])
|
85
|
+
|
86
|
+
secondRow = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'Mary'")
|
87
|
+
assert_nil(secondRow["author_email_address"])
|
88
|
+
ensure
|
89
|
+
ActiveRecord::Base.connection.drop_table :prefix_topics_suffix rescue nil
|
90
|
+
end
|
91
|
+
|
54
92
|
def test_insert_with_datetime
|
55
93
|
topics = create_fixtures("tasks")
|
56
94
|
first = Task.find(1)
|
@@ -117,6 +155,47 @@ class FixturesTest < Test::Unit::TestCase
|
|
117
155
|
def test_empty_csv_fixtures
|
118
156
|
assert_not_nil Fixtures.new( Account.connection, "accounts", File.dirname(__FILE__) + "/fixtures/naked/csv/accounts")
|
119
157
|
end
|
158
|
+
|
159
|
+
def test_omap_fixtures
|
160
|
+
assert_nothing_raised do
|
161
|
+
fixtures = Fixtures.new(Account.connection, 'categories', File.dirname(__FILE__) + '/fixtures/categories_ordered')
|
162
|
+
|
163
|
+
i = 0
|
164
|
+
fixtures.each do |name, fixture|
|
165
|
+
assert_equal "fixture_no_#{i}", name
|
166
|
+
assert_equal "Category #{i}", fixture['name']
|
167
|
+
i += 1
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
if Account.connection.respond_to?(:reset_pk_sequence!)
|
174
|
+
class FixturesResetPkSequenceTest < Test::Unit::TestCase
|
175
|
+
fixtures :accounts
|
176
|
+
|
177
|
+
def test_resets_to_min_pk
|
178
|
+
Account.delete_all
|
179
|
+
Account.connection.reset_pk_sequence!(Account.table_name)
|
180
|
+
|
181
|
+
one = Account.new(:credit_limit => 50)
|
182
|
+
one.save!
|
183
|
+
assert_equal 1, one.id
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_create_fixtures_resets_sequences
|
187
|
+
# create_fixtures performs reset_pk_sequence!
|
188
|
+
max_id = create_fixtures('accounts').inject(0) do |max_id, (name, fixture)|
|
189
|
+
fixture_id = fixture['id'].to_i
|
190
|
+
fixture_id > max_id ? fixture_id : max_id
|
191
|
+
end
|
192
|
+
|
193
|
+
# Clone the last fixture to check that it gets the next greatest id.
|
194
|
+
another = Account.new(:credit_limit => 1200)
|
195
|
+
another.save!
|
196
|
+
assert_equal max_id + 1, another.id
|
197
|
+
end
|
198
|
+
end
|
120
199
|
end
|
121
200
|
|
122
201
|
|
@@ -209,11 +288,4 @@ class ForeignKeyFixturesTest < Test::Unit::TestCase
|
|
209
288
|
def test_number2
|
210
289
|
assert true
|
211
290
|
end
|
212
|
-
|
213
291
|
end
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
data/test/inheritance_test.rb
CHANGED
@@ -57,7 +57,7 @@ class InheritanceTest < Test::Unit::TestCase
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_inheritance_condition
|
60
|
-
assert_equal
|
60
|
+
assert_equal 8, Company.count
|
61
61
|
assert_equal 2, Firm.count
|
62
62
|
assert_equal 3, Client.count
|
63
63
|
end
|
@@ -127,7 +127,7 @@ class InheritanceTest < Test::Unit::TestCase
|
|
127
127
|
|
128
128
|
def test_inheritance_without_mapping
|
129
129
|
assert_kind_of SpecialSubscriber, SpecialSubscriber.find("webster132")
|
130
|
-
assert_nothing_raised { SpecialSubscriber.
|
130
|
+
assert_nothing_raised { s = SpecialSubscriber.new("name" => "And breaaaaathe!"); s.id = 'roger'; s.save }
|
131
131
|
end
|
132
132
|
|
133
133
|
private
|