activerecord 1.15.6 → 2.0.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 +2454 -34
- data/README +1 -1
- data/RUNNING_UNIT_TESTS +3 -34
- data/Rakefile +98 -77
- data/install.rb +1 -1
- data/lib/active_record.rb +13 -22
- data/lib/active_record/aggregations.rb +38 -49
- data/lib/active_record/associations.rb +452 -333
- data/lib/active_record/associations/association_collection.rb +66 -20
- data/lib/active_record/associations/association_proxy.rb +9 -8
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +46 -51
- data/lib/active_record/associations/has_many_association.rb +21 -57
- data/lib/active_record/associations/has_many_through_association.rb +38 -18
- data/lib/active_record/associations/has_one_association.rb +30 -14
- data/lib/active_record/attribute_methods.rb +253 -0
- data/lib/active_record/base.rb +719 -494
- data/lib/active_record/calculations.rb +62 -63
- data/lib/active_record/callbacks.rb +57 -83
- data/lib/active_record/connection_adapters/abstract/connection_specification.rb +38 -9
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +56 -15
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +87 -0
- data/lib/active_record/connection_adapters/abstract/quoting.rb +23 -12
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +191 -62
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +37 -34
- data/lib/active_record/connection_adapters/abstract_adapter.rb +28 -17
- data/lib/active_record/connection_adapters/mysql_adapter.rb +119 -37
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +473 -210
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +34 -0
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +91 -107
- data/lib/active_record/fixtures.rb +503 -113
- data/lib/active_record/locking/optimistic.rb +72 -34
- data/lib/active_record/migration.rb +80 -57
- data/lib/active_record/observer.rb +13 -10
- data/lib/active_record/query_cache.rb +16 -57
- data/lib/active_record/reflection.rb +35 -38
- data/lib/active_record/schema.rb +5 -5
- data/lib/active_record/schema_dumper.rb +35 -13
- data/lib/active_record/serialization.rb +98 -0
- data/lib/active_record/serializers/json_serializer.rb +71 -0
- data/lib/active_record/{xml_serialization.rb → serializers/xml_serializer.rb} +90 -83
- data/lib/active_record/timestamp.rb +20 -21
- data/lib/active_record/transactions.rb +39 -43
- data/lib/active_record/validations.rb +256 -107
- data/lib/active_record/version.rb +3 -3
- data/lib/activerecord.rb +1 -0
- data/test/aaa_create_tables_test.rb +15 -2
- data/test/abstract_unit.rb +24 -17
- data/test/active_schema_test_mysql.rb +20 -8
- data/test/adapter_test.rb +23 -5
- data/test/adapter_test_sqlserver.rb +15 -1
- data/test/aggregations_test.rb +16 -1
- data/test/all.sh +2 -2
- data/test/associations/ar_joins_test.rb +0 -0
- data/test/associations/callbacks_test.rb +51 -30
- data/test/associations/cascaded_eager_loading_test.rb +1 -29
- data/test/associations/eager_singularization_test.rb +145 -0
- data/test/associations/eager_test.rb +42 -6
- data/test/associations/extension_test.rb +6 -1
- data/test/associations/inner_join_association_test.rb +88 -0
- data/test/associations/join_model_test.rb +47 -16
- data/test/associations_test.rb +449 -226
- data/test/attribute_methods_test.rb +97 -0
- data/test/base_test.rb +251 -105
- data/test/binary_test.rb +22 -27
- data/test/calculations_test.rb +37 -5
- data/test/callbacks_test.rb +23 -0
- data/test/connection_test_firebird.rb +2 -2
- data/test/connection_test_mysql.rb +30 -0
- data/test/connections/native_mysql/connection.rb +3 -0
- data/test/connections/native_sqlite/connection.rb +5 -14
- data/test/connections/native_sqlite3/connection.rb +5 -14
- data/test/connections/native_sqlite3/in_memory_connection.rb +1 -1
- data/test/{copy_table_sqlite.rb → copy_table_test_sqlite.rb} +8 -3
- data/test/datatype_test_postgresql.rb +178 -27
- data/test/{empty_date_time_test.rb → date_time_test.rb} +13 -1
- data/test/defaults_test.rb +8 -1
- data/test/deprecated_finder_test.rb +7 -128
- data/test/finder_test.rb +192 -54
- data/test/fixtures/all/developers.yml +0 -0
- data/test/fixtures/all/people.csv +0 -0
- data/test/fixtures/all/tasks.yml +0 -0
- data/test/fixtures/author.rb +12 -5
- data/test/fixtures/binaries.yml +130 -435
- data/test/fixtures/category.rb +6 -0
- data/test/fixtures/company.rb +8 -1
- data/test/fixtures/computer.rb +1 -0
- data/test/fixtures/contact.rb +16 -0
- data/test/fixtures/customer.rb +2 -2
- data/test/fixtures/db_definitions/db2.drop.sql +1 -0
- data/test/fixtures/db_definitions/db2.sql +4 -0
- data/test/fixtures/db_definitions/firebird.drop.sql +3 -1
- data/test/fixtures/db_definitions/firebird.sql +6 -0
- data/test/fixtures/db_definitions/frontbase.drop.sql +1 -0
- data/test/fixtures/db_definitions/frontbase.sql +5 -0
- data/test/fixtures/db_definitions/openbase.sql +41 -25
- data/test/fixtures/db_definitions/oracle.drop.sql +2 -0
- data/test/fixtures/db_definitions/oracle.sql +5 -0
- data/test/fixtures/db_definitions/postgresql.drop.sql +7 -0
- data/test/fixtures/db_definitions/postgresql.sql +87 -58
- data/test/fixtures/db_definitions/postgresql2.sql +1 -2
- data/test/fixtures/db_definitions/schema.rb +280 -0
- data/test/fixtures/db_definitions/schema2.rb +11 -0
- data/test/fixtures/db_definitions/sqlite.drop.sql +1 -0
- data/test/fixtures/db_definitions/sqlite.sql +4 -0
- data/test/fixtures/db_definitions/sybase.drop.sql +1 -0
- data/test/fixtures/db_definitions/sybase.sql +4 -0
- data/test/fixtures/developer.rb +10 -0
- data/test/fixtures/example.log +1 -0
- data/test/fixtures/flowers.jpg +0 -0
- data/test/fixtures/item.rb +7 -0
- data/test/fixtures/items.yml +4 -0
- data/test/fixtures/joke.rb +0 -3
- data/test/fixtures/matey.rb +4 -0
- data/test/fixtures/mateys.yml +4 -0
- data/test/fixtures/minimalistic.rb +2 -0
- data/test/fixtures/minimalistics.yml +2 -0
- data/test/fixtures/mixins.yml +2 -100
- data/test/fixtures/parrot.rb +13 -0
- data/test/fixtures/parrots.yml +27 -0
- data/test/fixtures/parrots_pirates.yml +7 -0
- data/test/fixtures/pirate.rb +5 -0
- data/test/fixtures/pirates.yml +9 -0
- data/test/fixtures/post.rb +1 -0
- data/test/fixtures/project.rb +3 -2
- data/test/fixtures/reserved_words/distinct.yml +5 -0
- data/test/fixtures/reserved_words/distincts_selects.yml +11 -0
- data/test/fixtures/reserved_words/group.yml +14 -0
- data/test/fixtures/reserved_words/select.yml +8 -0
- data/test/fixtures/reserved_words/values.yml +7 -0
- data/test/fixtures/ship.rb +3 -0
- data/test/fixtures/ships.yml +5 -0
- data/test/fixtures/tagging.rb +4 -0
- data/test/fixtures/taggings.yml +8 -1
- data/test/fixtures/topic.rb +13 -1
- data/test/fixtures/treasure.rb +4 -0
- data/test/fixtures/treasures.yml +10 -0
- data/test/fixtures_test.rb +205 -24
- data/test/inheritance_test.rb +7 -1
- data/test/json_serialization_test.rb +180 -0
- data/test/lifecycle_test.rb +1 -1
- data/test/locking_test.rb +85 -2
- data/test/migration_test.rb +206 -40
- data/test/mixin_test.rb +13 -515
- data/test/pk_test.rb +3 -6
- data/test/query_cache_test.rb +104 -0
- data/test/reflection_test.rb +16 -0
- data/test/reserved_word_test_mysql.rb +177 -0
- data/test/schema_dumper_test.rb +38 -3
- data/test/serialization_test.rb +47 -0
- data/test/transactions_test.rb +74 -23
- data/test/unconnected_test.rb +1 -1
- data/test/validations_test.rb +322 -32
- data/test/xml_serialization_test.rb +121 -44
- metadata +48 -41
- data/examples/associations.rb +0 -87
- data/examples/shared_setup.rb +0 -15
- data/examples/validation.rb +0 -85
- data/lib/active_record/acts/list.rb +0 -256
- data/lib/active_record/acts/nested_set.rb +0 -211
- data/lib/active_record/acts/tree.rb +0 -96
- data/lib/active_record/connection_adapters/db2_adapter.rb +0 -228
- data/lib/active_record/connection_adapters/firebird_adapter.rb +0 -728
- data/lib/active_record/connection_adapters/frontbase_adapter.rb +0 -861
- data/lib/active_record/connection_adapters/openbase_adapter.rb +0 -350
- data/lib/active_record/connection_adapters/oracle_adapter.rb +0 -690
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +0 -591
- data/lib/active_record/connection_adapters/sybase_adapter.rb +0 -662
- data/lib/active_record/deprecated_associations.rb +0 -104
- data/lib/active_record/deprecated_finders.rb +0 -44
- data/lib/active_record/vendor/simple.rb +0 -693
- data/lib/active_record/wrappers/yaml_wrapper.rb +0 -15
- data/lib/active_record/wrappings.rb +0 -58
- data/test/connections/native_sqlserver/connection.rb +0 -23
- data/test/connections/native_sqlserver_odbc/connection.rb +0 -25
- data/test/deprecated_associations_test.rb +0 -396
- data/test/fixtures/db_definitions/mysql.drop.sql +0 -32
- data/test/fixtures/db_definitions/mysql.sql +0 -234
- data/test/fixtures/db_definitions/mysql2.drop.sql +0 -2
- data/test/fixtures/db_definitions/mysql2.sql +0 -5
- data/test/fixtures/db_definitions/sqlserver.drop.sql +0 -34
- data/test/fixtures/db_definitions/sqlserver.sql +0 -243
- data/test/fixtures/db_definitions/sqlserver2.drop.sql +0 -2
- data/test/fixtures/db_definitions/sqlserver2.sql +0 -5
- data/test/fixtures/mixin.rb +0 -63
- data/test/mixin_nested_set_test.rb +0 -196
@@ -1,5 +1,214 @@
|
|
1
1
|
ActiveRecord::Schema.define do
|
2
2
|
|
3
|
+
# adapter name is checked because we are under a transition of
|
4
|
+
# moving the sql files under activerecord/test/fixtures/db_definitions
|
5
|
+
# to this file, schema.rb.
|
6
|
+
if adapter_name == "MySQL"
|
7
|
+
|
8
|
+
# Please keep these create table statements in alphabetical order
|
9
|
+
# unless the ordering matters. In which case, define them below
|
10
|
+
create_table :accounts, :force => true do |t|
|
11
|
+
t.integer :firm_id
|
12
|
+
t.integer :credit_limit
|
13
|
+
end
|
14
|
+
|
15
|
+
create_table :authors, :force => true do |t|
|
16
|
+
t.string :name, :null => false
|
17
|
+
end
|
18
|
+
|
19
|
+
create_table :auto_id_tests, :force => true, :id => false do |t|
|
20
|
+
t.primary_key :auto_id
|
21
|
+
t.integer :value
|
22
|
+
end
|
23
|
+
|
24
|
+
create_table :binaries, :force => true do |t|
|
25
|
+
t.binary :data
|
26
|
+
end
|
27
|
+
|
28
|
+
create_table :booleantests, :force => true do |t|
|
29
|
+
t.integer :value
|
30
|
+
end
|
31
|
+
|
32
|
+
create_table :categories, :force => true do |t|
|
33
|
+
t.string :name, :null => false
|
34
|
+
t.string :type
|
35
|
+
end
|
36
|
+
|
37
|
+
create_table :categories_posts, :force => true, :id => false do |t|
|
38
|
+
t.integer :category_id, :null => false
|
39
|
+
t.integer :post_id, :null => false
|
40
|
+
end
|
41
|
+
|
42
|
+
create_table :colnametests, :force => true do |t|
|
43
|
+
t.integer :references, :null => false
|
44
|
+
end
|
45
|
+
|
46
|
+
create_table :comments, :force => true do |t|
|
47
|
+
t.integer :post_id, :null => false
|
48
|
+
t.text :body, :null => false
|
49
|
+
t.string :type
|
50
|
+
end
|
51
|
+
|
52
|
+
create_table :companies, :force => true do |t|
|
53
|
+
t.string :type
|
54
|
+
t.string :ruby_type
|
55
|
+
t.integer :firm_id
|
56
|
+
t.string :name
|
57
|
+
t.integer :client_of
|
58
|
+
t.integer :rating, :default => 1
|
59
|
+
end
|
60
|
+
|
61
|
+
create_table :computers, :force => true do |t|
|
62
|
+
t.integer :developer, :null => false
|
63
|
+
t.integer :extendedWarranty, :null => false
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
create_table :customers, :force => true do |t|
|
68
|
+
t.string :name
|
69
|
+
t.integer :balance, :default => 0
|
70
|
+
t.string :address_street
|
71
|
+
t.string :address_city
|
72
|
+
t.string :address_country
|
73
|
+
t.string :gps_location
|
74
|
+
end
|
75
|
+
|
76
|
+
create_table :developers, :force => true do |t|
|
77
|
+
t.string :name
|
78
|
+
t.integer :salary, :default => 70000
|
79
|
+
t.datetime :created_at
|
80
|
+
t.datetime :updated_at
|
81
|
+
end
|
82
|
+
|
83
|
+
create_table :developers_projects, :force => true, :id => false do |t|
|
84
|
+
t.integer :developer_id, :null => false
|
85
|
+
t.integer :project_id, :null => false
|
86
|
+
t.date :joined_on
|
87
|
+
t.integer :access_level, :default => 1
|
88
|
+
end
|
89
|
+
|
90
|
+
create_table :entrants, :force => true do |t|
|
91
|
+
t.string :name, :null => false
|
92
|
+
t.integer :course_id, :null => false
|
93
|
+
end
|
94
|
+
|
95
|
+
create_table :funny_jokes, :force => true do |t|
|
96
|
+
t.string :name
|
97
|
+
end
|
98
|
+
|
99
|
+
create_table :keyboards, :force => true, :id => false do |t|
|
100
|
+
t.primary_key :key_number
|
101
|
+
t.string :name
|
102
|
+
end
|
103
|
+
|
104
|
+
create_table :legacy_things, :force => true do |t|
|
105
|
+
t.integer :tps_report_number
|
106
|
+
t.integer :version, :null => false, :default => 0
|
107
|
+
end
|
108
|
+
|
109
|
+
create_table :minimalistics, :force => true do |t|
|
110
|
+
end
|
111
|
+
|
112
|
+
create_table :mixed_case_monkeys, :force => true, :id => false do |t|
|
113
|
+
t.primary_key :monkeyID
|
114
|
+
t.integer :fleaCount
|
115
|
+
end
|
116
|
+
|
117
|
+
create_table :mixins, :force => true do |t|
|
118
|
+
t.integer :parent_id
|
119
|
+
t.integer :pos
|
120
|
+
t.datetime :created_at
|
121
|
+
t.datetime :updated_at
|
122
|
+
t.integer :lft
|
123
|
+
t.integer :rgt
|
124
|
+
t.integer :root_id
|
125
|
+
t.string :type
|
126
|
+
end
|
127
|
+
|
128
|
+
create_table :movies, :force => true, :id => false do |t|
|
129
|
+
t.primary_key :movieid
|
130
|
+
t.string :name
|
131
|
+
end
|
132
|
+
|
133
|
+
create_table :numeric_data, :force => true do |t|
|
134
|
+
t.decimal :bank_balance, :precision => 10, :scale => 2
|
135
|
+
t.decimal :big_bank_balance, :precision => 15, :scale => 2
|
136
|
+
t.decimal :world_population, :precision => 10, :scale => 0
|
137
|
+
t.decimal :my_house_population, :precision => 2, :scale => 0
|
138
|
+
t.decimal :decimal_number_with_default, :precision => 3, :scale => 2, :default => 2.78
|
139
|
+
end
|
140
|
+
|
141
|
+
create_table :orders, :force => true do |t|
|
142
|
+
t.string :name
|
143
|
+
t.integer :billing_customer_id
|
144
|
+
t.integer :shipping_customer_id
|
145
|
+
end
|
146
|
+
|
147
|
+
create_table :people, :force => true do |t|
|
148
|
+
t.string :first_name, :null => false
|
149
|
+
t.integer :lock_version, :null => false, :default => 0
|
150
|
+
end
|
151
|
+
|
152
|
+
create_table :posts, :force => true do |t|
|
153
|
+
t.integer :author_id
|
154
|
+
t.string :title, :null => false
|
155
|
+
t.text :body, :null => false
|
156
|
+
t.string :type
|
157
|
+
end
|
158
|
+
|
159
|
+
create_table :projects, :force => true do |t|
|
160
|
+
t.string :name
|
161
|
+
t.string :type
|
162
|
+
end
|
163
|
+
|
164
|
+
create_table :readers, :force => true do |t|
|
165
|
+
t.integer :post_id, :null => false
|
166
|
+
t.integer :person_id, :null => false
|
167
|
+
end
|
168
|
+
|
169
|
+
create_table :subscribers, :force => true, :id => false do |t|
|
170
|
+
t.string :nick, :null => false
|
171
|
+
t.string :name
|
172
|
+
end
|
173
|
+
add_index :subscribers, :nick, :unique => true
|
174
|
+
|
175
|
+
create_table :tasks, :force => true do |t|
|
176
|
+
t.datetime :starting
|
177
|
+
t.datetime :ending
|
178
|
+
end
|
179
|
+
|
180
|
+
create_table :topics, :force => true do |t|
|
181
|
+
t.string :title
|
182
|
+
t.string :author_name
|
183
|
+
t.string :author_email_address
|
184
|
+
t.datetime :written_on
|
185
|
+
t.time :bonus_time
|
186
|
+
t.date :last_read
|
187
|
+
t.text :content
|
188
|
+
t.boolean :approved, :default => true
|
189
|
+
t.integer :replies_count, :default => 0
|
190
|
+
t.integer :parent_id
|
191
|
+
t.string :type
|
192
|
+
end
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
### These tables are created last as the order is significant
|
197
|
+
|
198
|
+
# fk_test_has_fk should be before fk_test_has_pk
|
199
|
+
create_table :fk_test_has_fk, :force => true do |t|
|
200
|
+
t.integer :fk_id, :null => false
|
201
|
+
end
|
202
|
+
|
203
|
+
create_table :fk_test_has_pk, :force => true do |t|
|
204
|
+
end
|
205
|
+
|
206
|
+
execute 'alter table fk_test_has_fk
|
207
|
+
add FOREIGN KEY (`fk_id`) REFERENCES `fk_test_has_pk`(`id`)'
|
208
|
+
|
209
|
+
|
210
|
+
end
|
211
|
+
|
3
212
|
# For Firebird, set the sequence values 10000 when create_table is called;
|
4
213
|
# this prevents primary key collisions between "normally" created records
|
5
214
|
# and fixture-based (YAML) records.
|
@@ -58,6 +267,24 @@ ActiveRecord::Schema.define do
|
|
58
267
|
t.column :custom_lock_version, :integer
|
59
268
|
end
|
60
269
|
|
270
|
+
create_table :items, :force => true do |t|
|
271
|
+
t.column :name, :integer
|
272
|
+
end
|
273
|
+
|
274
|
+
# For sqlite 3.1.0+, make a table with a autoincrement column
|
275
|
+
if adapter_name == 'SQLite' and supports_autoincrement?
|
276
|
+
create_table :table_with_autoincrement, :force => true do |t|
|
277
|
+
t.column :name, :string
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
# For sqlserver 2000+, ensure real columns can be used
|
282
|
+
if adapter_name.starts_with?("SQLServer")
|
283
|
+
create_table :table_with_real_columns, :force => true do |t|
|
284
|
+
t.column :real_number, :real
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
61
288
|
create_table :audit_logs, :force => true do |t|
|
62
289
|
t.column :message, :string, :null=>false
|
63
290
|
t.column :developer_id, :integer, :null=>false
|
@@ -71,4 +298,57 @@ ActiveRecord::Schema.define do
|
|
71
298
|
t.column :book1_id, :integer
|
72
299
|
t.column :book2_id, :integer
|
73
300
|
end
|
301
|
+
|
302
|
+
create_table :inept_wizards, :force => true do |t|
|
303
|
+
t.column :name, :string, :null => false
|
304
|
+
t.column :city, :string, :null => false
|
305
|
+
t.column :type, :string
|
306
|
+
end
|
307
|
+
|
308
|
+
create_table :parrots, :force => true do |t|
|
309
|
+
t.column :name, :string
|
310
|
+
t.column :parrot_sti_class, :string
|
311
|
+
t.column :killer_id, :integer
|
312
|
+
t.column :created_at, :datetime
|
313
|
+
t.column :created_on, :datetime
|
314
|
+
t.column :updated_at, :datetime
|
315
|
+
t.column :updated_on, :datetime
|
316
|
+
end
|
317
|
+
|
318
|
+
create_table :pirates, :force => true do |t|
|
319
|
+
t.column :catchphrase, :string
|
320
|
+
t.column :parrot_id, :integer
|
321
|
+
t.column :created_on, :datetime
|
322
|
+
t.column :updated_on, :datetime
|
323
|
+
end
|
324
|
+
|
325
|
+
create_table :parrots_pirates, :id => false, :force => true do |t|
|
326
|
+
t.column :parrot_id, :integer
|
327
|
+
t.column :pirate_id, :integer
|
328
|
+
end
|
329
|
+
|
330
|
+
create_table :treasures, :force => true do |t|
|
331
|
+
t.column :name, :string
|
332
|
+
t.column :looter_id, :integer
|
333
|
+
t.column :looter_type, :string
|
334
|
+
end
|
335
|
+
|
336
|
+
create_table :parrots_treasures, :id => false, :force => true do |t|
|
337
|
+
t.column :parrot_id, :integer
|
338
|
+
t.column :treasure_id, :integer
|
339
|
+
end
|
340
|
+
|
341
|
+
create_table :mateys, :id => false, :force => true do |t|
|
342
|
+
t.column :pirate_id, :integer
|
343
|
+
t.column :target_id, :integer
|
344
|
+
t.column :weight, :integer
|
345
|
+
end
|
346
|
+
|
347
|
+
create_table :ships, :force => true do |t|
|
348
|
+
t.string :name
|
349
|
+
t.datetime :created_at
|
350
|
+
t.datetime :created_on
|
351
|
+
t.datetime :updated_at
|
352
|
+
t.datetime :updated_on
|
353
|
+
end
|
74
354
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
ActiveRecord::Schema.define do
|
2
|
+
|
3
|
+
# adapter name is checked because we are under a transition of
|
4
|
+
# moving the sql files under activerecord/test/fixtures/db_definitions
|
5
|
+
# to this file, schema.rb.
|
6
|
+
if adapter_name == "MySQL"
|
7
|
+
Course.connection.create_table :courses, :force => true do |t|
|
8
|
+
t.column :name, :string, :null => false
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/test/fixtures/developer.rb
CHANGED
@@ -29,6 +29,16 @@ class Developer < ActiveRecord::Base
|
|
29
29
|
:association_foreign_key => "project_id",
|
30
30
|
:extend => [DeveloperProjectsAssociationExtension, DeveloperProjectsAssociationExtension2]
|
31
31
|
|
32
|
+
has_and_belongs_to_many :projects_extended_by_name_and_block,
|
33
|
+
:class_name => "Project",
|
34
|
+
:join_table => "developers_projects",
|
35
|
+
:association_foreign_key => "project_id",
|
36
|
+
:extend => DeveloperProjectsAssociationExtension do
|
37
|
+
def find_least_recent
|
38
|
+
find(:first, :order => "id ASC")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
32
42
|
has_and_belongs_to_many :special_projects, :join_table => 'developers_projects', :association_foreign_key => 'project_id'
|
33
43
|
|
34
44
|
has_many :audit_logs
|
@@ -0,0 +1 @@
|
|
1
|
+
# Logfile created on Wed Oct 31 16:05:13 +0000 2007 by logger.rb/1.5.2.9
|
data/test/fixtures/flowers.jpg
CHANGED
Binary file
|
data/test/fixtures/joke.rb
CHANGED
data/test/fixtures/mixins.yml
CHANGED
@@ -1,98 +1,8 @@
|
|
1
|
-
# tree mixins
|
2
|
-
tree_1:
|
3
|
-
id: 1001
|
4
|
-
type: TreeMixin
|
5
|
-
parent_id:
|
6
|
-
|
7
|
-
tree_2:
|
8
|
-
id: 1002
|
9
|
-
type: TreeMixin
|
10
|
-
parent_id: 1001
|
11
|
-
|
12
|
-
tree_3:
|
13
|
-
id: 1003
|
14
|
-
type: TreeMixin
|
15
|
-
parent_id: 1002
|
16
|
-
|
17
|
-
tree_4:
|
18
|
-
id: 1004
|
19
|
-
type: TreeMixin
|
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:
|
31
|
-
|
32
|
-
tree_without_order_1:
|
33
|
-
id: 1101
|
34
|
-
type: TreeMixinWithoutOrder
|
35
|
-
parent_id:
|
36
|
-
|
37
|
-
tree_without_order_2:
|
38
|
-
id: 1100
|
39
|
-
type: TreeMixinWithoutOrder
|
40
|
-
parent_id:
|
41
|
-
|
42
|
-
recursively_cascaded_tree_1:
|
43
|
-
id: 5005
|
44
|
-
type: RecursivelyCascadedTreeMixin
|
45
|
-
parent_id:
|
46
|
-
|
47
|
-
recursively_cascaded_tree_2:
|
48
|
-
id: 5006
|
49
|
-
type: RecursivelyCascadedTreeMixin
|
50
|
-
parent_id: 5005
|
51
|
-
|
52
|
-
recursively_cascaded_tree_3:
|
53
|
-
id: 5007
|
54
|
-
type: RecursivelyCascadedTreeMixin
|
55
|
-
parent_id: 5006
|
56
|
-
|
57
|
-
recursively_cascaded_tree_4:
|
58
|
-
id: 5008
|
59
|
-
type: RecursivelyCascadedTreeMixin
|
60
|
-
parent_id: 5007
|
61
|
-
|
62
|
-
# List mixins
|
63
|
-
|
64
|
-
<% (1..4).each do |counter| %>
|
65
|
-
list_<%= counter %>:
|
66
|
-
id: <%= counter+1006 %>
|
67
|
-
pos: <%= counter %>
|
68
|
-
type: ListMixin
|
69
|
-
parent_id: 5
|
70
|
-
<% end %>
|
71
|
-
|
72
1
|
# Nested set mixins
|
73
2
|
|
74
3
|
<% (1..10).each do |counter| %>
|
75
4
|
set_<%= counter %>:
|
76
5
|
id: <%= counter+3000 %>
|
77
|
-
type: NestedSet
|
78
|
-
<% end %>
|
79
|
-
|
80
|
-
# Nested set with STI
|
81
|
-
<%
|
82
|
-
[ [3100, 0, 1, 10, "NestedSetSuperclass"],
|
83
|
-
[3101, 3100, 2, 5, "NestedSetSubclass"],
|
84
|
-
[3102, 3101, 3, 4, "NestedSetSuperclass"],
|
85
|
-
[3103, 3100, 6, 9, "NestedSetSuperclass"],
|
86
|
-
[3104, 3103, 7, 8, "NestedSetSubclass"]
|
87
|
-
].each do |sti| %>
|
88
|
-
sti_set_<%= sti[0] %>:
|
89
|
-
id: <%= sti[0] %>
|
90
|
-
parent_id: <%= sti[1] %>
|
91
|
-
lft: <%= sti[2] %>
|
92
|
-
rgt: <%= sti[3] %>
|
93
|
-
type: <%= sti[4] %>
|
94
|
-
root_id: 3100
|
95
|
-
|
96
6
|
<% end %>
|
97
7
|
|
98
8
|
# Big old set
|
@@ -101,10 +11,10 @@ sti_set_<%= sti[0] %>:
|
|
101
11
|
[4002, 4001, 2, 7],
|
102
12
|
[4003, 4002, 3, 4],
|
103
13
|
[4004, 4002, 5, 6],
|
104
|
-
[4005, 4001,
|
14
|
+
[4005, 4001, 14, 13],
|
105
15
|
[4006, 4005, 9, 10],
|
106
16
|
[4007, 4005, 11, 12],
|
107
|
-
[4008, 4001,
|
17
|
+
[4008, 4001, 8, 19],
|
108
18
|
[4009, 4008, 15, 16],
|
109
19
|
[4010, 4008, 17, 18]].each do |set| %>
|
110
20
|
tree_<%= set[0] %>:
|
@@ -117,11 +27,3 @@ tree_<%= set[0] %>:
|
|
117
27
|
|
118
28
|
<% end %>
|
119
29
|
|
120
|
-
# subclasses of list items
|
121
|
-
<% (1..4).each do |i| %>
|
122
|
-
list_sub_<%= i %>:
|
123
|
-
id: <%= i + 5000 %>
|
124
|
-
pos: <%= i %>
|
125
|
-
parent_id: 5000
|
126
|
-
type: <%= (i % 2 == 1) ? ListMixinSub1 : ListMixinSub2 %>
|
127
|
-
<% end %>
|