activerecord 1.9.1 → 1.10.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 +78 -0
- data/README +1 -1
- data/install.rb +7 -42
- data/lib/active_record.rb +2 -0
- data/lib/active_record/acts/list.rb +28 -4
- data/lib/active_record/acts/nested_set.rb +212 -0
- data/lib/active_record/associations.rb +203 -21
- data/lib/active_record/associations/association_proxy.rb +10 -2
- data/lib/active_record/associations/belongs_to_association.rb +0 -1
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +15 -9
- data/lib/active_record/associations/has_many_association.rb +25 -25
- data/lib/active_record/associations/has_one_association.rb +2 -2
- data/lib/active_record/base.rb +134 -110
- data/lib/active_record/connection_adapters/abstract_adapter.rb +9 -9
- data/lib/active_record/connection_adapters/mysql_adapter.rb +4 -0
- data/lib/active_record/connection_adapters/oci_adapter.rb +2 -2
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +1 -2
- data/lib/active_record/deprecated_associations.rb +1 -19
- data/lib/active_record/deprecated_finders.rb +41 -0
- data/lib/active_record/fixtures.rb +24 -11
- data/lib/active_record/observer.rb +17 -11
- data/lib/active_record/reflection.rb +5 -1
- data/lib/active_record/transactions.rb +7 -0
- data/lib/active_record/validations.rb +32 -33
- data/rakefile +30 -6
- data/test/associations_go_eager_test.rb +55 -0
- data/test/associations_test.rb +72 -15
- data/test/base_test.rb +15 -21
- data/test/deprecated_associations_test.rb +0 -24
- data/test/deprecated_finder_test.rb +147 -0
- data/test/finder_test.rb +37 -37
- data/test/fixtures/author.rb +3 -0
- data/test/fixtures/authors.yml +7 -0
- data/test/fixtures/categories.yml +7 -0
- data/test/fixtures/categories_posts.yml +11 -0
- data/test/fixtures/category.rb +3 -0
- data/test/fixtures/comment.rb +5 -0
- data/test/fixtures/comments.yml +17 -0
- data/test/fixtures/company.rb +3 -0
- data/test/fixtures/courses.yml +4 -4
- data/test/fixtures/db_definitions/db2.drop.sql +6 -0
- data/test/fixtures/db_definitions/db2.sql +46 -0
- data/test/fixtures/db_definitions/mysql.drop.sql +6 -1
- data/test/fixtures/db_definitions/mysql.sql +60 -12
- data/test/fixtures/db_definitions/mysql2.sql +1 -1
- data/test/fixtures/db_definitions/oci.drop.sql +5 -0
- data/test/fixtures/db_definitions/oci.sql +45 -0
- data/test/fixtures/db_definitions/postgresql.drop.sql +6 -0
- data/test/fixtures/db_definitions/postgresql.sql +45 -0
- data/test/fixtures/db_definitions/sqlite.drop.sql +6 -1
- data/test/fixtures/db_definitions/sqlite.sql +46 -0
- data/test/fixtures/db_definitions/sqlserver.drop.sql +7 -1
- data/test/fixtures/db_definitions/sqlserver.sql +46 -0
- data/test/fixtures/fk_test_has_fk.yml +3 -0
- data/test/fixtures/fk_test_has_pk.yml +2 -0
- data/test/fixtures/mixin.rb +18 -0
- data/test/fixtures/mixins.yml +30 -0
- data/test/fixtures/post.rb +8 -0
- data/test/fixtures/posts.yml +20 -0
- data/test/fixtures/task.rb +3 -0
- data/test/fixtures/tasks.yml +7 -0
- data/test/fixtures_test.rb +34 -2
- data/test/mixin_nested_set_test.rb +184 -0
- data/test/mixin_test.rb +28 -3
- data/test/validations_test.rb +16 -0
- metadata +21 -5
- data/test/fixtures/db_definitions/drop_oracle_tables.sql +0 -35
- data/test/fixtures/db_definitions/drop_oracle_tables2.sql +0 -3
data/test/mixin_test.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'abstract_unit'
|
2
2
|
require 'active_record/acts/tree'
|
3
3
|
require 'active_record/acts/list'
|
4
|
+
require 'active_record/acts/nested_set'
|
4
5
|
require 'fixtures/mixin'
|
5
6
|
|
6
7
|
class ListTest < Test::Unit::TestCase
|
7
8
|
fixtures :mixins
|
8
|
-
|
9
|
+
|
9
10
|
def test_reordering
|
10
11
|
|
11
12
|
assert_equal [@mixins['list_1'].find,
|
@@ -100,6 +101,32 @@ class ListTest < Test::Unit::TestCase
|
|
100
101
|
assert new.first?
|
101
102
|
assert new.last?
|
102
103
|
end
|
104
|
+
|
105
|
+
def test_insert_at
|
106
|
+
new = ListMixin.create("parent_id" => 20)
|
107
|
+
assert_equal 1, new.pos
|
108
|
+
|
109
|
+
new = ListMixin.create("parent_id" => 20)
|
110
|
+
assert_equal 2, new.pos
|
111
|
+
|
112
|
+
new = ListMixin.create("parent_id" => 20)
|
113
|
+
assert_equal 3, new.pos
|
114
|
+
|
115
|
+
new4 = ListMixin.create("parent_id" => 20)
|
116
|
+
assert_equal 4, new4.pos
|
117
|
+
|
118
|
+
new4.insert_at(3)
|
119
|
+
assert_equal 3, new4.pos
|
120
|
+
|
121
|
+
new.reload
|
122
|
+
assert_equal 4, new.pos
|
123
|
+
|
124
|
+
new.insert_at(2)
|
125
|
+
assert_equal 2, new.pos
|
126
|
+
|
127
|
+
new4.reload
|
128
|
+
assert_equal 4, new4.pos
|
129
|
+
end
|
103
130
|
|
104
131
|
def test_delete_middle
|
105
132
|
|
@@ -186,7 +213,6 @@ class TreeTest < Test::Unit::TestCase
|
|
186
213
|
assert @tree_1.children.include?(@tree_2)
|
187
214
|
assert @tree_1.children.include?(@tree_4)
|
188
215
|
end
|
189
|
-
|
190
216
|
|
191
217
|
end
|
192
218
|
|
@@ -229,7 +255,6 @@ class TouchTest < Test::Unit::TestCase
|
|
229
255
|
|
230
256
|
end
|
231
257
|
|
232
|
-
|
233
258
|
def test_create_turned_off
|
234
259
|
Mixin.record_timestamps = false
|
235
260
|
|
data/test/validations_test.rb
CHANGED
@@ -64,6 +64,11 @@ class ValidationsTest < Test::Unit::TestCase
|
|
64
64
|
assert_equal "is Wrong Update", r.errors.on("title"), "A reply with a bad content should contain an error"
|
65
65
|
end
|
66
66
|
|
67
|
+
def test_invalid_record_exception
|
68
|
+
r = Reply.new
|
69
|
+
assert_raises(ActiveRecord::RecordInvalid) { r.save! }
|
70
|
+
end
|
71
|
+
|
67
72
|
def test_single_error_per_attr_iteration
|
68
73
|
r = Reply.new
|
69
74
|
r.save
|
@@ -189,6 +194,17 @@ class ValidationsTest < Test::Unit::TestCase
|
|
189
194
|
assert t.save
|
190
195
|
end
|
191
196
|
|
197
|
+
def test_terms_of_service_agreement_with_accept_value
|
198
|
+
Topic.validates_acceptance_of(:terms_of_service, :on => :create, :accept => "I agree.")
|
199
|
+
|
200
|
+
t = Topic.create("title" => "We should be confirmed", "terms_of_service" => "")
|
201
|
+
assert !t.save
|
202
|
+
assert_equal "must be accepted", t.errors.on(:terms_of_service)
|
203
|
+
|
204
|
+
t.terms_of_service = "I agree."
|
205
|
+
assert t.save
|
206
|
+
end
|
207
|
+
|
192
208
|
def test_validate_presences
|
193
209
|
Topic.validates_presence_of(:title, :content)
|
194
210
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.8
|
|
3
3
|
specification_version: 1
|
4
4
|
name: activerecord
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date: 2005-
|
6
|
+
version: 1.10.0
|
7
|
+
date: 2005-04-19
|
8
8
|
summary: Implements the ActiveRecord pattern for ORM.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- lib/active_record/callbacks.rb
|
45
45
|
- lib/active_record/connection_adapters
|
46
46
|
- lib/active_record/deprecated_associations.rb
|
47
|
+
- lib/active_record/deprecated_finders.rb
|
47
48
|
- lib/active_record/fixtures.rb
|
48
49
|
- lib/active_record/locking.rb
|
49
50
|
- lib/active_record/migration.rb
|
@@ -56,6 +57,7 @@ files:
|
|
56
57
|
- lib/active_record/wrappers
|
57
58
|
- lib/active_record/wrappings.rb
|
58
59
|
- lib/active_record/acts/list.rb
|
60
|
+
- lib/active_record/acts/nested_set.rb
|
59
61
|
- lib/active_record/acts/tree.rb
|
60
62
|
- lib/active_record/associations/association_collection.rb
|
61
63
|
- lib/active_record/associations/association_proxy.rb
|
@@ -81,6 +83,7 @@ files:
|
|
81
83
|
- test/aggregations_test.rb
|
82
84
|
- test/all.sh
|
83
85
|
- test/association_inheritance_reload.rb
|
86
|
+
- test/associations_go_eager_test.rb
|
84
87
|
- test/associations_test.rb
|
85
88
|
- test/base_test.rb
|
86
89
|
- test/binary_test.rb
|
@@ -89,6 +92,7 @@ files:
|
|
89
92
|
- test/column_alias_test.rb
|
90
93
|
- test/connections
|
91
94
|
- test/deprecated_associations_test.rb
|
95
|
+
- test/deprecated_finder_test.rb
|
92
96
|
- test/finder_test.rb
|
93
97
|
- test/fixtures
|
94
98
|
- test/fixtures_test.rb
|
@@ -96,6 +100,7 @@ files:
|
|
96
100
|
- test/lifecycle_test.rb
|
97
101
|
- test/locking_test.rb
|
98
102
|
- test/migration_mysql.rb
|
103
|
+
- test/mixin_nested_set_test.rb
|
99
104
|
- test/mixin_test.rb
|
100
105
|
- test/modules_test.rb
|
101
106
|
- test/multiple_db_test.rb
|
@@ -121,10 +126,17 @@ files:
|
|
121
126
|
- test/connections/native_sqlserver/connection.rb
|
122
127
|
- test/fixtures/accounts.yml
|
123
128
|
- test/fixtures/associations.png
|
129
|
+
- test/fixtures/author.rb
|
130
|
+
- test/fixtures/authors.yml
|
124
131
|
- test/fixtures/auto_id.rb
|
125
132
|
- test/fixtures/bad_fixtures
|
126
133
|
- test/fixtures/binary.rb
|
134
|
+
- test/fixtures/categories.yml
|
135
|
+
- test/fixtures/categories_posts.yml
|
136
|
+
- test/fixtures/category.rb
|
127
137
|
- test/fixtures/column_name.rb
|
138
|
+
- test/fixtures/comment.rb
|
139
|
+
- test/fixtures/comments.yml
|
128
140
|
- test/fixtures/companies.yml
|
129
141
|
- test/fixtures/company.rb
|
130
142
|
- test/fixtures/company_in_module.rb
|
@@ -142,6 +154,8 @@ files:
|
|
142
154
|
- test/fixtures/developers_projects.yml
|
143
155
|
- test/fixtures/entrant.rb
|
144
156
|
- test/fixtures/entrants.yml
|
157
|
+
- test/fixtures/fk_test_has_fk.yml
|
158
|
+
- test/fixtures/fk_test_has_pk.yml
|
145
159
|
- test/fixtures/migrations
|
146
160
|
- test/fixtures/mixin.rb
|
147
161
|
- test/fixtures/mixins.yml
|
@@ -150,11 +164,15 @@ files:
|
|
150
164
|
- test/fixtures/naked
|
151
165
|
- test/fixtures/people.yml
|
152
166
|
- test/fixtures/person.rb
|
167
|
+
- test/fixtures/post.rb
|
168
|
+
- test/fixtures/posts.yml
|
153
169
|
- test/fixtures/project.rb
|
154
170
|
- test/fixtures/projects.yml
|
155
171
|
- test/fixtures/reply.rb
|
156
172
|
- test/fixtures/subscriber.rb
|
157
173
|
- test/fixtures/subscribers
|
174
|
+
- test/fixtures/task.rb
|
175
|
+
- test/fixtures/tasks.yml
|
158
176
|
- test/fixtures/topic.rb
|
159
177
|
- test/fixtures/topics.yml
|
160
178
|
- test/fixtures/bad_fixtures/attr_with_numeric_first_char
|
@@ -168,8 +186,6 @@ files:
|
|
168
186
|
- test/fixtures/db_definitions/db2.sql
|
169
187
|
- test/fixtures/db_definitions/db22.drop.sql
|
170
188
|
- test/fixtures/db_definitions/db22.sql
|
171
|
-
- test/fixtures/db_definitions/drop_oracle_tables.sql
|
172
|
-
- test/fixtures/db_definitions/drop_oracle_tables2.sql
|
173
189
|
- test/fixtures/db_definitions/mysql.drop.sql
|
174
190
|
- test/fixtures/db_definitions/mysql.sql
|
175
191
|
- test/fixtures/db_definitions/mysql2.drop.sql
|
@@ -225,5 +241,5 @@ dependencies:
|
|
225
241
|
-
|
226
242
|
- "="
|
227
243
|
- !ruby/object:Gem::Version
|
228
|
-
version: 1.0.
|
244
|
+
version: 1.0.4
|
229
245
|
version:
|
@@ -1,35 +0,0 @@
|
|
1
|
-
DROP TABLE accounts;
|
2
|
-
DROP SEQUENCE accounts_id;
|
3
|
-
DROP TABLE companies;
|
4
|
-
DROP SEQUENCE companies_id;
|
5
|
-
DROP TABLE topics;
|
6
|
-
DROP SEQUENCE topics_id;
|
7
|
-
DROP TABLE developers;
|
8
|
-
DROP SEQUENCE developers_id;
|
9
|
-
DROP TABLE projects;
|
10
|
-
DROP SEQUENCE projects_id;
|
11
|
-
DROP TABLE developers_projects;
|
12
|
-
DROP SEQUENCE developers_projects_id;
|
13
|
-
DROP TABLE customers;
|
14
|
-
DROP SEQUENCE customers_id;
|
15
|
-
DROP TABLE movies;
|
16
|
-
DROP SEQUENCE movies_id;
|
17
|
-
DROP TABLE subscribers;
|
18
|
-
DROP SEQUENCE subscribers_id;
|
19
|
-
DROP TABLE booleantests;
|
20
|
-
DROP SEQUENCE booleantests_id;
|
21
|
-
DROP TABLE auto_id_tests;
|
22
|
-
DROP SEQUENCE auto_id_tests_id;
|
23
|
-
DROP TABLE entrants;
|
24
|
-
DROP SEQUENCE entrants_id;
|
25
|
-
DROP TABLE colnametests;
|
26
|
-
DROP SEQUENCE colnametests_id;
|
27
|
-
DROP TABLE mixins;
|
28
|
-
DROP SEQUENCE mixins_id;
|
29
|
-
DROP TABLE people;
|
30
|
-
DROP SEQUENCE people_id;
|
31
|
-
DROP TABLE binaries;
|
32
|
-
DROP SEQUENCE binaries_id;
|
33
|
-
DROP TABLE computers;
|
34
|
-
DROP SEQUENCE computers_id;
|
35
|
-
EXIT;
|