composite_primary_keys 7.0.15 → 7.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +4 -0
- data/lib/composite_primary_keys.rb +5 -0
- data/lib/composite_primary_keys/arel/visitors/to_sql.rb +20 -0
- data/lib/composite_primary_keys/associations/join_dependency/join_association.rb +22 -22
- data/lib/composite_primary_keys/associations/preloader/belongs_to.rb +19 -19
- data/lib/composite_primary_keys/composite_predicates.rb +50 -50
- data/lib/composite_primary_keys/composite_relation.rb +48 -48
- data/lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb +60 -46
- data/lib/composite_primary_keys/fixtures.rb +22 -22
- data/lib/composite_primary_keys/locking/optimistic.rb +55 -55
- data/lib/composite_primary_keys/relation/query_methods.rb +40 -40
- data/lib/composite_primary_keys/version.rb +1 -1
- data/tasks/databases/oracle.rake +25 -25
- data/test/connections/databases.ci.yml +15 -15
- data/test/connections/native_oracle/connection.rb +11 -11
- data/test/connections/native_oracle_enhanced/connection.rb +16 -16
- data/test/fixtures/comment.rb +7 -7
- data/test/fixtures/db_definitions/db2-create-tables.sql +126 -126
- data/test/fixtures/db_definitions/db2-drop-tables.sql +18 -18
- data/test/fixtures/db_definitions/oracle.drop.sql +45 -45
- data/test/fixtures/db_definitions/oracle.sql +223 -223
- data/test/fixtures/dorm.rb +2 -2
- data/test/fixtures/membership.rb +6 -6
- data/test/fixtures/membership_statuses.yml +16 -16
- data/test/fixtures/memberships.yml +10 -10
- data/test/fixtures/product_tariffs.yml +14 -14
- data/test/fixtures/reference_code.rb +7 -7
- data/test/fixtures/restaurants_suburb.rb +2 -2
- data/test/fixtures/suburb.rb +5 -5
- data/test/fixtures/topic.rb +5 -5
- data/test/fixtures/topic_source.rb +6 -6
- data/test/fixtures/topic_sources.yml +3 -3
- data/test/fixtures/topics.yml +8 -8
- data/test/fixtures/users.yml +10 -10
- data/test/test_attribute_methods.rb +63 -63
- data/test/test_calculations.rb +42 -42
- data/test/test_callbacks.rb +99 -99
- data/test/test_delete_all.rb +5 -0
- data/test/test_dumpable.rb +15 -15
- data/test/test_nested_attributes.rb +124 -124
- data/test/test_optimistic.rb +18 -18
- data/test/test_predicates.rb +40 -40
- data/test/test_santiago.rb +23 -23
- data/test/test_suite.rb +34 -34
- data/test/test_touch.rb +23 -23
- data/test/test_update.rb +71 -71
- metadata +4 -3
data/test/test_delete_all.rb
CHANGED
@@ -18,4 +18,9 @@ class TestValidations < ActiveSupport::TestCase
|
|
18
18
|
}
|
19
19
|
assert(EmployeesGroup.all.size == 3)
|
20
20
|
end
|
21
|
+
|
22
|
+
# This test fails, requires fixin arel
|
23
|
+
def test_delete_all_with_joins
|
24
|
+
ReferenceCode.joins(:reference_type).where(:reference_type_id => 1).delete_all
|
25
|
+
end
|
21
26
|
end
|
data/test/test_dumpable.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
-
|
3
|
-
class TestDumpable < ActiveSupport::TestCase
|
4
|
-
fixtures :articles, :readings, :users
|
5
|
-
|
6
|
-
def test_marshal_with_simple_preload
|
7
|
-
articles = Article.preload(:readings).where(id: 1).to_a
|
8
|
-
assert_equal(Marshal.load(Marshal.dump(articles)), articles)
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_marshal_with_comples_preload
|
12
|
-
articles = Article.preload({ readings: :user }).where(id: 1).to_a
|
13
|
-
assert_equal(Marshal.load(Marshal.dump(articles)), articles)
|
14
|
-
end
|
15
|
-
end
|
1
|
+
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
+
|
3
|
+
class TestDumpable < ActiveSupport::TestCase
|
4
|
+
fixtures :articles, :readings, :users
|
5
|
+
|
6
|
+
def test_marshal_with_simple_preload
|
7
|
+
articles = Article.preload(:readings).where(id: 1).to_a
|
8
|
+
assert_equal(Marshal.load(Marshal.dump(articles)), articles)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_marshal_with_comples_preload
|
12
|
+
articles = Article.preload({ readings: :user }).where(id: 1).to_a
|
13
|
+
assert_equal(Marshal.load(Marshal.dump(articles)), articles)
|
14
|
+
end
|
15
|
+
end
|
@@ -1,124 +1,124 @@
|
|
1
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
-
|
3
|
-
# Testing the find action on composite ActiveRecords with two primary keys
|
4
|
-
class TestNestedAttributes < ActiveSupport::TestCase
|
5
|
-
fixtures :reference_types, :reference_codes
|
6
|
-
|
7
|
-
def test_nested_atttribute_create
|
8
|
-
code_id = 1001
|
9
|
-
|
10
|
-
reference_type = reference_types(:name_prefix)
|
11
|
-
reference_type.update_attribute :reference_codes_attributes, [{
|
12
|
-
:reference_code => code_id,
|
13
|
-
:code_label => 'XX',
|
14
|
-
:abbreviation => 'Xx'
|
15
|
-
}]
|
16
|
-
assert_not_nil ReferenceCode.find_by_reference_code(code_id)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_nested_atttribute_update
|
20
|
-
code_id = 1002
|
21
|
-
|
22
|
-
reference_type = reference_types(:name_prefix)
|
23
|
-
reference_type.update_attribute :reference_codes_attributes, [{
|
24
|
-
:reference_code => code_id,
|
25
|
-
:code_label => 'XX',
|
26
|
-
:abbreviation => 'Xx'
|
27
|
-
}]
|
28
|
-
|
29
|
-
reference_code = ReferenceCode.find_by_reference_code(code_id)
|
30
|
-
cpk = CompositePrimaryKeys::CompositeKeys[reference_type.reference_type_id, code_id]
|
31
|
-
reference_type.update_attribute :reference_codes_attributes, [{
|
32
|
-
:id => cpk,
|
33
|
-
:code_label => 'AAA',
|
34
|
-
:abbreviation => 'Aaa'
|
35
|
-
}]
|
36
|
-
|
37
|
-
reference_code = ReferenceCode.find_by_reference_code(code_id)
|
38
|
-
assert_kind_of(ReferenceCode, reference_code)
|
39
|
-
assert_equal(reference_code.code_label, 'AAA')
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_nested_atttribute_update_2
|
43
|
-
reference_type = reference_types(:gender)
|
44
|
-
reference_code = reference_codes(:gender_male)
|
45
|
-
|
46
|
-
reference_type.update_attributes(:reference_codes_attributes => [{:id => reference_code.id,
|
47
|
-
:code_label => 'XX',
|
48
|
-
:abbreviation => 'Xx'}])
|
49
|
-
|
50
|
-
reference_code.reload
|
51
|
-
assert_equal(reference_code.code_label, 'XX')
|
52
|
-
assert_equal(reference_code.abbreviation, 'Xx')
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_nested_atttribute_update_3
|
56
|
-
reference_type = reference_types(:gender)
|
57
|
-
reference_code = reference_codes(:gender_male)
|
58
|
-
|
59
|
-
reference_type.update_attributes(:reference_codes_attributes => [{:id => reference_code.id.to_s,
|
60
|
-
:code_label => 'XX',
|
61
|
-
:abbreviation => 'Xx'}])
|
62
|
-
|
63
|
-
reference_code.reload
|
64
|
-
assert_equal(reference_code.code_label, 'XX')
|
65
|
-
assert_equal(reference_code.abbreviation, 'Xx')
|
66
|
-
end
|
67
|
-
|
68
|
-
fixtures :topics, :topic_sources
|
69
|
-
|
70
|
-
def test_nested_attributes_create_with_string_in_primary_key
|
71
|
-
platform = 'instagram'
|
72
|
-
|
73
|
-
topic = topics(:music)
|
74
|
-
topic.update_attribute :topic_sources_attributes, [{
|
75
|
-
:platform => platform,
|
76
|
-
:keywords => 'funk'
|
77
|
-
}]
|
78
|
-
assert_not_nil TopicSource.find_by_platform(platform)
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_nested_attributes_update_with_string_in_primary_key
|
82
|
-
platform = 'instagram'
|
83
|
-
|
84
|
-
topic = topics(:music)
|
85
|
-
topic.update_attribute :topic_sources_attributes, [{
|
86
|
-
:platform => platform,
|
87
|
-
:keywords => 'funk'
|
88
|
-
}]
|
89
|
-
assert_not_nil TopicSource.find_by_platform(platform)
|
90
|
-
|
91
|
-
topic_source = TopicSource.find_by_platform(platform)
|
92
|
-
cpk = CompositePrimaryKeys::CompositeKeys[topic.id, platform]
|
93
|
-
topic.update_attribute :topic_sources_attributes, [{
|
94
|
-
:id => cpk,
|
95
|
-
:keywords => 'jazz'
|
96
|
-
}]
|
97
|
-
|
98
|
-
topic_source = TopicSource.find_by_platform(platform)
|
99
|
-
assert_kind_of(TopicSource, topic_source)
|
100
|
-
assert_equal(topic_source.keywords, 'jazz')
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_nested_attributes_update_with_string_in_primary_key_2
|
104
|
-
topic = topics(:music)
|
105
|
-
topic_source = topic_sources(:music_source)
|
106
|
-
|
107
|
-
topic.update_attributes(:topic_sources_attributes => [{:id => topic_source.id,
|
108
|
-
:keywords => 'classical, jazz'}])
|
109
|
-
|
110
|
-
topic_source.reload
|
111
|
-
assert_equal(topic_source.keywords, 'classical, jazz')
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_nested_attributes_update_with_string_in_primary_key_3
|
115
|
-
topic = topics(:music)
|
116
|
-
topic_source = topic_sources(:music_source)
|
117
|
-
|
118
|
-
topic.update_attributes(:topic_sources_attributes => [{:id => topic_source.id.to_s,
|
119
|
-
:keywords => 'classical, jazz'}])
|
120
|
-
|
121
|
-
topic_source.reload
|
122
|
-
assert_equal(topic_source.keywords, 'classical, jazz')
|
123
|
-
end
|
124
|
-
end
|
1
|
+
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
+
|
3
|
+
# Testing the find action on composite ActiveRecords with two primary keys
|
4
|
+
class TestNestedAttributes < ActiveSupport::TestCase
|
5
|
+
fixtures :reference_types, :reference_codes
|
6
|
+
|
7
|
+
def test_nested_atttribute_create
|
8
|
+
code_id = 1001
|
9
|
+
|
10
|
+
reference_type = reference_types(:name_prefix)
|
11
|
+
reference_type.update_attribute :reference_codes_attributes, [{
|
12
|
+
:reference_code => code_id,
|
13
|
+
:code_label => 'XX',
|
14
|
+
:abbreviation => 'Xx'
|
15
|
+
}]
|
16
|
+
assert_not_nil ReferenceCode.find_by_reference_code(code_id)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_nested_atttribute_update
|
20
|
+
code_id = 1002
|
21
|
+
|
22
|
+
reference_type = reference_types(:name_prefix)
|
23
|
+
reference_type.update_attribute :reference_codes_attributes, [{
|
24
|
+
:reference_code => code_id,
|
25
|
+
:code_label => 'XX',
|
26
|
+
:abbreviation => 'Xx'
|
27
|
+
}]
|
28
|
+
|
29
|
+
reference_code = ReferenceCode.find_by_reference_code(code_id)
|
30
|
+
cpk = CompositePrimaryKeys::CompositeKeys[reference_type.reference_type_id, code_id]
|
31
|
+
reference_type.update_attribute :reference_codes_attributes, [{
|
32
|
+
:id => cpk,
|
33
|
+
:code_label => 'AAA',
|
34
|
+
:abbreviation => 'Aaa'
|
35
|
+
}]
|
36
|
+
|
37
|
+
reference_code = ReferenceCode.find_by_reference_code(code_id)
|
38
|
+
assert_kind_of(ReferenceCode, reference_code)
|
39
|
+
assert_equal(reference_code.code_label, 'AAA')
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_nested_atttribute_update_2
|
43
|
+
reference_type = reference_types(:gender)
|
44
|
+
reference_code = reference_codes(:gender_male)
|
45
|
+
|
46
|
+
reference_type.update_attributes(:reference_codes_attributes => [{:id => reference_code.id,
|
47
|
+
:code_label => 'XX',
|
48
|
+
:abbreviation => 'Xx'}])
|
49
|
+
|
50
|
+
reference_code.reload
|
51
|
+
assert_equal(reference_code.code_label, 'XX')
|
52
|
+
assert_equal(reference_code.abbreviation, 'Xx')
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_nested_atttribute_update_3
|
56
|
+
reference_type = reference_types(:gender)
|
57
|
+
reference_code = reference_codes(:gender_male)
|
58
|
+
|
59
|
+
reference_type.update_attributes(:reference_codes_attributes => [{:id => reference_code.id.to_s,
|
60
|
+
:code_label => 'XX',
|
61
|
+
:abbreviation => 'Xx'}])
|
62
|
+
|
63
|
+
reference_code.reload
|
64
|
+
assert_equal(reference_code.code_label, 'XX')
|
65
|
+
assert_equal(reference_code.abbreviation, 'Xx')
|
66
|
+
end
|
67
|
+
|
68
|
+
fixtures :topics, :topic_sources
|
69
|
+
|
70
|
+
def test_nested_attributes_create_with_string_in_primary_key
|
71
|
+
platform = 'instagram'
|
72
|
+
|
73
|
+
topic = topics(:music)
|
74
|
+
topic.update_attribute :topic_sources_attributes, [{
|
75
|
+
:platform => platform,
|
76
|
+
:keywords => 'funk'
|
77
|
+
}]
|
78
|
+
assert_not_nil TopicSource.find_by_platform(platform)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_nested_attributes_update_with_string_in_primary_key
|
82
|
+
platform = 'instagram'
|
83
|
+
|
84
|
+
topic = topics(:music)
|
85
|
+
topic.update_attribute :topic_sources_attributes, [{
|
86
|
+
:platform => platform,
|
87
|
+
:keywords => 'funk'
|
88
|
+
}]
|
89
|
+
assert_not_nil TopicSource.find_by_platform(platform)
|
90
|
+
|
91
|
+
topic_source = TopicSource.find_by_platform(platform)
|
92
|
+
cpk = CompositePrimaryKeys::CompositeKeys[topic.id, platform]
|
93
|
+
topic.update_attribute :topic_sources_attributes, [{
|
94
|
+
:id => cpk,
|
95
|
+
:keywords => 'jazz'
|
96
|
+
}]
|
97
|
+
|
98
|
+
topic_source = TopicSource.find_by_platform(platform)
|
99
|
+
assert_kind_of(TopicSource, topic_source)
|
100
|
+
assert_equal(topic_source.keywords, 'jazz')
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_nested_attributes_update_with_string_in_primary_key_2
|
104
|
+
topic = topics(:music)
|
105
|
+
topic_source = topic_sources(:music_source)
|
106
|
+
|
107
|
+
topic.update_attributes(:topic_sources_attributes => [{:id => topic_source.id,
|
108
|
+
:keywords => 'classical, jazz'}])
|
109
|
+
|
110
|
+
topic_source.reload
|
111
|
+
assert_equal(topic_source.keywords, 'classical, jazz')
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_nested_attributes_update_with_string_in_primary_key_3
|
115
|
+
topic = topics(:music)
|
116
|
+
topic_source = topic_sources(:music_source)
|
117
|
+
|
118
|
+
topic.update_attributes(:topic_sources_attributes => [{:id => topic_source.id.to_s,
|
119
|
+
:keywords => 'classical, jazz'}])
|
120
|
+
|
121
|
+
topic_source.reload
|
122
|
+
assert_equal(topic_source.keywords, 'classical, jazz')
|
123
|
+
end
|
124
|
+
end
|
data/test/test_optimistic.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
-
|
3
|
-
class TestOptimisitic < ActiveSupport::TestCase
|
4
|
-
fixtures :restaurants
|
5
|
-
|
6
|
-
def test_update_with_stale_error
|
7
|
-
restaurant_1 = Restaurant.find([1, 1])
|
8
|
-
restaurant_1['name'] = "McDonalds renamed"
|
9
|
-
|
10
|
-
restaurant_2 = Restaurant.find([1, 1])
|
11
|
-
restaurant_2['name'] = "McDonalds renamed 2"
|
12
|
-
|
13
|
-
assert(restaurant_1.save)
|
14
|
-
assert_raise ActiveRecord::StaleObjectError do
|
15
|
-
restaurant_2.save
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
1
|
+
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
+
|
3
|
+
class TestOptimisitic < ActiveSupport::TestCase
|
4
|
+
fixtures :restaurants
|
5
|
+
|
6
|
+
def test_update_with_stale_error
|
7
|
+
restaurant_1 = Restaurant.find([1, 1])
|
8
|
+
restaurant_1['name'] = "McDonalds renamed"
|
9
|
+
|
10
|
+
restaurant_2 = Restaurant.find([1, 1])
|
11
|
+
restaurant_2['name'] = "McDonalds renamed 2"
|
12
|
+
|
13
|
+
assert(restaurant_1.save)
|
14
|
+
assert_raise ActiveRecord::StaleObjectError do
|
15
|
+
restaurant_2.save
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/test/test_predicates.rb
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
-
|
3
|
-
class TestEqual < ActiveSupport::TestCase
|
4
|
-
fixtures :departments
|
5
|
-
|
6
|
-
include CompositePrimaryKeys::Predicates
|
7
|
-
|
8
|
-
def test_or
|
9
|
-
dep = Arel::Table.new(:departments)
|
10
|
-
|
11
|
-
predicates = Array.new
|
12
|
-
|
13
|
-
3.times do |i|
|
14
|
-
predicates << dep[:id].eq(i)
|
15
|
-
end
|
16
|
-
|
17
|
-
connection = ActiveRecord::Base.connection
|
18
|
-
quoted = "#{connection.quote_table_name('departments')}.#{connection.quote_column_name('id')}"
|
19
|
-
expected = "((#{quoted} = 0) OR (#{quoted} = 1) OR (#{quoted} = 2))"
|
20
|
-
|
21
|
-
pred = cpk_or_predicate(predicates)
|
22
|
-
assert_equal(with_quoted_identifiers(expected), pred.to_sql)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_and
|
26
|
-
dep = Arel::Table.new(:departments)
|
27
|
-
|
28
|
-
predicates = Array.new
|
29
|
-
|
30
|
-
3.times do |i|
|
31
|
-
predicates << dep[:id].eq(i)
|
32
|
-
end
|
33
|
-
|
34
|
-
connection = ActiveRecord::Base.connection
|
35
|
-
quoted = "#{connection.quote_table_name('departments')}.#{connection.quote_column_name('id')}"
|
36
|
-
expected = "#{quoted} = 0 AND #{quoted} = 1 AND #{quoted} = 2"
|
37
|
-
|
38
|
-
pred = cpk_and_predicate(predicates)
|
39
|
-
assert_equal(with_quoted_identifiers(expected), pred.to_sql)
|
40
|
-
end
|
1
|
+
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
+
|
3
|
+
class TestEqual < ActiveSupport::TestCase
|
4
|
+
fixtures :departments
|
5
|
+
|
6
|
+
include CompositePrimaryKeys::Predicates
|
7
|
+
|
8
|
+
def test_or
|
9
|
+
dep = Arel::Table.new(:departments)
|
10
|
+
|
11
|
+
predicates = Array.new
|
12
|
+
|
13
|
+
3.times do |i|
|
14
|
+
predicates << dep[:id].eq(i)
|
15
|
+
end
|
16
|
+
|
17
|
+
connection = ActiveRecord::Base.connection
|
18
|
+
quoted = "#{connection.quote_table_name('departments')}.#{connection.quote_column_name('id')}"
|
19
|
+
expected = "((#{quoted} = 0) OR (#{quoted} = 1) OR (#{quoted} = 2))"
|
20
|
+
|
21
|
+
pred = cpk_or_predicate(predicates)
|
22
|
+
assert_equal(with_quoted_identifiers(expected), pred.to_sql)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_and
|
26
|
+
dep = Arel::Table.new(:departments)
|
27
|
+
|
28
|
+
predicates = Array.new
|
29
|
+
|
30
|
+
3.times do |i|
|
31
|
+
predicates << dep[:id].eq(i)
|
32
|
+
end
|
33
|
+
|
34
|
+
connection = ActiveRecord::Base.connection
|
35
|
+
quoted = "#{connection.quote_table_name('departments')}.#{connection.quote_column_name('id')}"
|
36
|
+
expected = "#{quoted} = 0 AND #{quoted} = 1 AND #{quoted} = 2"
|
37
|
+
|
38
|
+
pred = cpk_and_predicate(predicates)
|
39
|
+
assert_equal(with_quoted_identifiers(expected), pred.to_sql)
|
40
|
+
end
|
41
41
|
end
|
data/test/test_santiago.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
# Test cases devised by Santiago that broke the Composite Primary Keys
|
2
|
-
# code at one point in time. But no more!!!
|
3
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
4
|
-
|
5
|
-
class TestSantiago < ActiveSupport::TestCase
|
6
|
-
fixtures :suburbs, :streets, :users, :articles, :readings
|
7
|
-
|
8
|
-
def test_normal_and_composite_associations
|
9
|
-
assert_not_nil @suburb = Suburb.find([1, 1])
|
10
|
-
assert_equal 1, @suburb.streets.length
|
11
|
-
|
12
|
-
assert_not_nil @street = Street.find(1)
|
13
|
-
assert_not_nil @street.suburb
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_single_keys
|
17
|
-
@santiago = User.find(1)
|
18
|
-
assert_not_nil @santiago.articles
|
19
|
-
assert_equal 2, @santiago.articles.length
|
20
|
-
assert_not_nil @santiago.readings
|
21
|
-
assert_equal 2, @santiago.readings.length
|
22
|
-
end
|
23
|
-
end
|
1
|
+
# Test cases devised by Santiago that broke the Composite Primary Keys
|
2
|
+
# code at one point in time. But no more!!!
|
3
|
+
require File.expand_path('../abstract_unit', __FILE__)
|
4
|
+
|
5
|
+
class TestSantiago < ActiveSupport::TestCase
|
6
|
+
fixtures :suburbs, :streets, :users, :articles, :readings
|
7
|
+
|
8
|
+
def test_normal_and_composite_associations
|
9
|
+
assert_not_nil @suburb = Suburb.find([1, 1])
|
10
|
+
assert_equal 1, @suburb.streets.length
|
11
|
+
|
12
|
+
assert_not_nil @street = Street.find(1)
|
13
|
+
assert_not_nil @street.suburb
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_single_keys
|
17
|
+
@santiago = User.find(1)
|
18
|
+
assert_not_nil @santiago.articles
|
19
|
+
assert_equal 2, @santiago.articles.length
|
20
|
+
assert_not_nil @santiago.readings
|
21
|
+
assert_equal 2, @santiago.readings.length
|
22
|
+
end
|
23
|
+
end
|