ibm_db 2.5.6-x86-mswin32-60 → 2.5.7-x86-mswin32-60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +6 -0
- data/README +1 -1
- data/ext/Makefile.nt32 +3 -3
- data/ext/Makefile.nt32.191 +212 -0
- data/ext/ibm_db.c +30 -5
- data/lib/active_record/connection_adapters/ibm_db_adapter.rb +300 -108
- data/lib/active_record/connection_adapters/ibm_db_pstmt.rb +1 -1
- data/lib/mswin32/rb18x/ibm_db.so +0 -0
- data/test/cases/adapter_test.rb +25 -22
- data/test/cases/associations/belongs_to_associations_test.rb +245 -43
- data/test/cases/associations/cascaded_eager_loading_test.rb +28 -26
- data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +60 -156
- data/test/cases/associations/join_model_test.rb +96 -146
- data/test/cases/attribute_methods_test.rb +98 -33
- data/test/cases/base_test.rb +525 -103
- data/test/cases/calculations_test.rb +92 -8
- data/test/cases/migration_test.rb +533 -207
- data/test/cases/persistence_test.rb +636 -0
- data/test/cases/query_cache_test.rb +242 -0
- data/test/cases/relations_test.rb +1019 -0
- data/test/cases/schema_dumper_test.rb +37 -17
- data/test/cases/transaction_callbacks_test.rb +300 -0
- data/test/cases/validations/uniqueness_validation_test.rb +38 -22
- data/test/cases/xml_serialization_test.rb +276 -0
- data/test/config.yml +154 -0
- data/test/connections/native_ibm_db/connection.rb +2 -0
- data/test/models/warehouse_thing.rb +4 -4
- data/test/schema/i5/ibm_db_specific_schema.rb +3 -1
- data/test/schema/ids/ibm_db_specific_schema.rb +3 -1
- data/test/schema/luw/ibm_db_specific_schema.rb +2 -0
- data/test/schema/schema.rb +174 -89
- data/test/schema/zOS/ibm_db_specific_schema.rb +3 -1
- metadata +9 -7
- data/lib/mswin32/rb19x/ibm_db.so +0 -0
- data/test/cases/associations/eager_test.rb +0 -862
- data/test/cases/associations/has_many_through_associations_test.rb +0 -461
- data/test/cases/finder_test.rb +0 -1088
- data/test/cases/fixtures_test.rb +0 -684
@@ -1,461 +0,0 @@
|
|
1
|
-
require "cases/helper"
|
2
|
-
require 'models/post'
|
3
|
-
require 'models/person'
|
4
|
-
require 'models/reference'
|
5
|
-
require 'models/job'
|
6
|
-
require 'models/reader'
|
7
|
-
require 'models/comment'
|
8
|
-
require 'models/tag'
|
9
|
-
require 'models/tagging'
|
10
|
-
require 'models/author'
|
11
|
-
require 'models/owner'
|
12
|
-
require 'models/pet'
|
13
|
-
require 'models/toy'
|
14
|
-
require 'models/contract'
|
15
|
-
require 'models/company'
|
16
|
-
require 'models/developer'
|
17
|
-
require 'models/subscriber'
|
18
|
-
require 'models/book'
|
19
|
-
require 'models/subscription'
|
20
|
-
|
21
|
-
class HasManyThroughAssociationsTest < ActiveRecord::TestCase
|
22
|
-
fixtures :posts, :readers, :people, :comments, :authors,
|
23
|
-
:owners, :pets, :toys, :jobs, :references, :companies,
|
24
|
-
:subscribers, :books, :subscriptions, :developers
|
25
|
-
|
26
|
-
# Dummies to force column loads so query counts are clean.
|
27
|
-
def setup
|
28
|
-
Person.create :first_name => 'gummy'
|
29
|
-
Reader.create :person_id => 0, :post_id => 0
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_associate_existing
|
33
|
-
assert_queries(2) { posts(:thinking); people(:david) }
|
34
|
-
|
35
|
-
assert_queries(1) do
|
36
|
-
posts(:thinking).people << people(:david)
|
37
|
-
end
|
38
|
-
|
39
|
-
assert_queries(1) do
|
40
|
-
assert posts(:thinking).people.include?(people(:david))
|
41
|
-
end
|
42
|
-
|
43
|
-
assert posts(:thinking).reload.people(true).include?(people(:david))
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_associating_new
|
47
|
-
assert_queries(1) { posts(:thinking) }
|
48
|
-
new_person = nil # so block binding catches it
|
49
|
-
|
50
|
-
assert_queries(0) do
|
51
|
-
new_person = Person.new :first_name => 'bob'
|
52
|
-
end
|
53
|
-
|
54
|
-
# Associating new records always saves them
|
55
|
-
# Thus, 1 query for the new person record, 1 query for the new join table record
|
56
|
-
assert_queries(2) do
|
57
|
-
posts(:thinking).people << new_person
|
58
|
-
end
|
59
|
-
|
60
|
-
assert_queries(1) do
|
61
|
-
assert posts(:thinking).people.include?(new_person)
|
62
|
-
end
|
63
|
-
|
64
|
-
assert posts(:thinking).reload.people(true).include?(new_person)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_associate_new_by_building
|
68
|
-
assert_queries(1) { posts(:thinking) }
|
69
|
-
|
70
|
-
assert_queries(0) do
|
71
|
-
posts(:thinking).people.build(:first_name => "Bob")
|
72
|
-
posts(:thinking).people.new(:first_name => "Ted")
|
73
|
-
end
|
74
|
-
|
75
|
-
# Should only need to load the association once
|
76
|
-
assert_queries(1) do
|
77
|
-
assert posts(:thinking).people.collect(&:first_name).include?("Bob")
|
78
|
-
assert posts(:thinking).people.collect(&:first_name).include?("Ted")
|
79
|
-
end
|
80
|
-
|
81
|
-
# 2 queries for each new record (1 to save the record itself, 1 for the join model)
|
82
|
-
# * 2 new records = 4
|
83
|
-
# + 1 query to save the actual post = 5
|
84
|
-
assert_queries(5) do
|
85
|
-
posts(:thinking).body += '-changed'
|
86
|
-
posts(:thinking).save
|
87
|
-
end
|
88
|
-
|
89
|
-
assert posts(:thinking).reload.people(true).collect(&:first_name).include?("Bob")
|
90
|
-
assert posts(:thinking).reload.people(true).collect(&:first_name).include?("Ted")
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_delete_association
|
94
|
-
assert_queries(2){posts(:welcome);people(:michael); }
|
95
|
-
|
96
|
-
assert_queries(1) do
|
97
|
-
posts(:welcome).people.delete(people(:michael))
|
98
|
-
end
|
99
|
-
|
100
|
-
assert_queries(1) do
|
101
|
-
assert posts(:welcome).people.empty?
|
102
|
-
end
|
103
|
-
|
104
|
-
assert posts(:welcome).reload.people(true).empty?
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_destroy_association
|
108
|
-
assert_difference ["Person.count", "Reader.count"], -1 do
|
109
|
-
posts(:welcome).people.destroy(people(:michael))
|
110
|
-
end
|
111
|
-
|
112
|
-
assert posts(:welcome).reload.people.empty?
|
113
|
-
assert posts(:welcome).people(true).empty?
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_destroy_all
|
117
|
-
assert_difference ["Person.count", "Reader.count"], -1 do
|
118
|
-
posts(:welcome).people.destroy_all
|
119
|
-
end
|
120
|
-
|
121
|
-
assert posts(:welcome).reload.people.empty?
|
122
|
-
assert posts(:welcome).people(true).empty?
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_should_raise_exception_for_destroying_mismatching_records
|
126
|
-
assert_no_difference ["Person.count", "Reader.count"] do
|
127
|
-
assert_raise(ActiveRecord::AssociationTypeMismatch) { posts(:welcome).people.destroy(posts(:thinking)) }
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def test_replace_association
|
132
|
-
assert_queries(4){posts(:welcome);people(:david);people(:michael); posts(:welcome).people(true)}
|
133
|
-
|
134
|
-
# 1 query to delete the existing reader (michael)
|
135
|
-
# 1 query to associate the new reader (david)
|
136
|
-
assert_queries(2) do
|
137
|
-
posts(:welcome).people = [people(:david)]
|
138
|
-
end
|
139
|
-
|
140
|
-
assert_queries(0){
|
141
|
-
assert posts(:welcome).people.include?(people(:david))
|
142
|
-
assert !posts(:welcome).people.include?(people(:michael))
|
143
|
-
}
|
144
|
-
|
145
|
-
assert posts(:welcome).reload.people(true).include?(people(:david))
|
146
|
-
assert !posts(:welcome).reload.people(true).include?(people(:michael))
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_replace_order_is_preserved
|
150
|
-
posts(:welcome).people.clear
|
151
|
-
posts(:welcome).people = [people(:david), people(:michael)]
|
152
|
-
assert_equal [people(:david).id, people(:michael).id], posts(:welcome).readers.order('id').map(&:person_id)
|
153
|
-
|
154
|
-
# Test the inverse order in case the first success was a coincidence
|
155
|
-
posts(:welcome).people.clear
|
156
|
-
posts(:welcome).people = [people(:michael), people(:david)]
|
157
|
-
assert_equal [people(:michael).id, people(:david).id], posts(:welcome).readers.order('id').map(&:person_id)
|
158
|
-
end
|
159
|
-
|
160
|
-
def test_replace_by_id_order_is_preserved
|
161
|
-
posts(:welcome).people.clear
|
162
|
-
posts(:welcome).person_ids = [people(:david).id, people(:michael).id]
|
163
|
-
assert_equal [people(:david).id, people(:michael).id], posts(:welcome).readers.order('id').map(&:person_id)
|
164
|
-
|
165
|
-
# Test the inverse order in case the first success was a coincidence
|
166
|
-
posts(:welcome).people.clear
|
167
|
-
posts(:welcome).person_ids = [people(:michael).id, people(:david).id]
|
168
|
-
assert_equal [people(:michael).id, people(:david).id], posts(:welcome).readers.order('id').map(&:person_id)
|
169
|
-
end
|
170
|
-
|
171
|
-
def test_associate_with_create
|
172
|
-
assert_queries(1) { posts(:thinking) }
|
173
|
-
|
174
|
-
# 1 query for the new record, 1 for the join table record
|
175
|
-
# No need to update the actual collection yet!
|
176
|
-
assert_queries(2) do
|
177
|
-
posts(:thinking).people.create(:first_name=>"Jeb")
|
178
|
-
end
|
179
|
-
|
180
|
-
# *Now* we actually need the collection so it's loaded
|
181
|
-
assert_queries(1) do
|
182
|
-
assert posts(:thinking).people.collect(&:first_name).include?("Jeb")
|
183
|
-
end
|
184
|
-
|
185
|
-
assert posts(:thinking).reload.people(true).collect(&:first_name).include?("Jeb")
|
186
|
-
end
|
187
|
-
|
188
|
-
def test_associate_with_create_and_no_options
|
189
|
-
peeps = posts(:thinking).people.count
|
190
|
-
posts(:thinking).people.create(:first_name => 'foo')
|
191
|
-
assert_equal peeps + 1, posts(:thinking).people.count
|
192
|
-
end
|
193
|
-
|
194
|
-
def test_associate_with_create_with_through_having_conditions
|
195
|
-
impatient_people = posts(:thinking).impatient_people.count
|
196
|
-
posts(:thinking).impatient_people.create!(:first_name => 'foo')
|
197
|
-
assert_equal impatient_people + 1, posts(:thinking).impatient_people.count
|
198
|
-
end
|
199
|
-
|
200
|
-
def test_associate_with_create_exclamation_and_no_options
|
201
|
-
peeps = posts(:thinking).people.count
|
202
|
-
posts(:thinking).people.create!(:first_name => 'foo')
|
203
|
-
assert_equal peeps + 1, posts(:thinking).people.count
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_create_on_new_record
|
207
|
-
p = Post.new
|
208
|
-
|
209
|
-
assert_raises(ActiveRecord::RecordNotSaved) { p.people.create(:first_name => "mew") }
|
210
|
-
assert_raises(ActiveRecord::RecordNotSaved) { p.people.create!(:first_name => "snow") }
|
211
|
-
end
|
212
|
-
|
213
|
-
def test_associate_with_create_and_invalid_options
|
214
|
-
firm = companies(:first_firm)
|
215
|
-
assert_no_difference('firm.developers.count') { assert_nothing_raised { firm.developers.create(:name => '0') } }
|
216
|
-
end
|
217
|
-
|
218
|
-
def test_associate_with_create_and_valid_options
|
219
|
-
firm = companies(:first_firm)
|
220
|
-
assert_difference('firm.developers.count', 1) { firm.developers.create(:name => 'developer') }
|
221
|
-
end
|
222
|
-
|
223
|
-
def test_associate_with_create_bang_and_invalid_options
|
224
|
-
firm = companies(:first_firm)
|
225
|
-
assert_no_difference('firm.developers.count') { assert_raises(ActiveRecord::RecordInvalid) { firm.developers.create!(:name => '0') } }
|
226
|
-
end
|
227
|
-
|
228
|
-
def test_associate_with_create_bang_and_valid_options
|
229
|
-
firm = companies(:first_firm)
|
230
|
-
assert_difference('firm.developers.count', 1) { firm.developers.create!(:name => 'developer') }
|
231
|
-
end
|
232
|
-
|
233
|
-
def test_push_with_invalid_record
|
234
|
-
firm = companies(:first_firm)
|
235
|
-
assert_raises(ActiveRecord::RecordInvalid) { firm.developers << Developer.new(:name => '0') }
|
236
|
-
end
|
237
|
-
|
238
|
-
def test_push_with_invalid_join_record
|
239
|
-
repair_validations(Contract) do
|
240
|
-
Contract.validate {|r| r.errors[:base] << 'Invalid Contract' }
|
241
|
-
|
242
|
-
firm = companies(:first_firm)
|
243
|
-
lifo = Developer.new(:name => 'lifo')
|
244
|
-
assert_raises(ActiveRecord::RecordInvalid) { firm.developers << lifo }
|
245
|
-
|
246
|
-
lifo = Developer.create!(:name => 'lifo')
|
247
|
-
assert_raises(ActiveRecord::RecordInvalid) { firm.developers << lifo }
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
def test_clear_associations
|
252
|
-
assert_queries(2) { posts(:welcome);posts(:welcome).people(true) }
|
253
|
-
|
254
|
-
assert_queries(1) do
|
255
|
-
posts(:welcome).people.clear
|
256
|
-
end
|
257
|
-
|
258
|
-
assert_queries(0) do
|
259
|
-
assert posts(:welcome).people.empty?
|
260
|
-
end
|
261
|
-
|
262
|
-
assert posts(:welcome).reload.people(true).empty?
|
263
|
-
end
|
264
|
-
|
265
|
-
def test_association_callback_ordering
|
266
|
-
Post.reset_log
|
267
|
-
log = Post.log
|
268
|
-
post = posts(:thinking)
|
269
|
-
|
270
|
-
post.people_with_callbacks << people(:michael)
|
271
|
-
assert_equal [
|
272
|
-
[:added, :before, "Michael"],
|
273
|
-
[:added, :after, "Michael"]
|
274
|
-
], log.last(2)
|
275
|
-
|
276
|
-
post.people_with_callbacks.push(people(:david), Person.create!(:first_name => "Bob"), Person.new(:first_name => "Lary"))
|
277
|
-
assert_equal [
|
278
|
-
[:added, :before, "David"],
|
279
|
-
[:added, :after, "David"],
|
280
|
-
[:added, :before, "Bob"],
|
281
|
-
[:added, :after, "Bob"],
|
282
|
-
[:added, :before, "Lary"],
|
283
|
-
[:added, :after, "Lary"]
|
284
|
-
],log.last(6)
|
285
|
-
|
286
|
-
post.people_with_callbacks.build(:first_name => "Ted")
|
287
|
-
assert_equal [
|
288
|
-
[:added, :before, "Ted"],
|
289
|
-
[:added, :after, "Ted"]
|
290
|
-
], log.last(2)
|
291
|
-
|
292
|
-
post.people_with_callbacks.create(:first_name => "Sam")
|
293
|
-
assert_equal [
|
294
|
-
[:added, :before, "Sam"],
|
295
|
-
[:added, :after, "Sam"]
|
296
|
-
], log.last(2)
|
297
|
-
|
298
|
-
post.people_with_callbacks = [people(:michael),people(:david), Person.new(:first_name => "Julian"), Person.create!(:first_name => "Roger")]
|
299
|
-
assert_equal((%w(Ted Bob Sam Lary) * 2).sort, log[-12..-5].collect(&:last).sort)
|
300
|
-
assert_equal [
|
301
|
-
[:added, :before, "Julian"],
|
302
|
-
[:added, :after, "Julian"],
|
303
|
-
[:added, :before, "Roger"],
|
304
|
-
[:added, :after, "Roger"]
|
305
|
-
], log.last(4)
|
306
|
-
|
307
|
-
post.people_with_callbacks.clear
|
308
|
-
assert_equal((%w(Michael David Julian Roger) * 2).sort, log.last(8).collect(&:last).sort)
|
309
|
-
end
|
310
|
-
|
311
|
-
unless current_adapter?(:IBM_DBAdapter) #refer db2 ? SQL0214N
|
312
|
-
def test_dynamic_find_should_respect_association_include
|
313
|
-
# SQL error in sort clause if :include is not included
|
314
|
-
# due to Unknown column 'comments.id'
|
315
|
-
assert Person.find(1).posts_with_comments_sorted_by_comment_id.find_by_title('Welcome to the weblog')
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
def test_count_with_include_should_alias_join_table
|
320
|
-
assert_equal 2, people(:michael).posts.count(:include => :readers)
|
321
|
-
end
|
322
|
-
|
323
|
-
def test_inner_join_with_quoted_table_name
|
324
|
-
assert_equal 2, people(:michael).jobs.size
|
325
|
-
end
|
326
|
-
|
327
|
-
def test_get_ids_for_belongs_to_source
|
328
|
-
assert_sql(/DISTINCT/) { assert_equal [posts(:welcome).id, posts(:authorless).id].sort, people(:michael).post_ids.sort }
|
329
|
-
end
|
330
|
-
|
331
|
-
def test_get_ids_for_has_many_source
|
332
|
-
assert_equal [comments(:eager_other_comment1).id], authors(:mary).comment_ids
|
333
|
-
end
|
334
|
-
|
335
|
-
def test_get_ids_for_loaded_associations
|
336
|
-
person = people(:michael)
|
337
|
-
person.posts(true)
|
338
|
-
assert_queries(0) do
|
339
|
-
person.post_ids
|
340
|
-
person.post_ids
|
341
|
-
end
|
342
|
-
end
|
343
|
-
|
344
|
-
def test_get_ids_for_unloaded_associations_does_not_load_them
|
345
|
-
person = people(:michael)
|
346
|
-
assert !person.posts.loaded?
|
347
|
-
assert_equal [posts(:welcome).id, posts(:authorless).id].sort, person.post_ids.sort
|
348
|
-
assert !person.posts.loaded?
|
349
|
-
end
|
350
|
-
|
351
|
-
def test_association_proxy_transaction_method_starts_transaction_in_association_class
|
352
|
-
Tag.expects(:transaction)
|
353
|
-
Post.find(:first).tags.transaction do
|
354
|
-
# nothing
|
355
|
-
end
|
356
|
-
end
|
357
|
-
|
358
|
-
def test_has_many_association_through_a_belongs_to_association_where_the_association_doesnt_exist
|
359
|
-
author = authors(:mary)
|
360
|
-
post = Post.create!(:title => "TITLE", :body => "BODY")
|
361
|
-
assert_equal [], post.author_favorites
|
362
|
-
end
|
363
|
-
|
364
|
-
def test_has_many_association_through_a_belongs_to_association
|
365
|
-
author = authors(:mary)
|
366
|
-
post = Post.create!(:author => author, :title => "TITLE", :body => "BODY")
|
367
|
-
author.author_favorites.create(:favorite_author_id => 1)
|
368
|
-
author.author_favorites.create(:favorite_author_id => 2)
|
369
|
-
author.author_favorites.create(:favorite_author_id => 3)
|
370
|
-
assert_equal post.author.author_favorites, post.author_favorites
|
371
|
-
end
|
372
|
-
|
373
|
-
def test_has_many_association_through_a_has_many_association_with_nonstandard_primary_keys
|
374
|
-
assert_equal 1, owners(:blackbeard).toys.count
|
375
|
-
end
|
376
|
-
|
377
|
-
def test_find_on_has_many_association_collection_with_include_and_conditions
|
378
|
-
post_with_no_comments = people(:michael).posts_with_no_comments.first
|
379
|
-
assert_equal post_with_no_comments, posts(:authorless)
|
380
|
-
end
|
381
|
-
|
382
|
-
def test_has_many_through_has_one_reflection
|
383
|
-
assert_equal [comments(:eager_sti_on_associations_vs_comment)], authors(:david).very_special_comments
|
384
|
-
end
|
385
|
-
|
386
|
-
def test_modifying_has_many_through_has_one_reflection_should_raise
|
387
|
-
[
|
388
|
-
lambda { authors(:david).very_special_comments = [VerySpecialComment.create!(:body => "Gorp!", :post_id => 1011), VerySpecialComment.create!(:body => "Eep!", :post_id => 1012)] },
|
389
|
-
lambda { authors(:david).very_special_comments << VerySpecialComment.create!(:body => "Hoohah!", :post_id => 1013) },
|
390
|
-
lambda { authors(:david).very_special_comments.delete(authors(:david).very_special_comments.first) },
|
391
|
-
].each {|block| assert_raise(ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection, &block) }
|
392
|
-
end
|
393
|
-
|
394
|
-
def test_collection_singular_ids_getter_with_string_primary_keys
|
395
|
-
book = books(:awdr)
|
396
|
-
assert_equal 2, book.subscriber_ids.size
|
397
|
-
assert_equal [subscribers(:first).nick, subscribers(:second).nick].sort, book.subscriber_ids.sort
|
398
|
-
end
|
399
|
-
|
400
|
-
def test_collection_singular_ids_setter
|
401
|
-
company = companies(:rails_core)
|
402
|
-
dev = Developer.find(:first)
|
403
|
-
|
404
|
-
company.developer_ids = [dev.id]
|
405
|
-
assert_equal [dev], company.developers
|
406
|
-
end
|
407
|
-
|
408
|
-
def test_collection_singular_ids_setter_with_string_primary_keys
|
409
|
-
assert_nothing_raised do
|
410
|
-
book = books(:awdr)
|
411
|
-
book.subscriber_ids = [subscribers(:second).nick]
|
412
|
-
assert_equal [subscribers(:second)], book.subscribers(true)
|
413
|
-
|
414
|
-
book.subscriber_ids = []
|
415
|
-
assert_equal [], book.subscribers(true)
|
416
|
-
end
|
417
|
-
|
418
|
-
end
|
419
|
-
|
420
|
-
def test_collection_singular_ids_setter_raises_exception_when_invalid_ids_set
|
421
|
-
company = companies(:rails_core)
|
422
|
-
ids = [Developer.find(:first).id, -9999]
|
423
|
-
assert_raises(ActiveRecord::RecordNotFound) {company.developer_ids= ids}
|
424
|
-
end
|
425
|
-
|
426
|
-
def test_build_a_model_from_hm_through_association_with_where_clause
|
427
|
-
assert_nothing_raised { books(:awdr).subscribers.where(:nick => "marklazz").build }
|
428
|
-
end
|
429
|
-
|
430
|
-
def test_attributes_are_being_set_when_initialized_from_hm_through_association_with_where_clause
|
431
|
-
new_subscriber = books(:awdr).subscribers.where(:nick => "marklazz").build
|
432
|
-
assert_equal new_subscriber.nick, "marklazz"
|
433
|
-
end
|
434
|
-
|
435
|
-
def test_attributes_are_being_set_when_initialized_from_hm_through_association_with_multiple_where_clauses
|
436
|
-
new_subscriber = books(:awdr).subscribers.where(:nick => "marklazz").where(:name => 'Marcelo Giorgi').build
|
437
|
-
assert_equal new_subscriber.nick, "marklazz"
|
438
|
-
assert_equal new_subscriber.name, "Marcelo Giorgi"
|
439
|
-
end
|
440
|
-
|
441
|
-
def test_include_method_in_association_through_should_return_true_for_instance_added_with_build
|
442
|
-
person = Person.new
|
443
|
-
reference = person.references.build
|
444
|
-
job = reference.build_job
|
445
|
-
assert person.jobs.include?(job)
|
446
|
-
end
|
447
|
-
|
448
|
-
def test_include_method_in_association_through_should_return_true_for_instance_added_with_nested_builds
|
449
|
-
author = Author.new
|
450
|
-
post = author.posts.build
|
451
|
-
comment = post.comments.build
|
452
|
-
assert author.comments.include?(comment)
|
453
|
-
end
|
454
|
-
|
455
|
-
def test_size_of_through_association_should_increase_correctly_when_has_many_association_is_added
|
456
|
-
post = posts(:thinking)
|
457
|
-
readers = post.readers.size
|
458
|
-
post.people << people(:michael)
|
459
|
-
assert_equal readers + 1, post.readers.size
|
460
|
-
end
|
461
|
-
end
|