composite_primary_keys 8.1.6 → 8.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +5 -5
  2. data/History.rdoc +5 -0
  3. data/lib/composite_primary_keys/connection_adapters/abstract_adapter.rb +10 -10
  4. data/lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb +1 -1
  5. data/lib/composite_primary_keys/relation/batches.rb +1 -1
  6. data/lib/composite_primary_keys/version.rb +1 -1
  7. data/scripts/console.rb +48 -48
  8. data/scripts/txt2html +76 -76
  9. data/scripts/txt2js +65 -65
  10. data/tasks/website.rake +18 -18
  11. data/test/README_tests.rdoc +56 -56
  12. data/test/connections/databases.yml +39 -30
  13. data/test/db_test.rb +52 -52
  14. data/test/fixtures/articles.yml +6 -6
  15. data/test/fixtures/capitol.rb +3 -3
  16. data/test/fixtures/capitols.yml +16 -16
  17. data/test/fixtures/comments.yml +15 -15
  18. data/test/fixtures/department.rb +5 -5
  19. data/test/fixtures/departments.yml +15 -15
  20. data/test/fixtures/dorms.yml +4 -4
  21. data/test/fixtures/group.rb +2 -2
  22. data/test/fixtures/groups.yml +6 -6
  23. data/test/fixtures/hack.rb +4 -4
  24. data/test/fixtures/hacks.yml +2 -2
  25. data/test/fixtures/membership_status.rb +2 -2
  26. data/test/fixtures/product.rb +9 -9
  27. data/test/fixtures/product_tariff.rb +5 -5
  28. data/test/fixtures/products.yml +11 -11
  29. data/test/fixtures/reading.rb +4 -4
  30. data/test/fixtures/readings.yml +10 -10
  31. data/test/fixtures/reference_code_using_composite_key_alias.rb +8 -8
  32. data/test/fixtures/reference_code_using_simple_key_alias.rb +8 -8
  33. data/test/fixtures/reference_codes.yml +28 -28
  34. data/test/fixtures/reference_types.yml +9 -9
  35. data/test/fixtures/restaurant.rb +9 -9
  36. data/test/fixtures/restaurants.yml +14 -14
  37. data/test/fixtures/restaurants_suburbs.yml +10 -10
  38. data/test/fixtures/room.rb +11 -11
  39. data/test/fixtures/room_assignment.rb +13 -13
  40. data/test/fixtures/room_assignments.yml +24 -24
  41. data/test/fixtures/room_attribute.rb +2 -2
  42. data/test/fixtures/room_attribute_assignment.rb +4 -4
  43. data/test/fixtures/room_attribute_assignments.yml +4 -4
  44. data/test/fixtures/room_attributes.yml +2 -2
  45. data/test/fixtures/rooms.yml +12 -12
  46. data/test/fixtures/seat.rb +5 -5
  47. data/test/fixtures/seats.yml +8 -8
  48. data/test/fixtures/street.rb +2 -2
  49. data/test/fixtures/streets.yml +16 -16
  50. data/test/fixtures/student.rb +3 -3
  51. data/test/fixtures/students.yml +15 -15
  52. data/test/fixtures/suburbs.yml +14 -14
  53. data/test/fixtures/tariffs.yml +14 -14
  54. data/test/plugins/pagination.rb +405 -405
  55. data/test/plugins/pagination_helper.rb +135 -135
  56. data/test/setup.rb +50 -50
  57. data/test/test_aliases.rb +18 -18
  58. data/test/test_composite_arrays.rb +24 -24
  59. data/test/test_counter_cache.rb +30 -30
  60. data/test/test_dup.rb +37 -37
  61. data/test/test_exists.rb +39 -39
  62. data/test/test_miscellaneous.rb +32 -32
  63. data/test/test_pagination.rb +35 -35
  64. data/test/test_update_all.rb +17 -0
  65. data/test/test_validations.rb +13 -13
  66. metadata +5 -4
@@ -1,18 +1,18 @@
1
- desc 'Generate website files'
2
- task :website_generate do
3
- sh %{ ruby scripts/txt2html website/index.txt > website/index.html }
4
- sh %{ ruby scripts/txt2js website/version.txt > website/version.js }
5
- sh %{ ruby scripts/txt2js website/version-raw.txt > website/version-raw.js }
6
- end
7
-
8
- desc 'Upload website files to rubyforge'
9
- task :website_upload do
10
- config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
11
- host = "#{config["username"]}@rubyforge.org"
12
- remote_dir = "/var/www/gforge-projects/compositekeys/"
13
- local_dir = 'website'
14
- sh %{scp -r #{local_dir}/* #{host}:#{remote_dir}}
15
- end
16
-
17
- desc 'Generate and upload website files'
18
- task :website => [:website_generate, :website_upload]
1
+ desc 'Generate website files'
2
+ task :website_generate do
3
+ sh %{ ruby scripts/txt2html website/index.txt > website/index.html }
4
+ sh %{ ruby scripts/txt2js website/version.txt > website/version.js }
5
+ sh %{ ruby scripts/txt2js website/version-raw.txt > website/version-raw.js }
6
+ end
7
+
8
+ desc 'Upload website files to rubyforge'
9
+ task :website_upload do
10
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
11
+ host = "#{config["username"]}@rubyforge.org"
12
+ remote_dir = "/var/www/gforge-projects/compositekeys/"
13
+ local_dir = 'website'
14
+ sh %{scp -r #{local_dir}/* #{host}:#{remote_dir}}
15
+ end
16
+
17
+ desc 'Generate and upload website files'
18
+ task :website => [:website_generate, :website_upload]
@@ -1,56 +1,56 @@
1
- = Composite Primary Keys - Testing Readme
2
-
3
- == Testing an adapter
4
-
5
- There are tests available for the following adapters:
6
-
7
- * ibmdb
8
- * mysql
9
- * oracle
10
- * oracle_enhanced
11
- * postgresql
12
- * sqlite3
13
-
14
- To run the tests for one of the adapters follow these steps (using mysql in the example):
15
-
16
- * You will need the following gems:
17
- - rake
18
- - activerecord (3.1.0.rc5 or later)
19
- - mysql (or the adapter of your choice)
20
-
21
- * Put your database connection settings in test/connections/databases.yml.
22
- Look at databases.example.yml for examples.
23
-
24
- mysql:
25
- adapter: mysql
26
- username: root
27
- database: composite_primary_keys_unittest
28
-
29
- * rake -T mysql
30
-
31
- rake mysql:build_database # Build the MySQL test databases
32
- rake mysql:drop_database # Drop the MySQL test databases
33
- rake mysql:rebuild_database # Rebuild the MySQL test databases
34
- rake mysql:test # Run tests using the mysql adapter
35
-
36
- * rake mysql:build_database
37
- * rake mysql:test
38
-
39
- == Running tests individually
40
-
41
- You can specify which test you'd like to run on the command line:
42
-
43
- * rake mysql:test TEST=test/test_equal.rb
44
-
45
- If you want to run closer to the metal you can cd into the test/
46
- directory and run the tests like so:
47
-
48
- * ADAPTER=mysql ruby test_equal.rb
49
-
50
- == Logging
51
-
52
- By default, ActiveRecord's log messages are sent to standard out when
53
- running the tests. If you would prefer to send them to a file, specify
54
- it as the environment variable CPK_LOGFILE:
55
-
56
- * CPK_LOGFILE=cpk_test.log rake mysql:test
1
+ = Composite Primary Keys - Testing Readme
2
+
3
+ == Testing an adapter
4
+
5
+ There are tests available for the following adapters:
6
+
7
+ * ibmdb
8
+ * mysql
9
+ * oracle
10
+ * oracle_enhanced
11
+ * postgresql
12
+ * sqlite3
13
+
14
+ To run the tests for one of the adapters follow these steps (using mysql in the example):
15
+
16
+ * You will need the following gems:
17
+ - rake
18
+ - activerecord (3.1.0.rc5 or later)
19
+ - mysql (or the adapter of your choice)
20
+
21
+ * Put your database connection settings in test/connections/databases.yml.
22
+ Look at databases.example.yml for examples.
23
+
24
+ mysql:
25
+ adapter: mysql
26
+ username: root
27
+ database: composite_primary_keys_unittest
28
+
29
+ * rake -T mysql
30
+
31
+ rake mysql:build_database # Build the MySQL test databases
32
+ rake mysql:drop_database # Drop the MySQL test databases
33
+ rake mysql:rebuild_database # Rebuild the MySQL test databases
34
+ rake mysql:test # Run tests using the mysql adapter
35
+
36
+ * rake mysql:build_database
37
+ * rake mysql:test
38
+
39
+ == Running tests individually
40
+
41
+ You can specify which test you'd like to run on the command line:
42
+
43
+ * rake mysql:test TEST=test/test_equal.rb
44
+
45
+ If you want to run closer to the metal you can cd into the test/
46
+ directory and run the tests like so:
47
+
48
+ * ADAPTER=mysql ruby test_equal.rb
49
+
50
+ == Logging
51
+
52
+ By default, ActiveRecord's log messages are sent to standard out when
53
+ running the tests. If you would prefer to send them to a file, specify
54
+ it as the environment variable CPK_LOGFILE:
55
+
56
+ * CPK_LOGFILE=cpk_test.log rake mysql:test
@@ -1,30 +1,39 @@
1
- mysql:
2
- adapter: mysql2
3
- username: root
4
- password: mysql
5
- database: composite_primary_keys_unittest
6
-
7
- oracle:
8
- adapter: oracle_enhanced
9
- database: xe
10
- username: SYSTEM
11
- password: oracle
12
- host: localhost
13
-
14
- postgresql:
15
- adapter: postgresql
16
- database: composite_primary_keys_unittest
17
- username: postgres
18
- host: localhost
19
-
20
- sqlite:
21
- adapter: sqlite3
22
- database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %>
23
-
24
- sqlserver:
25
- adapter: sqlserver
26
- username: cpk
27
- password: cpk
28
- database: composite_primary_keys_unittest
29
- host: localhost
30
- port: 1433
1
+ # To run tests:
2
+ # 1. Copy this file to test/connections/databases.yml.
3
+ # 2. Update to match the databases you want to test against.
4
+
5
+ ibm_db:
6
+ database: ocdpdev
7
+ username: db2inst1
8
+ password: password
9
+ host: localhost
10
+
11
+ mysql:
12
+ adapter: mysql2
13
+ username: root
14
+ database: composite_primary_keys_unittest
15
+
16
+ oracle:
17
+ adapter: oracle_enhanced
18
+ database: xe
19
+ username: SYSTEM
20
+ password: oracle
21
+ host: localhost
22
+
23
+ postgresql:
24
+ adapter: postgresql
25
+ database: composite_primary_keys_unittest
26
+ username: postgres
27
+ host: localhost
28
+
29
+ sqlite:
30
+ adapter: sqlite3
31
+ database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %>
32
+
33
+ sqlserver:
34
+ adapter: sqlserver
35
+ username: cpk
36
+ password: cpk
37
+ database: composite_primary_keys_unittest
38
+ host: localhost
39
+ port: 1433
@@ -1,53 +1,53 @@
1
- # assoc_test.rb
2
-
3
- path = File.expand_path(File.join(File.basename(__FILE__), "..", "lib", "composite_primary_keys"))
4
- puts path
5
-
6
- require File.join(path)
7
- require 'active_record'
8
-
9
- $configuration = {
10
- :adapter => 'postgresql',
11
- :database => 'cpk_test',
12
- :username => 'postgres'
13
- }
14
-
15
- ActiveRecord::Base.establish_connection($configuration) unless ActiveRecord::Base.connected?
16
-
17
- module GlobePG
18
- class PGBase < ActiveRecord::Base
19
- self.abstract_class = true
20
- # establish_connection($configuration) unless connected?
21
- end
22
- end
23
-
24
- module GlobePG
25
- class TeacherToSchool < PGBase
26
- set_table_name 'teacher_to_school'
27
- self.primary_keys = ['teacherid', 'schoolid']
28
-
29
- belongs_to :globe_teacher, :foreign_key => 'teacherid'
30
- belongs_to :globe_school, :foreign_key => 'schoolid'
31
- end
32
- end
33
-
34
- module GlobePG
35
- class GlobeSchool < PGBase
36
- set_table_name 'globe_school'
37
- self.primary_key = 'schoolid'
38
- has_many :teacher_to_schools, :foreign_key => :schoolid
39
- has_many :globe_teachers, :through => :teacher_to_schools
40
- end
41
- end
42
-
43
- module GlobePG
44
- class GlobeTeacher < PGBase
45
- set_table_name 'globe_teacher'
46
- self.primary_key = 'teacherid'
47
- has_many :teacher_to_schools, :foreign_key => :teacherid
48
- has_many :globe_schools, :through => :teacher_to_schools
49
- end
50
- end
51
-
52
- teacher = GlobePG::GlobeTeacher.find_by_teacherid('ZZGLOBEY')
1
+ # assoc_test.rb
2
+
3
+ path = File.expand_path(File.join(File.basename(__FILE__), "..", "lib", "composite_primary_keys"))
4
+ puts path
5
+
6
+ require File.join(path)
7
+ require 'active_record'
8
+
9
+ $configuration = {
10
+ :adapter => 'postgresql',
11
+ :database => 'cpk_test',
12
+ :username => 'postgres'
13
+ }
14
+
15
+ ActiveRecord::Base.establish_connection($configuration) unless ActiveRecord::Base.connected?
16
+
17
+ module GlobePG
18
+ class PGBase < ActiveRecord::Base
19
+ self.abstract_class = true
20
+ # establish_connection($configuration) unless connected?
21
+ end
22
+ end
23
+
24
+ module GlobePG
25
+ class TeacherToSchool < PGBase
26
+ set_table_name 'teacher_to_school'
27
+ self.primary_keys = ['teacherid', 'schoolid']
28
+
29
+ belongs_to :globe_teacher, :foreign_key => 'teacherid'
30
+ belongs_to :globe_school, :foreign_key => 'schoolid'
31
+ end
32
+ end
33
+
34
+ module GlobePG
35
+ class GlobeSchool < PGBase
36
+ set_table_name 'globe_school'
37
+ self.primary_key = 'schoolid'
38
+ has_many :teacher_to_schools, :foreign_key => :schoolid
39
+ has_many :globe_teachers, :through => :teacher_to_schools
40
+ end
41
+ end
42
+
43
+ module GlobePG
44
+ class GlobeTeacher < PGBase
45
+ set_table_name 'globe_teacher'
46
+ self.primary_key = 'teacherid'
47
+ has_many :teacher_to_schools, :foreign_key => :teacherid
48
+ has_many :globe_schools, :through => :teacher_to_schools
49
+ end
50
+ end
51
+
52
+ teacher = GlobePG::GlobeTeacher.find_by_teacherid('ZZGLOBEY')
53
53
  p teacher.globe_schools
@@ -1,7 +1,7 @@
1
- first:
2
- id: 1
3
- name: Article One
4
-
5
- second:
6
- id: 2
1
+ first:
2
+ id: 1
3
+ name: Article One
4
+
5
+ second:
6
+ id: 2
7
7
  name: Article Two
@@ -1,3 +1,3 @@
1
- class Capitol < ActiveRecord::Base
2
- self.primary_keys = :country, :city
3
- end
1
+ class Capitol < ActiveRecord::Base
2
+ self.primary_keys = :country, :city
3
+ end
@@ -1,16 +1,16 @@
1
- netherlands:
2
- country: The Netherlands
3
- city: Amsterdam
4
-
5
- france:
6
- country: France
7
- city: Paris
8
-
9
- canada:
10
- country: Canada
11
- city: Ottawa
12
-
13
- mexico:
14
- country: Mexico
15
- city: Mexico City
16
-
1
+ netherlands:
2
+ country: The Netherlands
3
+ city: Amsterdam
4
+
5
+ france:
6
+ country: France
7
+ city: Paris
8
+
9
+ canada:
10
+ country: Canada
11
+ city: Ottawa
12
+
13
+ mexico:
14
+ country: Mexico
15
+ city: Mexico City
16
+
@@ -1,16 +1,16 @@
1
- comment1:
2
- id: 1
3
- person_id: 1
4
- person_type: Employee
5
-
6
- comment2:
7
- id: 2
8
- person_id: 1
9
- person_type: User
10
- hack_id: 7
11
-
12
- comment3:
13
- id: 3
14
- person_id: 7
15
- person_type: Hack
1
+ comment1:
2
+ id: 1
3
+ person_id: 1
4
+ person_type: Employee
5
+
6
+ comment2:
7
+ id: 2
8
+ person_id: 1
9
+ person_type: User
10
+ hack_id: 7
11
+
12
+ comment3:
13
+ id: 3
14
+ person_id: 7
15
+ person_type: Hack
16
16
 
@@ -1,5 +1,5 @@
1
- class Department < ActiveRecord::Base
2
- self.primary_keys = :department_id, :location_id
3
- has_many :employees, :foreign_key => [:department_id, :location_id]
4
- has_one :head, :class_name => 'Employee', :foreign_key => [:department_id, :location_id], :dependent => :delete
5
- end
1
+ class Department < ActiveRecord::Base
2
+ self.primary_keys = :department_id, :location_id
3
+ has_many :employees, :foreign_key => [:department_id, :location_id]
4
+ has_one :head, :class_name => 'Employee', :foreign_key => [:department_id, :location_id], :dependent => :delete
5
+ end
@@ -1,15 +1,15 @@
1
- accounting:
2
- department_id: 1
3
- location_id: 1
4
-
5
- engineering:
6
- department_id: 2
7
- location_id: 1
8
-
9
- human_resources:
10
- department_id: 3
11
- location_id: 2
12
-
13
- offsite_accounting:
14
- department_id: 1
15
- location_id: 2
1
+ accounting:
2
+ department_id: 1
3
+ location_id: 1
4
+
5
+ engineering:
6
+ department_id: 2
7
+ location_id: 1
8
+
9
+ human_resources:
10
+ department_id: 3
11
+ location_id: 2
12
+
13
+ offsite_accounting:
14
+ department_id: 1
15
+ location_id: 2