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.
Files changed (62) hide show
  1. data/History.txt +6 -0
  2. data/Rakefile +10 -1
  3. data/lib/composite_primary_keys.rb +75 -75
  4. data/lib/composite_primary_keys/base.rb +190 -194
  5. data/lib/composite_primary_keys/composite_arrays.rb +23 -23
  6. data/lib/composite_primary_keys/finder_methods.rb +0 -11
  7. data/lib/composite_primary_keys/reflection.rb +38 -38
  8. data/lib/composite_primary_keys/version.rb +2 -2
  9. data/test/abstract_unit.rb +3 -2
  10. data/test/connections/connection_spec.rb +1 -2
  11. data/test/connections/databases.example.yml +14 -12
  12. data/test/connections/databases.yml +14 -14
  13. data/test/connections/native_ibm_db/connection.rb +0 -3
  14. data/test/connections/native_mysql/connection.rb +3 -9
  15. data/test/connections/native_oracle/connection.rb +4 -10
  16. data/test/connections/native_oracle_enhanced/connection.rb +4 -11
  17. data/test/connections/native_postgresql/connection.rb +1 -3
  18. data/test/connections/native_sqlite/connection.rb +2 -4
  19. data/test/debug.log +589 -589
  20. data/test/fixtures/article.rb +5 -5
  21. data/test/fixtures/articles.yml +5 -5
  22. data/test/fixtures/capitol.rb +3 -0
  23. data/test/fixtures/capitols.yml +16 -0
  24. data/test/fixtures/db_definitions/mysql.sql +5 -0
  25. data/test/fixtures/db_definitions/postgresql.sql +5 -0
  26. data/test/fixtures/product.rb +7 -7
  27. data/test/fixtures/product_tariff.rb +5 -5
  28. data/test/fixtures/product_tariffs.yml +12 -12
  29. data/test/fixtures/products.yml +5 -5
  30. data/test/fixtures/reading.rb +4 -4
  31. data/test/fixtures/readings.yml +9 -9
  32. data/test/fixtures/reference_code.rb +7 -7
  33. data/test/fixtures/reference_codes.yml +29 -29
  34. data/test/fixtures/reference_type.rb +7 -7
  35. data/test/fixtures/reference_types.yml +9 -9
  36. data/test/fixtures/suburb.rb +5 -5
  37. data/test/fixtures/suburbs.yml +8 -8
  38. data/test/fixtures/tariff.rb +6 -6
  39. data/test/fixtures/tariffs.yml +12 -12
  40. data/test/fixtures/user.rb +10 -10
  41. data/test/fixtures/users.yml +5 -5
  42. data/test/hash_tricks.rb +34 -34
  43. data/test/test_associations.rb +180 -180
  44. data/test/test_attribute_methods.rb +0 -2
  45. data/test/test_attributes.rb +0 -5
  46. data/test/test_clone.rb +31 -33
  47. data/test/test_composite_arrays.rb +0 -2
  48. data/test/test_create.rb +0 -4
  49. data/test/test_delete.rb +92 -96
  50. data/test/test_equal.rb +21 -0
  51. data/test/test_exists.rb +0 -2
  52. data/test/test_find.rb +79 -76
  53. data/test/test_ids.rb +81 -83
  54. data/test/test_miscellaneous.rb +36 -38
  55. data/test/test_pagination.rb +35 -37
  56. data/test/test_polymorphic.rb +0 -6
  57. data/test/test_santiago.rb +23 -27
  58. data/test/test_suite.rb +1 -0
  59. data/test/test_tutorial_example.rb +0 -4
  60. data/test/test_update.rb +37 -39
  61. data/test/test_validations.rb +0 -1
  62. metadata +8 -4
@@ -1,39 +1,37 @@
1
- require 'abstract_unit'
2
- require 'fixtures/reference_type'
3
- require 'fixtures/reference_code'
4
-
5
- class TestMiscellaneous < ActiveSupport::TestCase
6
- fixtures :reference_types, :reference_codes, :products
7
-
8
- CLASSES = {
9
- :single => {
10
- :class => ReferenceType,
11
- :primary_keys => :reference_type_id,
12
- },
13
- :dual => {
14
- :class => ReferenceCode,
15
- :primary_keys => [:reference_type_id, :reference_code],
16
- },
17
- }
18
-
19
- def setup
20
- self.class.classes = CLASSES
21
- end
22
-
23
- def test_composite_class
24
- testing_with do
25
- assert_equal composite?, @klass.composite?
26
- end
27
- end
28
-
29
- def test_composite_instance
30
- testing_with do
31
- assert_equal composite?, @first.composite?
32
- end
33
- end
34
-
35
- def test_count
36
- assert_equal 2, Product.count
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
@@ -1,38 +1,36 @@
1
- require 'abstract_unit'
2
- require 'fixtures/reference_type'
3
- require 'fixtures/reference_code'
4
- require 'plugins/pagination'
5
-
6
- class TestPagination < ActiveSupport::TestCase
7
- fixtures :reference_types, :reference_codes
8
-
9
- include ActionController::Pagination
10
- DEFAULT_PAGE_SIZE = 2
11
-
12
- attr_accessor :params
13
-
14
- CLASSES = {
15
- :single => {
16
- :class => ReferenceType,
17
- :primary_keys => :reference_type_id,
18
- :table => :reference_types,
19
- },
20
- :dual => {
21
- :class => ReferenceCode,
22
- :primary_keys => [:reference_type_id, :reference_code],
23
- :table => :reference_codes,
24
- },
25
- }
26
-
27
- def setup
28
- self.class.classes = CLASSES
29
- @params = {}
30
- end
31
-
32
- def test_paginate_all
33
- testing_with do
34
- @object_pages, @objects = paginate @klass_info[:table], :per_page => DEFAULT_PAGE_SIZE
35
- assert_equal 2, @objects.length, "Each page should have #{DEFAULT_PAGE_SIZE} items"
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
@@ -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
@@ -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
- require 'abstract_unit'
5
- require 'fixtures/user'
6
- require 'fixtures/article'
7
- require 'fixtures/reading'
8
-
9
- class TestSantiago < ActiveSupport::TestCase
10
- fixtures :suburbs, :streets, :users, :articles, :readings
11
-
12
- def test_normal_and_composite_associations
13
- assert_not_nil @suburb = Suburb.find(1,1)
14
- assert_equal 1, @suburb.streets.length
15
-
16
- assert_not_nil @street = Street.find(1)
17
- assert_not_nil @street.suburb
18
- end
19
-
20
- def test_single_keys
21
- @santiago = User.find(1)
22
- assert_not_nil @santiago.articles
23
- assert_equal 2, @santiago.articles.length
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
@@ -7,6 +7,7 @@ require 'test_clone'
7
7
  require 'test_composite_arrays'
8
8
  require 'test_create'
9
9
  require 'test_delete'
10
+ require 'test_equal'
10
11
  require 'test_exists'
11
12
  require 'test_find'
12
13
  require 'test_ids'
@@ -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
@@ -1,40 +1,38 @@
1
- require 'abstract_unit'
2
- require 'fixtures/reference_type'
3
- require 'fixtures/reference_code'
4
-
5
- class TestUpdate < ActiveSupport::TestCase
6
- fixtures :reference_types, :reference_codes
7
-
8
- CLASSES = {
9
- :single => {
10
- :class => ReferenceType,
11
- :primary_keys => :reference_type_id,
12
- :update => { :description => 'RT Desc' },
13
- },
14
- :dual => {
15
- :class => ReferenceCode,
16
- :primary_keys => [:reference_type_id, :reference_code],
17
- :update => { :description => 'RT Desc' },
18
- },
19
- }
20
-
21
- def setup
22
- self.class.classes = CLASSES
23
- end
24
-
25
- def test_setup
26
- testing_with do
27
- assert_not_nil @klass_info[:update]
28
- end
29
- end
30
-
31
- def test_update_attributes
32
- testing_with do
33
- assert @first.update_attributes(@klass_info[:update])
34
- assert @first.reload
35
- @klass_info[:update].each_pair do |attr_name, new_value|
36
- assert_equal new_value, @first[attr_name], "Attribute #{attr_name} is incorrect"
37
- end
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
@@ -1,5 +1,4 @@
1
1
  require 'abstract_unit'
2
- require 'fixtures/seat'
3
2
 
4
3
  class TestValidations < ActiveSupport::TestCase
5
4
  fixtures :seats
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: 21
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 3
8
+ - 1
8
9
  - 0
9
- - 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-04 00:00:00 -07:00
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