composite_primary_keys 3.0.9 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Rakefile +10 -1
- data/lib/composite_primary_keys.rb +75 -75
- data/lib/composite_primary_keys/base.rb +190 -194
- data/lib/composite_primary_keys/composite_arrays.rb +23 -23
- data/lib/composite_primary_keys/finder_methods.rb +0 -11
- data/lib/composite_primary_keys/reflection.rb +38 -38
- data/lib/composite_primary_keys/version.rb +2 -2
- data/test/abstract_unit.rb +3 -2
- data/test/connections/connection_spec.rb +1 -2
- data/test/connections/databases.example.yml +14 -12
- data/test/connections/databases.yml +14 -14
- data/test/connections/native_ibm_db/connection.rb +0 -3
- data/test/connections/native_mysql/connection.rb +3 -9
- data/test/connections/native_oracle/connection.rb +4 -10
- data/test/connections/native_oracle_enhanced/connection.rb +4 -11
- data/test/connections/native_postgresql/connection.rb +1 -3
- data/test/connections/native_sqlite/connection.rb +2 -4
- data/test/debug.log +589 -589
- data/test/fixtures/article.rb +5 -5
- data/test/fixtures/articles.yml +5 -5
- data/test/fixtures/capitol.rb +3 -0
- data/test/fixtures/capitols.yml +16 -0
- data/test/fixtures/db_definitions/mysql.sql +5 -0
- data/test/fixtures/db_definitions/postgresql.sql +5 -0
- data/test/fixtures/product.rb +7 -7
- data/test/fixtures/product_tariff.rb +5 -5
- data/test/fixtures/product_tariffs.yml +12 -12
- data/test/fixtures/products.yml +5 -5
- data/test/fixtures/reading.rb +4 -4
- data/test/fixtures/readings.yml +9 -9
- data/test/fixtures/reference_code.rb +7 -7
- data/test/fixtures/reference_codes.yml +29 -29
- data/test/fixtures/reference_type.rb +7 -7
- data/test/fixtures/reference_types.yml +9 -9
- data/test/fixtures/suburb.rb +5 -5
- data/test/fixtures/suburbs.yml +8 -8
- data/test/fixtures/tariff.rb +6 -6
- data/test/fixtures/tariffs.yml +12 -12
- data/test/fixtures/user.rb +10 -10
- data/test/fixtures/users.yml +5 -5
- data/test/hash_tricks.rb +34 -34
- data/test/test_associations.rb +180 -180
- data/test/test_attribute_methods.rb +0 -2
- data/test/test_attributes.rb +0 -5
- data/test/test_clone.rb +31 -33
- data/test/test_composite_arrays.rb +0 -2
- data/test/test_create.rb +0 -4
- data/test/test_delete.rb +92 -96
- data/test/test_equal.rb +21 -0
- data/test/test_exists.rb +0 -2
- data/test/test_find.rb +79 -76
- data/test/test_ids.rb +81 -83
- data/test/test_miscellaneous.rb +36 -38
- data/test/test_pagination.rb +35 -37
- data/test/test_polymorphic.rb +0 -6
- data/test/test_santiago.rb +23 -27
- data/test/test_suite.rb +1 -0
- data/test/test_tutorial_example.rb +0 -4
- data/test/test_update.rb +37 -39
- data/test/test_validations.rb +0 -1
- metadata +8 -4
data/test/test_miscellaneous.rb
CHANGED
@@ -1,39 +1,37 @@
|
|
1
|
-
require 'abstract_unit'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class TestMiscellaneous < ActiveSupport::TestCase
|
4
|
+
fixtures :reference_types, :reference_codes, :products
|
5
|
+
|
6
|
+
CLASSES = {
|
7
|
+
:single => {
|
8
|
+
:class => ReferenceType,
|
9
|
+
:primary_keys => :reference_type_id,
|
10
|
+
},
|
11
|
+
:dual => {
|
12
|
+
:class => ReferenceCode,
|
13
|
+
:primary_keys => [:reference_type_id, :reference_code],
|
14
|
+
},
|
15
|
+
}
|
16
|
+
|
17
|
+
def setup
|
18
|
+
self.class.classes = CLASSES
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_composite_class
|
22
|
+
testing_with do
|
23
|
+
assert_equal composite?, @klass.composite?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_composite_instance
|
28
|
+
testing_with do
|
29
|
+
assert_equal composite?, @first.composite?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_count
|
34
|
+
assert_equal 2, Product.count
|
35
|
+
end
|
36
|
+
|
39
37
|
end
|
data/test/test_pagination.rb
CHANGED
@@ -1,38 +1,36 @@
|
|
1
|
-
require 'abstract_unit'
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
:
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
1
|
+
require 'abstract_unit'
|
2
|
+
require 'plugins/pagination'
|
3
|
+
|
4
|
+
class TestPagination < ActiveSupport::TestCase
|
5
|
+
fixtures :reference_types, :reference_codes
|
6
|
+
|
7
|
+
include ActionController::Pagination
|
8
|
+
DEFAULT_PAGE_SIZE = 2
|
9
|
+
|
10
|
+
attr_accessor :params
|
11
|
+
|
12
|
+
CLASSES = {
|
13
|
+
:single => {
|
14
|
+
:class => ReferenceType,
|
15
|
+
:primary_keys => :reference_type_id,
|
16
|
+
:table => :reference_types,
|
17
|
+
},
|
18
|
+
:dual => {
|
19
|
+
:class => ReferenceCode,
|
20
|
+
:primary_keys => [:reference_type_id, :reference_code],
|
21
|
+
:table => :reference_codes,
|
22
|
+
},
|
23
|
+
}
|
24
|
+
|
25
|
+
def setup
|
26
|
+
self.class.classes = CLASSES
|
27
|
+
@params = {}
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_paginate_all
|
31
|
+
testing_with do
|
32
|
+
@object_pages, @objects = paginate @klass_info[:table], :per_page => DEFAULT_PAGE_SIZE
|
33
|
+
assert_equal 2, @objects.length, "Each page should have #{DEFAULT_PAGE_SIZE} items"
|
34
|
+
end
|
35
|
+
end
|
38
36
|
end
|
data/test/test_polymorphic.rb
CHANGED
@@ -1,10 +1,4 @@
|
|
1
1
|
require 'abstract_unit'
|
2
|
-
require 'fixtures/comment'
|
3
|
-
require 'fixtures/article'
|
4
|
-
require 'fixtures/reading'
|
5
|
-
require 'fixtures/user'
|
6
|
-
require 'fixtures/employee'
|
7
|
-
require 'fixtures/hack'
|
8
2
|
|
9
3
|
class TestPolymorphic < ActiveSupport::TestCase
|
10
4
|
fixtures :users, :employees, :comments, :hacks
|
data/test/test_santiago.rb
CHANGED
@@ -1,27 +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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
assert_not_nil @suburb
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
@santiago
|
22
|
-
|
23
|
-
|
24
|
-
assert_not_nil @santiago.readings
|
25
|
-
assert_equal 2, @santiago.readings.length
|
26
|
-
end
|
27
|
-
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 'abstract_unit'
|
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
|
data/test/test_suite.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
1
|
require 'abstract_unit'
|
2
|
-
require 'fixtures/user'
|
3
|
-
require 'fixtures/group'
|
4
|
-
require 'fixtures/membership_status'
|
5
|
-
require 'fixtures/membership'
|
6
2
|
|
7
3
|
class TestTutorialExample < ActiveSupport::TestCase
|
8
4
|
fixtures :users, :groups, :memberships, :membership_statuses
|
data/test/test_update.rb
CHANGED
@@ -1,40 +1,38 @@
|
|
1
|
-
require 'abstract_unit'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
:
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
1
|
+
require 'abstract_unit'
|
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_attributes(@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], "Attribute #{attr_name} is incorrect"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
40
38
|
end
|
data/test/test_validations.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: composite_primary_keys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 3
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 3.0.9
|
10
|
+
version: 3.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dr Nic Williams
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-12-
|
19
|
+
date: 2010-12-17 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -117,6 +117,8 @@ files:
|
|
117
117
|
- test/fixtures/articles.yml
|
118
118
|
- test/fixtures/article_group.rb
|
119
119
|
- test/fixtures/article_groups.yml
|
120
|
+
- test/fixtures/capitol.rb
|
121
|
+
- test/fixtures/capitols.yml
|
120
122
|
- test/fixtures/comment.rb
|
121
123
|
- test/fixtures/comments.yml
|
122
124
|
- test/fixtures/db_definitions/db2-create-tables.sql
|
@@ -186,6 +188,7 @@ files:
|
|
186
188
|
- test/test_composite_arrays.rb
|
187
189
|
- test/test_create.rb
|
188
190
|
- test/test_delete.rb
|
191
|
+
- test/test_equal.rb
|
189
192
|
- test/test_exists.rb
|
190
193
|
- test/test_find.rb
|
191
194
|
- test/test_ids.rb
|
@@ -245,6 +248,7 @@ test_files:
|
|
245
248
|
- test/test_composite_arrays.rb
|
246
249
|
- test/test_create.rb
|
247
250
|
- test/test_delete.rb
|
251
|
+
- test/test_equal.rb
|
248
252
|
- test/test_exists.rb
|
249
253
|
- test/test_find.rb
|
250
254
|
- test/test_ids.rb
|