has_many_polymorphs 2.10 → 2.11

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 (156) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +2 -0
  3. data/Manifest +191 -56
  4. data/TODO +1 -0
  5. data/examples/hmph.rb +69 -0
  6. data/generators/commenting/commenting_generator.rb +94 -0
  7. data/generators/commenting/templates/comment.rb +33 -0
  8. data/generators/commenting/templates/comment_test.rb +12 -0
  9. data/generators/commenting/templates/commenting.rb +13 -0
  10. data/generators/commenting/templates/commenting_extensions.rb +30 -0
  11. data/generators/commenting/templates/commenting_test.rb +30 -0
  12. data/generators/commenting/templates/commentings.yml +23 -0
  13. data/generators/commenting/templates/comments.yml +13 -0
  14. data/generators/commenting/templates/migration.rb +28 -0
  15. data/generators/tagging/templates/tagging_extensions.rb +4 -8
  16. data/has_many_polymorphs.gemspec +19 -12
  17. data/lib/has_many_polymorphs.rb +3 -4
  18. data/lib/has_many_polymorphs/autoload.rb +4 -4
  19. data/lib/has_many_polymorphs/class_methods.rb +8 -8
  20. data/lib/has_many_polymorphs/debugging_tools.rb +2 -0
  21. data/lib/has_many_polymorphs/dependencies.rb +9 -4
  22. data/lib/has_many_polymorphs/support_methods.rb +3 -1
  23. data/test/fixtures/{aquatic/fish.yml → fish.yml} +0 -0
  24. data/test/fixtures/{aquatic/little_whale_pupils.yml → little_whale_pupils.yml} +0 -0
  25. data/test/fixtures/{aquatic/whales.yml → whales.yml} +0 -0
  26. data/test/integration/app/README +182 -0
  27. data/test/integration/app/Rakefile +19 -0
  28. data/test/integration/app/app/controllers/addresses_controller.rb +85 -0
  29. data/test/integration/app/app/controllers/application.rb +7 -0
  30. data/test/integration/app/app/controllers/sellers_controller.rb +85 -0
  31. data/test/integration/app/app/controllers/states_controller.rb +85 -0
  32. data/test/integration/app/app/controllers/users_controller.rb +85 -0
  33. data/test/integration/app/app/helpers/addresses_helper.rb +2 -0
  34. data/test/integration/app/app/helpers/application_helper.rb +3 -0
  35. data/test/integration/app/app/helpers/sellers_helper.rb +28 -0
  36. data/test/integration/app/app/helpers/states_helper.rb +2 -0
  37. data/test/integration/app/app/helpers/users_helper.rb +2 -0
  38. data/test/integration/app/app/models/address.rb +4 -0
  39. data/test/integration/app/app/models/citation.rb +3 -0
  40. data/test/integration/app/app/models/citations_item.rb +4 -0
  41. data/test/integration/app/app/models/seller.rb +4 -0
  42. data/test/integration/app/app/models/state.rb +3 -0
  43. data/test/integration/app/app/models/user.rb +4 -0
  44. data/test/integration/app/app/views/addresses/edit.html.erb +12 -0
  45. data/test/integration/app/app/views/addresses/index.html.erb +18 -0
  46. data/test/integration/app/app/views/addresses/new.html.erb +11 -0
  47. data/test/integration/app/app/views/addresses/show.html.erb +3 -0
  48. data/test/integration/app/app/views/layouts/addresses.html.erb +17 -0
  49. data/test/integration/app/app/views/layouts/sellers.html.erb +17 -0
  50. data/test/integration/app/app/views/layouts/states.html.erb +17 -0
  51. data/test/integration/app/app/views/layouts/users.html.erb +17 -0
  52. data/test/integration/app/app/views/sellers/edit.html.erb +12 -0
  53. data/test/integration/app/app/views/sellers/index.html.erb +20 -0
  54. data/test/integration/app/app/views/sellers/new.html.erb +11 -0
  55. data/test/integration/app/app/views/sellers/show.html.erb +3 -0
  56. data/test/integration/app/app/views/states/edit.html.erb +12 -0
  57. data/test/integration/app/app/views/states/index.html.erb +19 -0
  58. data/test/integration/app/app/views/states/new.html.erb +11 -0
  59. data/test/integration/app/app/views/states/show.html.erb +3 -0
  60. data/test/integration/app/app/views/users/edit.html.erb +12 -0
  61. data/test/integration/app/app/views/users/index.html.erb +22 -0
  62. data/test/integration/app/app/views/users/new.html.erb +11 -0
  63. data/test/integration/app/app/views/users/show.html.erb +3 -0
  64. data/test/integration/app/config/boot.rb +45 -0
  65. data/test/integration/app/config/database.yml +21 -0
  66. data/test/integration/app/config/environment.rb +13 -0
  67. data/test/integration/app/config/environments/development.rb +7 -0
  68. data/test/integration/app/config/environments/production.rb +18 -0
  69. data/test/integration/app/config/environments/test.rb +19 -0
  70. data/test/integration/app/config/locomotive.yml +6 -0
  71. data/test/integration/app/config/routes.rb +33 -0
  72. data/test/integration/app/config/ultrasphinx/default.base +56 -0
  73. data/test/integration/app/config/ultrasphinx/development.conf.canonical +155 -0
  74. data/test/integration/app/db/migrate/001_create_users.rb +16 -0
  75. data/test/integration/app/db/migrate/002_create_sellers.rb +14 -0
  76. data/test/integration/app/db/migrate/003_create_addresses.rb +19 -0
  77. data/test/integration/app/db/migrate/004_create_states.rb +12 -0
  78. data/test/integration/app/db/migrate/005_add_capitalization_to_seller.rb +9 -0
  79. data/test/integration/app/db/migrate/006_add_deleted_to_user.rb +9 -0
  80. data/test/integration/app/db/migrate/007_add_lat_and_long_to_address.rb +11 -0
  81. data/test/integration/app/db/migrate/008_create_citations.rb +12 -0
  82. data/test/integration/app/db/migrate/009_create_citations_items.rb +14 -0
  83. data/test/integration/app/db/schema.rb +144 -0
  84. data/test/integration/app/doc/README_FOR_APP +2 -0
  85. data/test/integration/app/generated_models/aquatic_fish.rb +109 -0
  86. data/test/integration/app/generated_models/aquatic_pupils_whale.rb +13 -0
  87. data/test/integration/app/generated_models/aquatic_whale.rb +42 -0
  88. data/test/integration/app/generated_models/beautiful_fight_relationship.rb +25 -0
  89. data/test/integration/app/generated_models/citation.rb +40 -0
  90. data/test/integration/app/generated_models/citations_item.rb +12 -0
  91. data/test/integration/app/generated_models/dog.rb +183 -0
  92. data/test/integration/app/generated_models/eaters_foodstuff.rb +13 -0
  93. data/test/integration/app/generated_models/frog.rb +78 -0
  94. data/test/integration/app/generated_models/kitten.rb +161 -0
  95. data/test/integration/app/generated_models/parentship.rb +14 -0
  96. data/test/integration/app/generated_models/person.rb +53 -0
  97. data/test/integration/app/generated_models/petfood.rb +125 -0
  98. data/test/integration/app/generated_models/polymorph_test_some_model.rb +25 -0
  99. data/test/integration/app/generated_models/seller.rb +30 -0
  100. data/test/integration/app/generated_models/tabby.rb +26 -0
  101. data/test/integration/app/generated_models/user.rb +34 -0
  102. data/test/integration/app/generated_models/wild_boar.rb +87 -0
  103. data/test/integration/app/generators/commenting_generator_test.rb +83 -0
  104. data/test/integration/app/public/404.html +30 -0
  105. data/test/integration/app/public/500.html +30 -0
  106. data/test/integration/app/public/dispatch.cgi +10 -0
  107. data/test/integration/app/public/dispatch.fcgi +24 -0
  108. data/test/integration/app/public/dispatch.rb +10 -0
  109. data/test/integration/app/public/favicon.ico +0 -0
  110. data/test/integration/app/public/images/rails.png +0 -0
  111. data/test/integration/app/public/index.html +277 -0
  112. data/test/integration/app/public/javascripts/application.js +2 -0
  113. data/test/integration/app/public/javascripts/controls.js +833 -0
  114. data/test/integration/app/public/javascripts/dragdrop.js +942 -0
  115. data/test/integration/app/public/javascripts/effects.js +1088 -0
  116. data/test/integration/app/public/javascripts/prototype.js +2515 -0
  117. data/test/integration/app/public/robots.txt +1 -0
  118. data/test/integration/app/public/stylesheets/scaffold.css +74 -0
  119. data/test/integration/app/script/about +3 -0
  120. data/test/integration/app/script/breakpointer +3 -0
  121. data/test/integration/app/script/console +3 -0
  122. data/test/integration/app/script/destroy +3 -0
  123. data/test/integration/app/script/generate +3 -0
  124. data/test/integration/app/script/performance/benchmarker +3 -0
  125. data/test/integration/app/script/performance/profiler +3 -0
  126. data/test/integration/app/script/plugin +3 -0
  127. data/test/integration/app/script/process/inspector +3 -0
  128. data/test/integration/app/script/process/reaper +3 -0
  129. data/test/integration/app/script/process/spawner +3 -0
  130. data/test/integration/app/script/runner +3 -0
  131. data/test/integration/app/script/server +3 -0
  132. data/test/integration/app/test/fixtures/addresses.yml +13 -0
  133. data/test/integration/app/test/fixtures/citations.yml +9 -0
  134. data/test/integration/app/test/fixtures/citations_items.yml +9 -0
  135. data/test/integration/app/test/fixtures/sellers.yml +10 -0
  136. data/test/integration/app/test/fixtures/states.yml +216 -0
  137. data/test/integration/app/test/fixtures/users.yml +11 -0
  138. data/test/integration/app/test/functional/addresses_controller_test.rb +57 -0
  139. data/test/integration/app/test/functional/sellers_controller_test.rb +57 -0
  140. data/test/integration/app/test/functional/states_controller_test.rb +57 -0
  141. data/test/integration/app/test/functional/users_controller_test.rb +57 -0
  142. data/test/integration/app/test/test_helper.rb +28 -0
  143. data/test/integration/app/test/unit/address_test.rb +10 -0
  144. data/test/integration/app/test/unit/citation_test.rb +10 -0
  145. data/test/integration/app/test/unit/citations_item_test.rb +10 -0
  146. data/test/integration/app/test/unit/seller_test.rb +10 -0
  147. data/test/integration/app/test/unit/state_test.rb +10 -0
  148. data/test/integration/app/test/unit/user_test.rb +10 -0
  149. data/test/models/aquatic/fish.rb +2 -1
  150. data/test/models/aquatic/whale.rb +2 -0
  151. data/test/setup.rb +10 -0
  152. data/test/test_all.rb +16 -0
  153. data/test/test_helper.rb +16 -12
  154. data/test/unit/polymorph_test.rb +35 -34
  155. metadata +239 -98
  156. metadata.gz.sig +0 -0
@@ -0,0 +1,57 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require 'sellers_controller'
3
+
4
+ # Re-raise errors caught by the controller.
5
+ class SellersController; def rescue_action(e) raise e end; end
6
+
7
+ class SellersControllerTest < Test::Unit::TestCase
8
+ fixtures :sellers
9
+
10
+ def setup
11
+ @controller = SellersController.new
12
+ @request = ActionController::TestRequest.new
13
+ @response = ActionController::TestResponse.new
14
+ end
15
+
16
+ def test_should_get_index
17
+ get :index
18
+ assert_response :success
19
+ assert assigns(:sellers)
20
+ end
21
+
22
+ def test_should_get_new
23
+ get :new
24
+ assert_response :success
25
+ end
26
+
27
+ def test_should_create_seller
28
+ assert_difference('Seller.count') do
29
+ post :create, :seller => { }
30
+ end
31
+
32
+ assert_redirected_to seller_path(assigns(:seller))
33
+ end
34
+
35
+ def test_should_show_seller
36
+ get :show, :id => 1
37
+ assert_response :success
38
+ end
39
+
40
+ def test_should_get_edit
41
+ get :edit, :id => 1
42
+ assert_response :success
43
+ end
44
+
45
+ def test_should_update_seller
46
+ put :update, :id => 1, :seller => { }
47
+ assert_redirected_to seller_path(assigns(:seller))
48
+ end
49
+
50
+ def test_should_destroy_seller
51
+ assert_difference('Seller.count', -1) do
52
+ delete :destroy, :id => 1
53
+ end
54
+
55
+ assert_redirected_to sellers_path
56
+ end
57
+ end
@@ -0,0 +1,57 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require 'states_controller'
3
+
4
+ # Re-raise errors caught by the controller.
5
+ class StatesController; def rescue_action(e) raise e end; end
6
+
7
+ class StatesControllerTest < Test::Unit::TestCase
8
+ fixtures :states
9
+
10
+ def setup
11
+ @controller = StatesController.new
12
+ @request = ActionController::TestRequest.new
13
+ @response = ActionController::TestResponse.new
14
+ end
15
+
16
+ def test_should_get_index
17
+ get :index
18
+ assert_response :success
19
+ assert assigns(:states)
20
+ end
21
+
22
+ def test_should_get_new
23
+ get :new
24
+ assert_response :success
25
+ end
26
+
27
+ def test_should_create_state
28
+ assert_difference('State.count') do
29
+ post :create, :state => { }
30
+ end
31
+
32
+ assert_redirected_to state_path(assigns(:state))
33
+ end
34
+
35
+ def test_should_show_state
36
+ get :show, :id => 1
37
+ assert_response :success
38
+ end
39
+
40
+ def test_should_get_edit
41
+ get :edit, :id => 1
42
+ assert_response :success
43
+ end
44
+
45
+ def test_should_update_state
46
+ put :update, :id => 1, :state => { }
47
+ assert_redirected_to state_path(assigns(:state))
48
+ end
49
+
50
+ def test_should_destroy_state
51
+ assert_difference('State.count', -1) do
52
+ delete :destroy, :id => 1
53
+ end
54
+
55
+ assert_redirected_to states_path
56
+ end
57
+ end
@@ -0,0 +1,57 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require 'users_controller'
3
+
4
+ # Re-raise errors caught by the controller.
5
+ class UsersController; def rescue_action(e) raise e end; end
6
+
7
+ class UsersControllerTest < Test::Unit::TestCase
8
+ fixtures :users
9
+
10
+ def setup
11
+ @controller = UsersController.new
12
+ @request = ActionController::TestRequest.new
13
+ @response = ActionController::TestResponse.new
14
+ end
15
+
16
+ def test_should_get_index
17
+ get :index
18
+ assert_response :success
19
+ assert assigns(:users)
20
+ end
21
+
22
+ def test_should_get_new
23
+ get :new
24
+ assert_response :success
25
+ end
26
+
27
+ def test_should_create_user
28
+ assert_difference('User.count') do
29
+ post :create, :user => { }
30
+ end
31
+
32
+ assert_redirected_to user_path(assigns(:user))
33
+ end
34
+
35
+ def test_should_show_user
36
+ get :show, :id => 1
37
+ assert_response :success
38
+ end
39
+
40
+ def test_should_get_edit
41
+ get :edit, :id => 1
42
+ assert_response :success
43
+ end
44
+
45
+ def test_should_update_user
46
+ put :update, :id => 1, :user => { }
47
+ assert_redirected_to user_path(assigns(:user))
48
+ end
49
+
50
+ def test_should_destroy_user
51
+ assert_difference('User.count', -1) do
52
+ delete :destroy, :id => 1
53
+ end
54
+
55
+ assert_redirected_to users_path
56
+ end
57
+ end
@@ -0,0 +1,28 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3
+ require 'test_help'
4
+
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
+ 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
+ self.use_instantiated_fixtures = false
26
+
27
+ # Add more helper methods to be used by all tests here...
28
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class AddressTest < Test::Unit::TestCase
4
+ fixtures :addresses
5
+
6
+ # Replace this with your real tests.
7
+ def test_truth
8
+ assert true
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class CitationTest < Test::Unit::TestCase
4
+ fixtures :citations
5
+
6
+ # Replace this with your real tests.
7
+ def test_truth
8
+ assert true
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class CitationsItemTest < Test::Unit::TestCase
4
+ fixtures :citations_items
5
+
6
+ # Replace this with your real tests.
7
+ def test_truth
8
+ assert true
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class SellerTest < Test::Unit::TestCase
4
+ fixtures :sellers
5
+
6
+ # Replace this with your real tests.
7
+ def test_truth
8
+ assert true
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class StatesTest < Test::Unit::TestCase
4
+ fixtures :states
5
+
6
+ # Replace this with your real tests.
7
+ def test_truth
8
+ assert true
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class UserTest < Test::Unit::TestCase
4
+ fixtures :users
5
+
6
+ # Replace this with your real tests.
7
+ def test_truth
8
+ assert true
9
+ end
10
+ end
@@ -1,4 +1,5 @@
1
1
  class Aquatic::Fish < ActiveRecord::Base
2
- # attr_accessor :after_find_test, :after_initialize_test
2
+ # set_table_name "fish"
3
+ # attr_accessor :after_find_test, :after_initialize_test
3
4
  end
4
5
 
@@ -4,6 +4,8 @@ require 'aquatic/fish'
4
4
  require 'aquatic/pupils_whale'
5
5
 
6
6
  class Aquatic::Whale < ActiveRecord::Base
7
+ # set_table_name "whales"
8
+
7
9
  has_many_polymorphs(:aquatic_pupils, :from => [:dogs, :"aquatic/fish"],
8
10
  :through => "aquatic/pupils_whales") do
9
11
  def a_method
@@ -0,0 +1,10 @@
1
+
2
+ # Setup integration system for the integration suite
3
+
4
+ Dir.chdir "#{File.dirname(__FILE__)}/integration/app/" do
5
+ Dir.chdir "vendor/plugins" do
6
+ system("rm has_many_polymorphs; ln -s ../../../../../ has_many_polymorphs")
7
+ end
8
+ system("rake db:create")
9
+ system("rake db:migrate db:fixtures:load")
10
+ end
@@ -0,0 +1,16 @@
1
+
2
+ # Run tests against all Rails versions
3
+
4
+ VENDOR_DIR = File.expand_path("~/Desktop/projects/vendor/rails")
5
+
6
+ HERE = File.expand_path(File.dirname(__FILE__))
7
+
8
+ Dir["#{VENDOR_DIR}/*"].each do |dir|
9
+ puts "\n\n**** #{dir} ****\n\n"
10
+ Dir.chdir "#{HERE}/integration/app/vendor" do
11
+ system("rm rails; ln -s #{dir} rails")
12
+ end
13
+ system("ruby #{HERE}/unit/polymorph_test.rb")
14
+ end
15
+
16
+ system("rm #{HERE}/integration/app/vendor; svn up #{HERE}/integration/app/vendor")
@@ -6,20 +6,23 @@ begin
6
6
  rescue Object
7
7
  end
8
8
 
9
- # load the applicaiton's test helper
10
- begin
11
- require File.dirname(__FILE__) + '/../../../../test/test_helper'
12
- rescue LoadError
13
- require '~/projects/miscellaneous/cookbook/test/test_helper'
14
- end
9
+ HERE = File.expand_path(File.dirname(__FILE__))
10
+ $LOAD_PATH << HERE
11
+
12
+ # require 'integration/app/config/environment'
13
+ require 'integration/app/test/test_helper'
15
14
 
16
- WORKING_DIR = File.dirname(__FILE__)
15
+ def silently
16
+ stderr, $stderr = $stderr, StringIO.new
17
+ yield
18
+ $stderr = stderr
19
+ end
17
20
 
18
21
  Inflector.inflections {|i| i.irregular 'fish', 'fish' }
19
22
 
20
- $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path = WORKING_DIR + "/fixtures")
21
- $LOAD_PATH.unshift(WORKING_DIR + "/models")
22
- $LOAD_PATH.unshift(WORKING_DIR + "/modules")
23
+ $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path = HERE + "/fixtures")
24
+ $LOAD_PATH.unshift(HERE + "/models")
25
+ $LOAD_PATH.unshift(HERE + "/modules")
23
26
 
24
27
  class Test::Unit::TestCase
25
28
  self.use_transactional_fixtures = !(ActiveRecord::Base.connection.is_a? ActiveRecord::ConnectionAdapters::MysqlAdapter rescue false)
@@ -27,5 +30,6 @@ class Test::Unit::TestCase
27
30
  end
28
31
 
29
32
  # test schema
30
- load(File.dirname(__FILE__) + "/schema.rb")
31
-
33
+ silently do
34
+ load(HERE + "/schema.rb")
35
+ end
@@ -1,11 +1,25 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
+ require 'dog'
4
+ require 'wild_boar'
5
+ require 'frog'
6
+ require 'cat'
7
+ require 'kitten'
8
+ require 'aquatic/whale'
9
+ require 'aquatic/fish'
10
+ require 'aquatic/pupils_whale'
11
+ require 'beautiful_fight_relationship'
12
+
3
13
  class PolymorphTest < Test::Unit::TestCase
4
14
 
15
+ set_fixture_class :bow_wows => Dog
16
+ set_fixture_class :keep_your_enemies_close => BeautifulFightRelationship
17
+ set_fixture_class :whales => Aquatic::Whale
18
+ set_fixture_class :fish => Aquatic::Fish
19
+ set_fixture_class :little_whale_pupils => Aquatic::PupilsWhale
20
+
5
21
  fixtures :cats, :bow_wows, :frogs, :wild_boars, :eaters_foodstuffs, :petfoods,
6
- :"aquatic/fish", :"aquatic/whales", :"aquatic/little_whale_pupils",
7
- :keep_your_enemies_close, :people
8
- require 'beautiful_fight_relationship'
22
+ :fish, :whales, :little_whale_pupils, :keep_your_enemies_close, :people
9
23
 
10
24
  def setup
11
25
  @association_error = ActiveRecord::Associations::PolymorphicError
@@ -22,18 +36,12 @@ class PolymorphTest < Test::Unit::TestCase
22
36
  @froggy = Frog.find(1)
23
37
 
24
38
  @join_count = EatersFoodstuff.count
25
- @l = @kibbles.eaters.size
26
- @m = @bits.eaters.size
39
+ @kibbles_eaters_count = @kibbles.eaters.size
40
+ @bits_eaters_count = @bits.eaters.size
27
41
 
28
42
  @double_join_count = BeautifulFightRelationship.count
29
- @n = @alice.enemies.size
30
- end
31
-
32
- def d
33
- require 'ruby-debug'
34
- Debugger.start
35
- debugger
36
- end
43
+ @alice_enemies_count = @alice.enemies.size
44
+ end
37
45
 
38
46
  def test_all_relationship_validities
39
47
  # q = []
@@ -49,27 +57,20 @@ class PolymorphTest < Test::Unit::TestCase
49
57
  WildBoar.reflect_on_all_associations.map &:check_validity!
50
58
  Frog.reflect_on_all_associations.map &:check_validity!
51
59
  Cat.reflect_on_all_associations.map &:check_validity!
52
- Right.reflect_on_all_associations.map &:check_validity!
53
- Left.reflect_on_all_associations.map &:check_validity!
54
- DoubleJoin.reflect_on_all_associations.map &:check_validity!
55
60
  BeautifulFightRelationship.reflect_on_all_associations.map &:check_validity!
56
61
  Person.reflect_on_all_associations.map &:check_validity!
57
62
  Parentship.reflect_on_all_associations.map &:check_validity!
58
63
  Aquatic::Whale.reflect_on_all_associations.map &:check_validity!
59
64
  Aquatic::PupilsWhale.reflect_on_all_associations.map &:check_validity!
60
- Tagging.reflect_on_all_associations.map &:check_validity!
61
- Recipe.reflect_on_all_associations.map &:check_validity!
62
- Category.reflect_on_all_associations.map &:check_validity!
63
- Tag.reflect_on_all_associations.map &:check_validity!
64
65
  end
65
66
 
66
67
  def test_assignment
67
68
  assert @kibbles.eaters.blank?
68
69
  assert @kibbles.eaters.push(Cat.find_by_name('Chloe'))
69
- assert_equal @l += 1, @kibbles.eaters.count
70
+ assert_equal @kibbles_eaters_count += 1, @kibbles.eaters.count
70
71
 
71
72
  @kibbles.reload
72
- assert_equal @l, @kibbles.eaters.count
73
+ assert_equal @kibbles_eaters_count, @kibbles.eaters.count
73
74
  end
74
75
 
75
76
  def test_duplicate_assignment
@@ -77,19 +78,19 @@ class PolymorphTest < Test::Unit::TestCase
77
78
  @kibbles.eaters.push(@alice)
78
79
  assert @kibbles.eaters.include?(@alice)
79
80
  @kibbles.eaters.push(@alice)
80
- assert_equal @l + 2, @kibbles.eaters.count
81
+ assert_equal @kibbles_eaters_count + 2, @kibbles.eaters.count
81
82
  assert_equal @join_count + 2, EatersFoodstuff.count
82
83
  end
83
84
 
84
85
  def test_create_and_push
85
86
  assert @kibbles.eaters.push(@spot)
86
- assert_equal @l += 1, @kibbles.eaters.count
87
+ assert_equal @kibbles_eaters_count += 1, @kibbles.eaters.count
87
88
  assert @kibbles.eaters << @rover
88
89
  assert @kibbles.eaters << Kitten.create(:name => "Miranda")
89
- assert_equal @l += 2, @kibbles.eaters.length
90
+ assert_equal @kibbles_eaters_count += 2, @kibbles.eaters.length
90
91
 
91
92
  @kibbles.reload
92
- assert_equal @l, @kibbles.eaters.length
93
+ assert_equal @kibbles_eaters_count, @kibbles.eaters.length
93
94
 
94
95
  # test that ids and new flags were set appropriately
95
96
  assert_not_nil @kibbles.eaters[0].id
@@ -108,8 +109,8 @@ class PolymorphTest < Test::Unit::TestCase
108
109
  assert join.id
109
110
  assert_equal @join_count + 1, EatersFoodstuff.count
110
111
 
111
- #assert_equal @m, @bits.eaters.size # Doesn't behave this way on latest edge anymore
112
- assert_equal @m + 1, @bits.eaters.count # SQL
112
+ #assert_equal @bits_eaters_count, @bits.eaters.size # Doesn't behave this way on latest edge anymore
113
+ assert_equal @bits_eaters_count + 1, @bits.eaters.count # SQL
113
114
 
114
115
  # reload; is the new association there?
115
116
  assert @bits.eaters.reload
@@ -133,17 +134,17 @@ class PolymorphTest < Test::Unit::TestCase
133
134
  # # add an unsaved item
134
135
  # assert @bits.eaters << Kitten.new(:name => "Bridget")
135
136
  # assert_nil Kitten.find_by_name("Bridget")
136
- # assert_equal @m + 1, @bits.eaters.count
137
+ # assert_equal @bits_eaters_count + 1, @bits.eaters.count
137
138
  #
138
139
  # assert @bits.save
139
140
  # @bits.reload
140
- # assert_equal @m + 1, @bits.eaters.count
141
+ # assert_equal @bits_eaters_count + 1, @bits.eaters.count
141
142
  #
142
143
  # end
143
144
 
144
145
  def test_self_reference
145
146
  assert @kibbles.eaters << @bits
146
- assert_equal @l += 1, @kibbles.eaters.count
147
+ assert_equal @kibbles_eaters_count += 1, @kibbles.eaters.count
147
148
  assert @kibbles.eaters.include?(@bits)
148
149
  @kibbles.reload
149
150
  assert @kibbles.foodstuffs_of_eaters.blank?
@@ -157,7 +158,7 @@ class PolymorphTest < Test::Unit::TestCase
157
158
  assert @kibbles.eaters << @chloe
158
159
  @kibbles.reload
159
160
  assert @kibbles.eaters.delete(@kibbles.eaters[0])
160
- assert_equal @l, @kibbles.eaters.count
161
+ assert_equal @kibbles_eaters_count, @kibbles.eaters.count
161
162
  end
162
163
 
163
164
  def test_destroy
@@ -166,7 +167,7 @@ class PolymorphTest < Test::Unit::TestCase
166
167
  assert @kibbles.eaters.length > 0
167
168
  assert @kibbles.eaters[0].destroy
168
169
  @kibbles.reload
169
- assert_equal @l, @kibbles.eaters.count
170
+ assert_equal @kibbles_eaters_count, @kibbles.eaters.count
170
171
  end
171
172
 
172
173
  def test_clear
@@ -233,7 +234,7 @@ class PolymorphTest < Test::Unit::TestCase
233
234
 
234
235
  def test_self_referential_join_tables
235
236
  # check that the self-reference join tables go the right ways
236
- assert_equal @l, @kibbles.eaters_foodstuffs.count
237
+ assert_equal @kibbles_eaters_count, @kibbles.eaters_foodstuffs.count
237
238
  assert_equal @kibbles.eaters_foodstuffs.count, @kibbles.eaters_foodstuffs_as_child.count
238
239
  end
239
240