has_many_polymorphs 2.11 → 2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +3 -1
  3. data/Manifest +43 -61
  4. data/README +30 -0
  5. data/TODO +0 -3
  6. data/generators/tagging/tagging_generator.rb +2 -0
  7. data/generators/tagging/templates/tag_test.rb +7 -2
  8. data/generators/tagging/templates/tagging.rb +2 -2
  9. data/generators/tagging/templates/tagging_extensions.rb +49 -2
  10. data/generators/tagging/templates/tagging_test.rb +32 -9
  11. data/generators/tagging/templates/tags.yml +2 -2
  12. data/has_many_polymorphs.gemspec +20 -13
  13. data/lib/has_many_polymorphs.rb +0 -1
  14. data/lib/has_many_polymorphs/autoload.rb +45 -37
  15. data/lib/has_many_polymorphs/class_methods.rb +2 -15
  16. data/lib/has_many_polymorphs/configuration.rb +2 -2
  17. data/lib/has_many_polymorphs/rake_task_redefine_task.rb +9 -1
  18. data/test/generator/tagging_generator_test.rb +42 -0
  19. data/test/integration/app/app/controllers/bones_controller.rb +5 -0
  20. data/test/integration/app/app/helpers/bones_helper.rb +2 -0
  21. data/test/integration/app/app/models/bone.rb +2 -0
  22. data/test/integration/app/app/models/double_sti_parent.rb +2 -0
  23. data/test/integration/app/app/models/double_sti_parent_relationship.rb +2 -0
  24. data/test/integration/app/app/models/organic_substance.rb +2 -0
  25. data/test/integration/app/app/models/single_sti_parent.rb +4 -0
  26. data/test/integration/app/app/models/single_sti_parent_relationship.rb +4 -0
  27. data/test/integration/app/app/models/stick.rb +2 -0
  28. data/test/integration/app/app/models/stone.rb +2 -0
  29. data/test/integration/app/app/views/bones/index.rhtml +5 -0
  30. data/test/integration/app/config/boot.rb +97 -32
  31. data/test/integration/app/config/database.yml +8 -12
  32. data/test/integration/app/config/environment.rb +9 -3
  33. data/test/integration/app/config/environment.rb.canonical +19 -0
  34. data/test/integration/app/config/environments/development.rb +6 -5
  35. data/test/integration/app/db/migrate/001_create_sticks.rb +11 -0
  36. data/test/integration/app/db/migrate/002_create_stones.rb +11 -0
  37. data/test/integration/app/db/migrate/003_create_organic_substances.rb +11 -0
  38. data/test/integration/app/db/migrate/004_create_bones.rb +8 -0
  39. data/test/integration/app/db/migrate/005_create_single_sti_parents.rb +11 -0
  40. data/test/integration/app/db/migrate/006_create_double_sti_parents.rb +11 -0
  41. data/test/integration/app/db/migrate/007_create_single_sti_parent_relationships.rb +13 -0
  42. data/test/integration/app/db/migrate/008_create_double_sti_parent_relationships.rb +14 -0
  43. data/test/integration/app/db/migrate/009_create_library_model.rb +11 -0
  44. data/test/integration/app/db/schema.rb +21 -121
  45. data/test/integration/app/hmp_development +0 -0
  46. data/test/integration/app/lib/library_model.rb +2 -0
  47. data/test/integration/app/test/fixtures/double_sti_parent_relationships.yml +7 -0
  48. data/test/integration/app/test/fixtures/double_sti_parents.yml +7 -0
  49. data/test/integration/app/test/fixtures/organic_substances.yml +5 -0
  50. data/test/integration/app/test/fixtures/single_sti_parent_relationships.yml +7 -0
  51. data/test/integration/app/test/fixtures/single_sti_parents.yml +7 -0
  52. data/test/integration/app/test/fixtures/sticks.yml +7 -0
  53. data/test/integration/app/test/fixtures/stones.yml +7 -0
  54. data/test/integration/app/test/{unit/user_test.rb → functional/bones_controller_test.rb} +1 -3
  55. data/test/integration/app/test/test_helper.rb +1 -21
  56. data/test/integration/app/test/unit/{state_test.rb → bone_test.rb} +1 -3
  57. data/test/integration/app/test/unit/{seller_test.rb → double_sti_parent_relationship_test.rb} +1 -3
  58. data/test/integration/app/test/unit/{address_test.rb → double_sti_parent_test.rb} +1 -3
  59. data/test/integration/app/test/unit/organic_substance_test.rb +8 -0
  60. data/test/integration/app/test/unit/single_sti_parent_relationship_test.rb +8 -0
  61. data/test/integration/app/test/unit/single_sti_parent_test.rb +8 -0
  62. data/test/integration/app/test/unit/stick_test.rb +8 -0
  63. data/test/integration/app/test/unit/stone_test.rb +8 -0
  64. data/test/integration/server_test.rb +43 -0
  65. data/test/patches/symlinked_plugins_1.2.6.diff +46 -0
  66. data/test/setup.rb +6 -2
  67. data/test/test_helper.rb +32 -16
  68. data/test/unit/{polymorph_test.rb → has_many_polymorphs_test.rb} +16 -16
  69. metadata +49 -65
  70. metadata.gz.sig +0 -0
  71. data/generators/commenting/commenting_generator.rb +0 -94
  72. data/generators/commenting/templates/comment.rb +0 -33
  73. data/generators/commenting/templates/comment_test.rb +0 -12
  74. data/generators/commenting/templates/commenting.rb +0 -13
  75. data/generators/commenting/templates/commenting_extensions.rb +0 -30
  76. data/generators/commenting/templates/commenting_test.rb +0 -30
  77. data/generators/commenting/templates/commentings.yml +0 -23
  78. data/generators/commenting/templates/comments.yml +0 -13
  79. data/generators/commenting/templates/migration.rb +0 -28
  80. data/lib/has_many_polymorphs/dependencies.rb +0 -41
  81. data/test/integration/app/app/controllers/addresses_controller.rb +0 -85
  82. data/test/integration/app/app/controllers/sellers_controller.rb +0 -85
  83. data/test/integration/app/app/controllers/states_controller.rb +0 -85
  84. data/test/integration/app/app/controllers/users_controller.rb +0 -85
  85. data/test/integration/app/app/models/address.rb +0 -4
  86. data/test/integration/app/app/models/citation.rb +0 -3
  87. data/test/integration/app/app/models/citations_item.rb +0 -4
  88. data/test/integration/app/app/models/seller.rb +0 -4
  89. data/test/integration/app/app/models/state.rb +0 -3
  90. data/test/integration/app/app/models/user.rb +0 -4
  91. data/test/integration/app/db/migrate/001_create_users.rb +0 -16
  92. data/test/integration/app/db/migrate/002_create_sellers.rb +0 -14
  93. data/test/integration/app/db/migrate/003_create_addresses.rb +0 -19
  94. data/test/integration/app/db/migrate/004_create_states.rb +0 -12
  95. data/test/integration/app/db/migrate/005_add_capitalization_to_seller.rb +0 -9
  96. data/test/integration/app/db/migrate/006_add_deleted_to_user.rb +0 -9
  97. data/test/integration/app/db/migrate/007_add_lat_and_long_to_address.rb +0 -11
  98. data/test/integration/app/db/migrate/008_create_citations.rb +0 -12
  99. data/test/integration/app/db/migrate/009_create_citations_items.rb +0 -14
  100. data/test/integration/app/generated_models/aquatic_fish.rb +0 -109
  101. data/test/integration/app/generated_models/aquatic_pupils_whale.rb +0 -13
  102. data/test/integration/app/generated_models/aquatic_whale.rb +0 -42
  103. data/test/integration/app/generated_models/beautiful_fight_relationship.rb +0 -25
  104. data/test/integration/app/generated_models/citation.rb +0 -40
  105. data/test/integration/app/generated_models/citations_item.rb +0 -12
  106. data/test/integration/app/generated_models/dog.rb +0 -183
  107. data/test/integration/app/generated_models/eaters_foodstuff.rb +0 -13
  108. data/test/integration/app/generated_models/frog.rb +0 -78
  109. data/test/integration/app/generated_models/kitten.rb +0 -161
  110. data/test/integration/app/generated_models/parentship.rb +0 -14
  111. data/test/integration/app/generated_models/person.rb +0 -53
  112. data/test/integration/app/generated_models/petfood.rb +0 -125
  113. data/test/integration/app/generated_models/polymorph_test_some_model.rb +0 -25
  114. data/test/integration/app/generated_models/seller.rb +0 -30
  115. data/test/integration/app/generated_models/tabby.rb +0 -26
  116. data/test/integration/app/generated_models/user.rb +0 -34
  117. data/test/integration/app/generated_models/wild_boar.rb +0 -87
  118. data/test/integration/app/test/fixtures/addresses.yml +0 -13
  119. data/test/integration/app/test/fixtures/citations.yml +0 -9
  120. data/test/integration/app/test/fixtures/citations_items.yml +0 -9
  121. data/test/integration/app/test/fixtures/sellers.yml +0 -10
  122. data/test/integration/app/test/fixtures/states.yml +0 -216
  123. data/test/integration/app/test/fixtures/users.yml +0 -11
  124. data/test/integration/app/test/unit/citation_test.rb +0 -10
  125. data/test/integration/app/test/unit/citations_item_test.rb +0 -10
  126. data/test/test_all.rb +0 -16
@@ -0,0 +1,19 @@
1
+ require File.join(File.dirname(__FILE__), 'boot')
2
+ require 'action_controller'
3
+
4
+ Rails::Initializer.run do |config|
5
+
6
+ if ActionController::Base.respond_to? 'session='
7
+ config.action_controller.session = {:session_key => '_app_session', :secret => '22cde4d5c1a61ba69a81795322cde4d5c1a61ba69a817953'}
8
+ end
9
+
10
+ config.load_paths << "#{RAILS_ROOT}/app/models/person" # moduleless model path
11
+
12
+ config.after_initialize do
13
+ config.has_many_polymorphs_options['requirements'] << "#{RAILS_ROOT}/lib/library_model"
14
+ end
15
+ end
16
+
17
+ # Dependencies.log_activity = true
18
+
19
+ ENV['RAILS_ASSET_ID'] = Time.now.to_i.to_s
@@ -1,7 +1,8 @@
1
- config.cache_classes = false
1
+
2
+ config.cache_classes = ENV['PRODUCTION']
2
3
  config.whiny_nils = true
3
- config.action_controller.consider_all_requests_local = true
4
- config.action_controller.perform_caching = false
5
- config.action_view.cache_template_extensions = false
6
- config.action_view.debug_rjs = true
4
+ config.action_controller.consider_all_requests_local = !ENV['PRODUCTION']
5
+ config.action_controller.perform_caching = ENV['PRODUCTION']
6
+ config.action_view.cache_template_extensions = ENV['PRODUCTION']
7
+ config.action_view.debug_rjs = !ENV['PRODUCTION']
7
8
  config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,11 @@
1
+ class CreateSticks < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :sticks do |t|
4
+ t.column :name, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :sticks
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateStones < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :stones do |t|
4
+ t.column :name, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :stones
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateOrganicSubstances < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :organic_substances do |t|
4
+ t.column :type, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :organic_substances
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ class CreateBones < ActiveRecord::Migration
2
+ def self.up
3
+ # Using STI
4
+ end
5
+
6
+ def self.down
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ class CreateSingleStiParents < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :single_sti_parents do |t|
4
+ t.column :name, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :single_sti_parents
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateDoubleStiParents < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :double_sti_parents do |t|
4
+ t.column :name, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :double_sti_parents
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ class CreateSingleStiParentRelationships < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :single_sti_parent_relationships do |t|
4
+ t.column :the_bone_type, :string, :null => false
5
+ t.column :the_bone_id, :integer, :null => false
6
+ t.column :single_sti_parent_id, :integer, :null => false
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :single_sti_parent_relationships
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ class CreateDoubleStiParentRelationships < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :double_sti_parent_relationships do |t|
4
+ t.column :the_bone_type, :string, :null => false
5
+ t.column :the_bone_id, :integer, :null => false
6
+ t.column :parent_type, :string, :null => false
7
+ t.column :parent_id, :integer, :null => false
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :double_sti_parent_relationships
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ class CreateLibraryModel < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :library_models do |t|
4
+ t.column :name, :string
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :library_models
10
+ end
11
+ end
@@ -4,141 +4,41 @@
4
4
 
5
5
  ActiveRecord::Schema.define(:version => 9) do
6
6
 
7
- create_table "addresses", :force => true do |t|
8
- t.integer "user_id", :null => false
9
- t.string "name"
10
- t.string "line_1", :default => "", :null => false
11
- t.string "line_2"
12
- t.string "city", :default => "", :null => false
13
- t.integer "state_id", :null => false
14
- t.string "province_region"
15
- t.string "zip_postal_code"
16
- t.integer "country_id", :null => false
17
- t.float "lat"
18
- t.float "long"
7
+ create_table "double_sti_parent_relationships", :force => true do |t|
8
+ t.column "the_bone_type", :string, :default => "", :null => false
9
+ t.column "the_bone_id", :integer, :null => false
10
+ t.column "parent_type", :string, :default => "", :null => false
11
+ t.column "parent_id", :integer, :null => false
19
12
  end
20
13
 
21
- create_table "bow_wows", :force => true do |t|
22
- t.string "name"
23
- t.datetime "created_at", :null => false
24
- t.datetime "updated_at", :null => false
14
+ create_table "double_sti_parents", :force => true do |t|
15
+ t.column "name", :string
25
16
  end
26
17
 
27
- create_table "cats", :force => true do |t|
28
- t.string "name"
29
- t.string "cat_type"
30
- t.datetime "created_at", :null => false
31
- t.datetime "updated_at", :null => false
18
+ create_table "library_models", :force => true do |t|
19
+ t.column "name", :string
32
20
  end
33
21
 
34
- create_table "citations", :force => true do |t|
35
- t.string "name"
36
- t.datetime "created_at"
37
- t.datetime "updated_at"
22
+ create_table "organic_substances", :force => true do |t|
23
+ t.column "type", :string
38
24
  end
39
25
 
40
- create_table "citations_items", :force => true do |t|
41
- t.integer "citation_id", :null => false
42
- t.integer "item_id", :null => false
43
- t.string "item_type", :default => "", :null => false
44
- t.datetime "created_at"
45
- t.datetime "updated_at"
26
+ create_table "single_sti_parent_relationships", :force => true do |t|
27
+ t.column "the_bone_type", :string, :default => "", :null => false
28
+ t.column "the_bone_id", :integer, :null => false
29
+ t.column "single_sti_parent_id", :integer, :null => false
46
30
  end
47
31
 
48
- create_table "eaters_foodstuffs", :force => true do |t|
49
- t.integer "foodstuff_id"
50
- t.integer "eater_id"
51
- t.integer "some_attribute", :default => 0
52
- t.string "eater_type"
53
- t.datetime "created_at", :null => false
54
- t.datetime "updated_at", :null => false
32
+ create_table "single_sti_parents", :force => true do |t|
33
+ t.column "name", :string
55
34
  end
56
35
 
57
- create_table "fish", :force => true do |t|
58
- t.string "name"
59
- t.integer "speed"
60
- t.datetime "created_at", :null => false
61
- t.datetime "updated_at", :null => false
36
+ create_table "sticks", :force => true do |t|
37
+ t.column "name", :string
62
38
  end
63
39
 
64
- create_table "frogs", :force => true do |t|
65
- t.string "name"
66
- t.datetime "created_at", :null => false
67
- t.datetime "updated_at", :null => false
68
- end
69
-
70
- create_table "keep_your_enemies_close", :force => true do |t|
71
- t.integer "enemy_id"
72
- t.string "enemy_type"
73
- t.integer "protector_id"
74
- t.string "protector_type"
75
- t.datetime "created_at", :null => false
76
- t.datetime "updated_at", :null => false
77
- end
78
-
79
- create_table "little_whale_pupils", :force => true do |t|
80
- t.integer "whale_id"
81
- t.integer "aquatic_pupil_id"
82
- t.string "aquatic_pupil_type"
83
- t.datetime "created_at", :null => false
84
- t.datetime "updated_at", :null => false
85
- end
86
-
87
- create_table "parentships", :force => true do |t|
88
- t.integer "parent_id"
89
- t.string "child_type"
90
- t.integer "kid_id"
91
- t.datetime "created_at", :null => false
92
- t.datetime "updated_at", :null => false
93
- end
94
-
95
- create_table "people", :force => true do |t|
96
- t.string "name"
97
- t.integer "age"
98
- t.datetime "created_at", :null => false
99
- t.datetime "updated_at", :null => false
100
- end
101
-
102
- create_table "petfoods", :id => false, :force => true do |t|
103
- t.integer "the_petfood_primary_key", :null => false
104
- t.string "name"
105
- t.datetime "created_at", :null => false
106
- t.datetime "updated_at", :null => false
107
- end
108
-
109
- create_table "sellers", :force => true do |t|
110
- t.integer "user_id", :null => false
111
- t.string "company_name"
112
- t.datetime "created_at"
113
- t.datetime "updated_at"
114
- t.float "capitalization", :default => 0.0
115
- end
116
-
117
- create_table "states", :force => true do |t|
118
- t.string "name", :default => "", :null => false
119
- t.string "abbreviation", :default => "", :null => false
120
- end
121
-
122
- create_table "users", :force => true do |t|
123
- t.string "login", :limit => 64, :default => "", :null => false
124
- t.string "email", :default => "", :null => false
125
- t.string "crypted_password", :limit => 64, :default => "", :null => false
126
- t.string "salt", :limit => 64, :default => "", :null => false
127
- t.datetime "created_at"
128
- t.datetime "updated_at"
129
- t.boolean "deleted", :default => false
130
- end
131
-
132
- create_table "whales", :force => true do |t|
133
- t.string "name"
134
- t.datetime "created_at", :null => false
135
- t.datetime "updated_at", :null => false
136
- end
137
-
138
- create_table "wild_boars", :force => true do |t|
139
- t.string "name"
140
- t.datetime "created_at", :null => false
141
- t.datetime "updated_at", :null => false
40
+ create_table "stones", :force => true do |t|
41
+ t.column "name", :string
142
42
  end
143
43
 
144
44
  end
@@ -0,0 +1,2 @@
1
+ class LibraryModel < ActiveRecord::Base
2
+ end
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ # one:
4
+ # column: value
5
+ #
6
+ # two:
7
+ # column: value
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ # one:
4
+ # column: value
5
+ #
6
+ # two:
7
+ # column: value
@@ -0,0 +1,5 @@
1
+ one:
2
+ type: Bone
3
+
4
+ two:
5
+ type: Bone
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ # one:
4
+ # column: value
5
+ #
6
+ # two:
7
+ # column: value
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ # one:
4
+ # column: value
5
+ #
6
+ # two:
7
+ # column: value
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ name: MyString
5
+
6
+ two:
7
+ name: MyString
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ name: MyString
5
+
6
+ two:
7
+ name: MyString
@@ -1,8 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class UserTest < Test::Unit::TestCase
4
- fixtures :users
5
-
3
+ class BonesControllerTest < ActionController::TestCase
6
4
  # Replace this with your real tests.
7
5
  def test_truth
8
6
  assert true
@@ -1,28 +1,8 @@
1
- ENV["RAILS_ENV"] = "test"
1
+ ENV["RAILS_ENV"] = "development"
2
2
  require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3
3
  require 'test_help'
4
4
 
5
5
  class Test::Unit::TestCase
6
- # Transactional fixtures accelerate your tests by wrapping each test method
7
- # in a transaction that's rolled back on completion. This ensures that the
8
- # test database remains unchanged so your fixtures don't have to be reloaded
9
- # between every test method. Fewer database queries means faster tests.
10
- #
11
- # Read Mike Clark's excellent walkthrough at
12
- # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
13
- #
14
- # Every Active Record database supports transactions except MyISAM tables
15
- # in MySQL. Turn off transactional fixtures in this case; however, if you
16
- # don't care one way or the other, switching from MyISAM to InnoDB tables
17
- # is recommended.
18
6
  self.use_transactional_fixtures = true
19
-
20
- # Instantiated fixtures are slow, but give you @david where otherwise you
21
- # would need people(:david). If you don't want to migrate your existing
22
- # test cases which use the @david style and don't mind the speed hit (each
23
- # instantiated fixtures translates to a database query per test method),
24
- # then set this back to true.
25
7
  self.use_instantiated_fixtures = false
26
-
27
- # Add more helper methods to be used by all tests here...
28
8
  end
@@ -1,8 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class StatesTest < Test::Unit::TestCase
4
- fixtures :states
5
-
3
+ class BoneTest < Test::Unit::TestCase
6
4
  # Replace this with your real tests.
7
5
  def test_truth
8
6
  assert true
@@ -1,8 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class SellerTest < Test::Unit::TestCase
4
- fixtures :sellers
5
-
3
+ class DoubleStiParentRelationshipTest < Test::Unit::TestCase
6
4
  # Replace this with your real tests.
7
5
  def test_truth
8
6
  assert true
@@ -1,8 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class AddressTest < Test::Unit::TestCase
4
- fixtures :addresses
5
-
3
+ class DoubleStiParentTest < Test::Unit::TestCase
6
4
  # Replace this with your real tests.
7
5
  def test_truth
8
6
  assert true