composite_primary_keys 12.0.2 → 12.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +880 -841
- data/README.rdoc +180 -179
- data/lib/composite_primary_keys/active_model/attribute_assignment.rb +19 -0
- data/lib/composite_primary_keys/arel/sqlserver.rb +1 -3
- data/lib/composite_primary_keys/associations/association_scope.rb +68 -68
- data/lib/composite_primary_keys/associations/join_dependency.rb +103 -103
- data/lib/composite_primary_keys/associations/through_association.rb +2 -1
- data/lib/composite_primary_keys/attribute_methods/primary_key.rb +13 -0
- data/lib/composite_primary_keys/attribute_methods/read.rb +30 -30
- data/lib/composite_primary_keys/attribute_methods/write.rb +35 -35
- data/lib/composite_primary_keys/attribute_methods.rb +9 -9
- data/lib/composite_primary_keys/base.rb +141 -130
- data/lib/composite_primary_keys/composite_arrays.rb +0 -8
- data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +37 -17
- data/lib/composite_primary_keys/connection_adapters/sqlserver/database_statements.rb +44 -23
- data/lib/composite_primary_keys/core.rb +48 -48
- data/lib/composite_primary_keys/persistence.rb +82 -81
- data/lib/composite_primary_keys/reflection.rb +29 -29
- data/lib/composite_primary_keys/relation/batches.rb +1 -1
- data/lib/composite_primary_keys/relation/calculations.rb +81 -81
- data/lib/composite_primary_keys/relation/finder_methods.rb +235 -235
- data/lib/composite_primary_keys/relation/predicate_builder/association_query_value.rb +20 -20
- data/lib/composite_primary_keys/relation/query_methods.rb +42 -42
- data/lib/composite_primary_keys/relation/where_clause.rb +23 -23
- data/lib/composite_primary_keys/relation.rb +193 -118
- data/lib/composite_primary_keys/version.rb +8 -8
- data/lib/composite_primary_keys.rb +117 -118
- data/test/abstract_unit.rb +114 -113
- data/test/connections/databases.ci.yml +22 -19
- data/test/fixtures/article.rb +4 -0
- data/test/fixtures/articles.yml +4 -3
- data/test/fixtures/comment.rb +1 -3
- data/test/fixtures/comments.yml +10 -9
- data/test/fixtures/db_definitions/db2-create-tables.sql +112 -126
- data/test/fixtures/db_definitions/db2-drop-tables.sql +17 -19
- data/test/fixtures/db_definitions/mysql.sql +180 -217
- data/test/fixtures/db_definitions/oracle.drop.sql +42 -48
- data/test/fixtures/db_definitions/oracle.sql +200 -236
- data/test/fixtures/db_definitions/postgresql.sql +183 -220
- data/test/fixtures/db_definitions/sqlite.sql +170 -206
- data/test/fixtures/db_definitions/sqlserver.sql +176 -212
- data/test/fixtures/department.rb +16 -11
- data/test/fixtures/departments.yml +15 -15
- data/test/fixtures/employees.yml +27 -27
- data/test/fixtures/readings.yml +2 -2
- data/test/fixtures/restaurants_suburbs.yml +11 -11
- data/test/fixtures/streets.yml +16 -16
- data/test/fixtures/suburbs.yml +14 -14
- data/test/fixtures/user.rb +11 -10
- data/test/test_associations.rb +358 -351
- data/test/test_attributes.rb +60 -60
- data/test/test_calculations.rb +42 -42
- data/test/test_create.rb +218 -183
- data/test/test_delete.rb +182 -179
- data/test/test_exists.rb +39 -39
- data/test/test_find.rb +164 -145
- data/test/test_habtm.rb +2 -2
- data/test/test_ids.rb +112 -116
- data/test/test_nested_attributes.rb +67 -124
- data/test/test_polymorphic.rb +29 -13
- data/test/test_preload.rb +4 -3
- data/test/test_serialize.rb +2 -2
- data/test/test_update.rb +96 -78
- metadata +4 -19
- data/test/fixtures/hack.rb +0 -5
- data/test/fixtures/hacks.yml +0 -3
- data/test/fixtures/pk_called_id.rb +0 -5
- data/test/fixtures/pk_called_ids.yml +0 -11
- data/test/fixtures/reference_code_using_composite_key_alias.rb +0 -8
- data/test/fixtures/reference_code_using_simple_key_alias.rb +0 -8
- data/test/fixtures/seat.rb +0 -5
- data/test/fixtures/seats.yml +0 -9
- data/test/fixtures/topic.rb +0 -6
- data/test/fixtures/topic_source.rb +0 -7
- data/test/test_aliases.rb +0 -18
- data/test/test_enum.rb +0 -21
- data/test/test_suite.rb +0 -35
@@ -1,124 +1,67 @@
|
|
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 :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 :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 :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(: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(: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 :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 :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 :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(: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(: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 :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 :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 :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(: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(: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
|
+
end
|
data/test/test_polymorphic.rb
CHANGED
@@ -1,27 +1,43 @@
|
|
1
1
|
require File.expand_path('../abstract_unit', __FILE__)
|
2
2
|
|
3
3
|
class TestPolymorphic < ActiveSupport::TestCase
|
4
|
-
fixtures :
|
4
|
+
fixtures :articles, :departments, :employees, :users, :comments
|
5
5
|
|
6
|
-
def
|
7
|
-
|
8
|
-
|
6
|
+
def test_has_many
|
7
|
+
user = users(:santiago)
|
8
|
+
comments = user.comments
|
9
|
+
assert_equal(user.id, comments[0].person_id)
|
9
10
|
end
|
10
11
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
12
|
+
def test_has_one
|
13
|
+
user = users(:santiago)
|
14
|
+
first_comment = user.first_comment
|
15
|
+
assert_equal(user.id, first_comment.person_id)
|
14
16
|
end
|
15
17
|
|
16
18
|
def test_has_many_through
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
assert_equal
|
19
|
+
department = departments(:accounting)
|
20
|
+
comment = comments(:employee_comment)
|
21
|
+
|
22
|
+
assert_equal(1, department.comments.size)
|
23
|
+
assert_equal(comment, department.comments[0])
|
21
24
|
end
|
22
25
|
|
23
|
-
def
|
26
|
+
def test_has_many_through_2
|
27
|
+
article = articles(:second)
|
28
|
+
|
24
29
|
user = users(:santiago)
|
25
|
-
assert_equal(
|
30
|
+
assert_equal(user, article.user_commentators[0])
|
31
|
+
|
32
|
+
user = users(:drnic)
|
33
|
+
assert_equal(user, article.user_commentators[1])
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_clear_has_many_through
|
37
|
+
article = articles(:second)
|
38
|
+
|
39
|
+
assert_equal(2, article.comments.size)
|
40
|
+
article.user_commentators = []
|
41
|
+
assert_equal(0, article.comments.size)
|
26
42
|
end
|
27
43
|
end
|
data/test/test_preload.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path('../abstract_unit', __FILE__)
|
2
2
|
|
3
3
|
class TestPreload < ActiveSupport::TestCase
|
4
|
-
fixtures :comments, :users, :employees, :groups, :
|
4
|
+
fixtures :articles, :comments, :users, :employees, :groups, :readings
|
5
5
|
|
6
6
|
class UserForPreload < User
|
7
7
|
has_many :comments_with_include_condition, -> { where('person_type = ?', 'User')},
|
@@ -31,10 +31,11 @@ class TestPreload < ActiveSupport::TestCase
|
|
31
31
|
|
32
32
|
def test_preload_for_conditioned_has_many_association
|
33
33
|
# has one comment
|
34
|
+
article = articles(:first)
|
34
35
|
user1 = users(:santiago)
|
35
36
|
user2 = UserForPreload.create(name: 'TestPreload')
|
36
|
-
Comment.create(person: user2, person_type: 'User')
|
37
|
-
Comment.create(person: user2, person_type: 'User')
|
37
|
+
Comment.create(article: article, person: user2, person_type: 'User')
|
38
|
+
Comment.create(article: article, person: user2, person_type: 'User')
|
38
39
|
|
39
40
|
users = UserForPreload.where(id: [user1.id, user2.id]).all
|
40
41
|
assert_equal(1, users.first.comments_with_include_condition.size)
|
data/test/test_serialize.rb
CHANGED
@@ -5,11 +5,11 @@ class TestSerialization < ActiveSupport::TestCase
|
|
5
5
|
|
6
6
|
def test_json
|
7
7
|
department = Department.first
|
8
|
-
assert_equal('{"
|
8
|
+
assert_equal('{"id":1,"location_id":1}', department.to_json)
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_serializable_hash
|
12
12
|
department = Department.first
|
13
|
-
assert_equal({"
|
13
|
+
assert_equal({"id" => 1,"location_id" => 1}, department.serializable_hash)
|
14
14
|
end
|
15
15
|
end
|
data/test/test_update.rb
CHANGED
@@ -1,79 +1,97 @@
|
|
1
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
-
|
3
|
-
class TestUpdate < ActiveSupport::TestCase
|
4
|
-
fixtures :reference_types, :reference_codes
|
5
|
-
|
6
|
-
CLASSES = {
|
7
|
-
:single => {
|
8
|
-
:class => ReferenceType,
|
9
|
-
:primary_keys => :reference_type_id,
|
10
|
-
:update => { :description => 'RT Desc' },
|
11
|
-
},
|
12
|
-
:dual => {
|
13
|
-
:class => ReferenceCode,
|
14
|
-
:primary_keys => [:reference_type_id, :reference_code],
|
15
|
-
:update => { :description => 'RT Desc' },
|
16
|
-
},
|
17
|
-
}
|
18
|
-
|
19
|
-
def setup
|
20
|
-
self.class.classes = CLASSES
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_setup
|
24
|
-
testing_with do
|
25
|
-
assert_not_nil @klass_info[:update]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_update_attributes
|
30
|
-
testing_with do
|
31
|
-
assert(@first.update(@klass_info[:update]))
|
32
|
-
assert(@first.reload)
|
33
|
-
@klass_info[:update].each_pair do |attr_name, new_value|
|
34
|
-
assert_equal(new_value, @first[attr_name])
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
assert_equal(
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
obj
|
54
|
-
obj
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
1
|
+
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
+
|
3
|
+
class TestUpdate < ActiveSupport::TestCase
|
4
|
+
fixtures :departments, :reference_types, :reference_codes, :rooms, :room_assignments
|
5
|
+
|
6
|
+
CLASSES = {
|
7
|
+
:single => {
|
8
|
+
:class => ReferenceType,
|
9
|
+
:primary_keys => :reference_type_id,
|
10
|
+
:update => { :description => 'RT Desc' },
|
11
|
+
},
|
12
|
+
:dual => {
|
13
|
+
:class => ReferenceCode,
|
14
|
+
:primary_keys => [:reference_type_id, :reference_code],
|
15
|
+
:update => { :description => 'RT Desc' },
|
16
|
+
},
|
17
|
+
}
|
18
|
+
|
19
|
+
def setup
|
20
|
+
self.class.classes = CLASSES
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_setup
|
24
|
+
testing_with do
|
25
|
+
assert_not_nil @klass_info[:update]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_update_attributes
|
30
|
+
testing_with do
|
31
|
+
assert(@first.update(@klass_info[:update]))
|
32
|
+
assert(@first.reload)
|
33
|
+
@klass_info[:update].each_pair do |attr_name, new_value|
|
34
|
+
assert_equal(new_value, @first[attr_name])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_update_attributes_with_id_field
|
40
|
+
department = departments(:accounting)
|
41
|
+
department.update_attribute(:location_id, 3)
|
42
|
+
department.reload
|
43
|
+
assert_equal(3, department.location_id)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_update_primary_key
|
47
|
+
obj = ReferenceCode.find([1,1])
|
48
|
+
obj.reference_type_id = 2
|
49
|
+
obj.reference_code = 3
|
50
|
+
assert_equal({"reference_type_id" => 2, "reference_code" => 3}, obj.ids_hash)
|
51
|
+
assert(obj.save)
|
52
|
+
assert(obj.reload)
|
53
|
+
assert_equal(2, obj.reference_type_id)
|
54
|
+
assert_equal(3, obj.reference_code)
|
55
|
+
assert_equal({"reference_type_id" => 2, "reference_code" => 3}, obj.ids_hash)
|
56
|
+
assert_equal([2, 3], obj.id)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_update_attribute
|
60
|
+
obj = ReferenceType.find(1)
|
61
|
+
obj[:abbreviation] = 'a'
|
62
|
+
obj['abbreviation'] = 'b'
|
63
|
+
assert(obj.save)
|
64
|
+
assert(obj.reload)
|
65
|
+
assert_equal('b', obj.abbreviation)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_update_all
|
69
|
+
ReferenceCode.update_all(description: 'random value')
|
70
|
+
|
71
|
+
ReferenceCode.all.each do |reference_code|
|
72
|
+
assert_equal('random value', reference_code.description)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_update_all_join
|
77
|
+
ReferenceCode.joins(:reference_type).
|
78
|
+
where('reference_types.reference_type_id = ?', 2).
|
79
|
+
update_all(:description => 'random value')
|
80
|
+
|
81
|
+
query = ReferenceCode.where('reference_type_id = ?', 2).
|
82
|
+
where(:description => 'random value')
|
83
|
+
|
84
|
+
assert_equal(2, query.count)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_update_with_uniqueness
|
88
|
+
assignment = room_assignments(:jacksons_room)
|
89
|
+
room_1 = rooms(:branner_room_1)
|
90
|
+
room_2 = rooms(:branner_room_3)
|
91
|
+
|
92
|
+
assert_equal(room_1, assignment.room)
|
93
|
+
assignment.room = room_2
|
94
|
+
assignment.save!
|
95
|
+
assert_equal(room_2, assignment.room)
|
96
|
+
end
|
79
97
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: composite_primary_keys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.0.
|
4
|
+
version: 12.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Savage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- README.rdoc
|
49
49
|
- Rakefile
|
50
50
|
- lib/composite_primary_keys.rb
|
51
|
+
- lib/composite_primary_keys/active_model/attribute_assignment.rb
|
51
52
|
- lib/composite_primary_keys/arel/sqlserver.rb
|
52
53
|
- lib/composite_primary_keys/arel/to_sql.rb
|
53
54
|
- lib/composite_primary_keys/associations/association.rb
|
@@ -126,14 +127,10 @@ files:
|
|
126
127
|
- test/fixtures/employees.yml
|
127
128
|
- test/fixtures/group.rb
|
128
129
|
- test/fixtures/groups.yml
|
129
|
-
- test/fixtures/hack.rb
|
130
|
-
- test/fixtures/hacks.yml
|
131
130
|
- test/fixtures/membership.rb
|
132
131
|
- test/fixtures/membership_status.rb
|
133
132
|
- test/fixtures/membership_statuses.yml
|
134
133
|
- test/fixtures/memberships.yml
|
135
|
-
- test/fixtures/pk_called_id.rb
|
136
|
-
- test/fixtures/pk_called_ids.yml
|
137
134
|
- test/fixtures/product.rb
|
138
135
|
- test/fixtures/product_tariff.rb
|
139
136
|
- test/fixtures/product_tariffs.yml
|
@@ -141,8 +138,6 @@ files:
|
|
141
138
|
- test/fixtures/reading.rb
|
142
139
|
- test/fixtures/readings.yml
|
143
140
|
- test/fixtures/reference_code.rb
|
144
|
-
- test/fixtures/reference_code_using_composite_key_alias.rb
|
145
|
-
- test/fixtures/reference_code_using_simple_key_alias.rb
|
146
141
|
- test/fixtures/reference_codes.yml
|
147
142
|
- test/fixtures/reference_type.rb
|
148
143
|
- test/fixtures/reference_types.yml
|
@@ -158,8 +153,6 @@ files:
|
|
158
153
|
- test/fixtures/room_attribute_assignments.yml
|
159
154
|
- test/fixtures/room_attributes.yml
|
160
155
|
- test/fixtures/rooms.yml
|
161
|
-
- test/fixtures/seat.rb
|
162
|
-
- test/fixtures/seats.yml
|
163
156
|
- test/fixtures/street.rb
|
164
157
|
- test/fixtures/streets.yml
|
165
158
|
- test/fixtures/student.rb
|
@@ -168,15 +161,12 @@ files:
|
|
168
161
|
- test/fixtures/suburbs.yml
|
169
162
|
- test/fixtures/tariff.rb
|
170
163
|
- test/fixtures/tariffs.yml
|
171
|
-
- test/fixtures/topic.rb
|
172
|
-
- test/fixtures/topic_source.rb
|
173
164
|
- test/fixtures/topic_sources.yml
|
174
165
|
- test/fixtures/topics.yml
|
175
166
|
- test/fixtures/user.rb
|
176
167
|
- test/fixtures/users.yml
|
177
168
|
- test/plugins/pagination.rb
|
178
169
|
- test/plugins/pagination_helper.rb
|
179
|
-
- test/test_aliases.rb
|
180
170
|
- test/test_associations.rb
|
181
171
|
- test/test_attribute_methods.rb
|
182
172
|
- test/test_attributes.rb
|
@@ -188,7 +178,6 @@ files:
|
|
188
178
|
- test/test_delete.rb
|
189
179
|
- test/test_dumpable.rb
|
190
180
|
- test/test_dup.rb
|
191
|
-
- test/test_enum.rb
|
192
181
|
- test/test_equal.rb
|
193
182
|
- test/test_exists.rb
|
194
183
|
- test/test_find.rb
|
@@ -203,7 +192,6 @@ files:
|
|
203
192
|
- test/test_preload.rb
|
204
193
|
- test/test_santiago.rb
|
205
194
|
- test/test_serialize.rb
|
206
|
-
- test/test_suite.rb
|
207
195
|
- test/test_touch.rb
|
208
196
|
- test/test_tutorial_example.rb
|
209
197
|
- test/test_update.rb
|
@@ -227,14 +215,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
215
|
- !ruby/object:Gem::Version
|
228
216
|
version: '0'
|
229
217
|
requirements: []
|
230
|
-
rubygems_version: 3.1.
|
218
|
+
rubygems_version: 3.1.4
|
231
219
|
signing_key:
|
232
220
|
specification_version: 4
|
233
221
|
summary: Composite key support for ActiveRecord
|
234
222
|
test_files:
|
235
223
|
- test/abstract_unit.rb
|
236
224
|
- test/README_tests.rdoc
|
237
|
-
- test/test_aliases.rb
|
238
225
|
- test/test_associations.rb
|
239
226
|
- test/test_attributes.rb
|
240
227
|
- test/test_attribute_methods.rb
|
@@ -246,7 +233,6 @@ test_files:
|
|
246
233
|
- test/test_delete.rb
|
247
234
|
- test/test_dumpable.rb
|
248
235
|
- test/test_dup.rb
|
249
|
-
- test/test_enum.rb
|
250
236
|
- test/test_equal.rb
|
251
237
|
- test/test_exists.rb
|
252
238
|
- test/test_find.rb
|
@@ -261,7 +247,6 @@ test_files:
|
|
261
247
|
- test/test_preload.rb
|
262
248
|
- test/test_santiago.rb
|
263
249
|
- test/test_serialize.rb
|
264
|
-
- test/test_suite.rb
|
265
250
|
- test/test_touch.rb
|
266
251
|
- test/test_tutorial_example.rb
|
267
252
|
- test/test_update.rb
|
data/test/fixtures/hack.rb
DELETED
data/test/fixtures/hacks.yml
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
class ReferenceCodeUsingCompositeKeyAlias < ActiveRecord::Base
|
2
|
-
self.table_name = 'reference_codes'
|
3
|
-
self.primary_key = [:reference_type_id, :reference_code]
|
4
|
-
|
5
|
-
belongs_to :reference_type, :foreign_key => "reference_type_id"
|
6
|
-
|
7
|
-
validates_presence_of :reference_code, :code_label, :abbreviation
|
8
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
class ReferenceCodeUsingSimpleKeyAlias < ActiveRecord::Base
|
2
|
-
self.table_name = 'reference_codes'
|
3
|
-
self.primary_key = :code_label
|
4
|
-
|
5
|
-
belongs_to :reference_type, :foreign_key => "reference_type_id"
|
6
|
-
|
7
|
-
validates_presence_of :reference_code, :code_label, :abbreviation
|
8
|
-
end
|
data/test/fixtures/seat.rb
DELETED
data/test/fixtures/seats.yml
DELETED
data/test/fixtures/topic.rb
DELETED