has_many_polymorphs 2.2
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.
- data/CHANGELOG +86 -0
- data/LICENSE +184 -0
- data/Manifest +173 -0
- data/README +205 -0
- data/Rakefile +28 -0
- data/TODO +2 -0
- data/examples/hmph.rb +69 -0
- data/generators/tagging/tagging_generator.rb +97 -0
- data/generators/tagging/templates/migration.rb +28 -0
- data/generators/tagging/templates/tag.rb +39 -0
- data/generators/tagging/templates/tag_test.rb +15 -0
- data/generators/tagging/templates/tagging.rb +16 -0
- data/generators/tagging/templates/tagging_extensions.rb +203 -0
- data/generators/tagging/templates/tagging_test.rb +85 -0
- data/generators/tagging/templates/taggings.yml +23 -0
- data/generators/tagging/templates/tags.yml +7 -0
- data/has_many_polymorphs.gemspec +36 -0
- data/init.rb +2 -0
- data/lib/has_many_polymorphs/association.rb +160 -0
- data/lib/has_many_polymorphs/autoload.rb +69 -0
- data/lib/has_many_polymorphs/base.rb +60 -0
- data/lib/has_many_polymorphs/class_methods.rb +600 -0
- data/lib/has_many_polymorphs/configuration.rb +19 -0
- data/lib/has_many_polymorphs/debugging_tools.rb +103 -0
- data/lib/has_many_polymorphs/rake_task_redefine_task.rb +35 -0
- data/lib/has_many_polymorphs/reflection.rb +58 -0
- data/lib/has_many_polymorphs/support_methods.rb +88 -0
- data/lib/has_many_polymorphs.rb +27 -0
- data/test/fixtures/bow_wows.yml +10 -0
- data/test/fixtures/cats.yml +18 -0
- data/test/fixtures/eaters_foodstuffs.yml +0 -0
- data/test/fixtures/fish.yml +12 -0
- data/test/fixtures/frogs.yml +5 -0
- data/test/fixtures/keep_your_enemies_close.yml +0 -0
- data/test/fixtures/little_whale_pupils.yml +0 -0
- data/test/fixtures/people.yml +7 -0
- data/test/fixtures/petfoods.yml +11 -0
- data/test/fixtures/whales.yml +5 -0
- data/test/fixtures/wild_boars.yml +10 -0
- data/test/generator/tagging_generator_test.rb +42 -0
- data/test/integration/app/README +182 -0
- data/test/integration/app/Rakefile +19 -0
- data/test/integration/app/app/controllers/application.rb +7 -0
- data/test/integration/app/app/controllers/bones_controller.rb +5 -0
- data/test/integration/app/app/helpers/addresses_helper.rb +2 -0
- data/test/integration/app/app/helpers/application_helper.rb +3 -0
- data/test/integration/app/app/helpers/bones_helper.rb +2 -0
- data/test/integration/app/app/helpers/sellers_helper.rb +28 -0
- data/test/integration/app/app/helpers/states_helper.rb +2 -0
- data/test/integration/app/app/helpers/users_helper.rb +2 -0
- data/test/integration/app/app/models/bone.rb +2 -0
- data/test/integration/app/app/models/double_sti_parent.rb +2 -0
- data/test/integration/app/app/models/double_sti_parent_relationship.rb +2 -0
- data/test/integration/app/app/models/organic_substance.rb +2 -0
- data/test/integration/app/app/models/single_sti_parent.rb +4 -0
- data/test/integration/app/app/models/single_sti_parent_relationship.rb +4 -0
- data/test/integration/app/app/models/stick.rb +2 -0
- data/test/integration/app/app/models/stone.rb +2 -0
- data/test/integration/app/app/views/addresses/edit.html.erb +12 -0
- data/test/integration/app/app/views/addresses/index.html.erb +18 -0
- data/test/integration/app/app/views/addresses/new.html.erb +11 -0
- data/test/integration/app/app/views/addresses/show.html.erb +3 -0
- data/test/integration/app/app/views/bones/index.rhtml +5 -0
- data/test/integration/app/app/views/layouts/addresses.html.erb +17 -0
- data/test/integration/app/app/views/layouts/sellers.html.erb +17 -0
- data/test/integration/app/app/views/layouts/states.html.erb +17 -0
- data/test/integration/app/app/views/layouts/users.html.erb +17 -0
- data/test/integration/app/app/views/sellers/edit.html.erb +12 -0
- data/test/integration/app/app/views/sellers/index.html.erb +20 -0
- data/test/integration/app/app/views/sellers/new.html.erb +11 -0
- data/test/integration/app/app/views/sellers/show.html.erb +3 -0
- data/test/integration/app/app/views/states/edit.html.erb +12 -0
- data/test/integration/app/app/views/states/index.html.erb +19 -0
- data/test/integration/app/app/views/states/new.html.erb +11 -0
- data/test/integration/app/app/views/states/show.html.erb +3 -0
- data/test/integration/app/app/views/users/edit.html.erb +12 -0
- data/test/integration/app/app/views/users/index.html.erb +22 -0
- data/test/integration/app/app/views/users/new.html.erb +11 -0
- data/test/integration/app/app/views/users/show.html.erb +3 -0
- data/test/integration/app/config/boot.rb +110 -0
- data/test/integration/app/config/database.yml +17 -0
- data/test/integration/app/config/environment.rb +19 -0
- data/test/integration/app/config/environment.rb.canonical +19 -0
- data/test/integration/app/config/environments/development.rb +9 -0
- data/test/integration/app/config/environments/production.rb +18 -0
- data/test/integration/app/config/environments/test.rb +19 -0
- data/test/integration/app/config/locomotive.yml +6 -0
- data/test/integration/app/config/routes.rb +33 -0
- data/test/integration/app/config/ultrasphinx/default.base +56 -0
- data/test/integration/app/config/ultrasphinx/development.conf.canonical +155 -0
- data/test/integration/app/db/migrate/001_create_sticks.rb +11 -0
- data/test/integration/app/db/migrate/002_create_stones.rb +11 -0
- data/test/integration/app/db/migrate/003_create_organic_substances.rb +11 -0
- data/test/integration/app/db/migrate/004_create_bones.rb +8 -0
- data/test/integration/app/db/migrate/005_create_single_sti_parents.rb +11 -0
- data/test/integration/app/db/migrate/006_create_double_sti_parents.rb +11 -0
- data/test/integration/app/db/migrate/007_create_single_sti_parent_relationships.rb +13 -0
- data/test/integration/app/db/migrate/008_create_double_sti_parent_relationships.rb +14 -0
- data/test/integration/app/db/migrate/009_create_library_model.rb +11 -0
- data/test/integration/app/doc/README_FOR_APP +2 -0
- data/test/integration/app/generators/commenting_generator_test.rb +83 -0
- data/test/integration/app/lib/library_model.rb +2 -0
- data/test/integration/app/public/404.html +30 -0
- data/test/integration/app/public/500.html +30 -0
- data/test/integration/app/public/dispatch.cgi +10 -0
- data/test/integration/app/public/dispatch.fcgi +24 -0
- data/test/integration/app/public/dispatch.rb +10 -0
- data/test/integration/app/public/favicon.ico +0 -0
- data/test/integration/app/public/images/rails.png +0 -0
- data/test/integration/app/public/index.html +277 -0
- data/test/integration/app/public/javascripts/application.js +2 -0
- data/test/integration/app/public/javascripts/controls.js +833 -0
- data/test/integration/app/public/javascripts/dragdrop.js +942 -0
- data/test/integration/app/public/javascripts/effects.js +1088 -0
- data/test/integration/app/public/javascripts/prototype.js +2515 -0
- data/test/integration/app/public/robots.txt +1 -0
- data/test/integration/app/public/stylesheets/scaffold.css +74 -0
- data/test/integration/app/script/about +3 -0
- data/test/integration/app/script/breakpointer +3 -0
- data/test/integration/app/script/console +3 -0
- data/test/integration/app/script/destroy +3 -0
- data/test/integration/app/script/generate +3 -0
- data/test/integration/app/script/performance/benchmarker +3 -0
- data/test/integration/app/script/performance/profiler +3 -0
- data/test/integration/app/script/plugin +3 -0
- data/test/integration/app/script/process/inspector +3 -0
- data/test/integration/app/script/process/reaper +3 -0
- data/test/integration/app/script/process/spawner +3 -0
- data/test/integration/app/script/runner +3 -0
- data/test/integration/app/script/server +3 -0
- data/test/integration/app/test/fixtures/double_sti_parent_relationships.yml +7 -0
- data/test/integration/app/test/fixtures/double_sti_parents.yml +7 -0
- data/test/integration/app/test/fixtures/organic_substances.yml +5 -0
- data/test/integration/app/test/fixtures/single_sti_parent_relationships.yml +7 -0
- data/test/integration/app/test/fixtures/single_sti_parents.yml +7 -0
- data/test/integration/app/test/fixtures/sticks.yml +7 -0
- data/test/integration/app/test/fixtures/stones.yml +7 -0
- data/test/integration/app/test/functional/addresses_controller_test.rb +57 -0
- data/test/integration/app/test/functional/bones_controller_test.rb +8 -0
- data/test/integration/app/test/functional/sellers_controller_test.rb +57 -0
- data/test/integration/app/test/functional/states_controller_test.rb +57 -0
- data/test/integration/app/test/functional/users_controller_test.rb +57 -0
- data/test/integration/app/test/test_helper.rb +8 -0
- data/test/integration/app/test/unit/bone_test.rb +8 -0
- data/test/integration/app/test/unit/double_sti_parent_relationship_test.rb +8 -0
- data/test/integration/app/test/unit/double_sti_parent_test.rb +8 -0
- data/test/integration/app/test/unit/organic_substance_test.rb +8 -0
- data/test/integration/app/test/unit/single_sti_parent_relationship_test.rb +8 -0
- data/test/integration/app/test/unit/single_sti_parent_test.rb +8 -0
- data/test/integration/app/test/unit/stick_test.rb +8 -0
- data/test/integration/app/test/unit/stone_test.rb +8 -0
- data/test/integration/server_test.rb +43 -0
- data/test/models/aquatic/fish.rb +5 -0
- data/test/models/aquatic/pupils_whale.rb +7 -0
- data/test/models/aquatic/whale.rb +15 -0
- data/test/models/beautiful_fight_relationship.rb +26 -0
- data/test/models/canine.rb +9 -0
- data/test/models/cat.rb +5 -0
- data/test/models/dog.rb +18 -0
- data/test/models/eaters_foodstuff.rb +8 -0
- data/test/models/frog.rb +4 -0
- data/test/models/kitten.rb +3 -0
- data/test/models/parentship.rb +4 -0
- data/test/models/person.rb +9 -0
- data/test/models/petfood.rb +39 -0
- data/test/models/tabby.rb +2 -0
- data/test/models/wild_boar.rb +3 -0
- data/test/modules/extension_module.rb +9 -0
- data/test/modules/other_extension_module.rb +9 -0
- data/test/patches/symlinked_plugins_1.2.6.diff +46 -0
- data/test/schema.rb +87 -0
- data/test/setup.rb +14 -0
- data/test/test_helper.rb +52 -0
- data/test/unit/has_many_polymorphs_test.rb +713 -0
- data.tar.gz.sig +1 -0
- metadata +279 -0
- metadata.gz.sig +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
|
2
|
+
|
|
3
|
+
body, p, ol, ul, td {
|
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
|
5
|
+
font-size: 13px;
|
|
6
|
+
line-height: 18px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
pre {
|
|
10
|
+
background-color: #eee;
|
|
11
|
+
padding: 10px;
|
|
12
|
+
font-size: 11px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
a { color: #000; }
|
|
16
|
+
a:visited { color: #666; }
|
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
|
18
|
+
|
|
19
|
+
.fieldWithErrors {
|
|
20
|
+
padding: 2px;
|
|
21
|
+
background-color: red;
|
|
22
|
+
display: table;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
#errorExplanation {
|
|
26
|
+
width: 400px;
|
|
27
|
+
border: 2px solid red;
|
|
28
|
+
padding: 7px;
|
|
29
|
+
padding-bottom: 12px;
|
|
30
|
+
margin-bottom: 20px;
|
|
31
|
+
background-color: #f0f0f0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#errorExplanation h2 {
|
|
35
|
+
text-align: left;
|
|
36
|
+
font-weight: bold;
|
|
37
|
+
padding: 5px 5px 5px 15px;
|
|
38
|
+
font-size: 12px;
|
|
39
|
+
margin: -7px;
|
|
40
|
+
background-color: #c00;
|
|
41
|
+
color: #fff;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#errorExplanation p {
|
|
45
|
+
color: #333;
|
|
46
|
+
margin-bottom: 0;
|
|
47
|
+
padding: 5px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#errorExplanation ul li {
|
|
51
|
+
font-size: 12px;
|
|
52
|
+
list-style: square;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
div.uploadStatus {
|
|
56
|
+
margin: 5px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
div.progressBar {
|
|
60
|
+
margin: 5px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
div.progressBar div.border {
|
|
64
|
+
background-color: #fff;
|
|
65
|
+
border: 1px solid grey;
|
|
66
|
+
width: 100%;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
div.progressBar div.background {
|
|
70
|
+
background-color: #333;
|
|
71
|
+
height: 18px;
|
|
72
|
+
width: 0%;
|
|
73
|
+
}
|
|
74
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'addresses_controller'
|
|
3
|
+
|
|
4
|
+
# Re-raise errors caught by the controller.
|
|
5
|
+
class AddressesController; def rescue_action(e) raise e end; end
|
|
6
|
+
|
|
7
|
+
class AddressesControllerTest < ActiveSupport::TestCase
|
|
8
|
+
fixtures :addresses
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
@controller = AddressesController.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(:addresses)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_should_get_new
|
|
23
|
+
get :new
|
|
24
|
+
assert_response :success
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_should_create_address
|
|
28
|
+
assert_difference('Address.count') do
|
|
29
|
+
post :create, :address => { :country_id => 1, :user_id => 1, :state_id => 1}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
assert_redirected_to address_path(assigns(:address))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_should_show_address
|
|
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_address
|
|
46
|
+
put :update, :id => 1, :address => { }
|
|
47
|
+
assert_redirected_to address_path(assigns(:address))
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_should_destroy_address
|
|
51
|
+
assert_difference('Address.count', -1) do
|
|
52
|
+
delete :destroy, :id => 1
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
assert_redirected_to addresses_path
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -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 < ActiveSupport::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 < ActiveSupport::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 < ActiveSupport::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,43 @@
|
|
|
1
|
+
|
|
2
|
+
require "#{File.dirname(__FILE__)}/../test_helper"
|
|
3
|
+
require 'open-uri'
|
|
4
|
+
|
|
5
|
+
# Start the server
|
|
6
|
+
|
|
7
|
+
class ServerTest < ActiveSupport::TestCase
|
|
8
|
+
|
|
9
|
+
PORT = 43040
|
|
10
|
+
URL = "http://localhost:#{PORT}/"
|
|
11
|
+
|
|
12
|
+
def setup
|
|
13
|
+
@pid = Process.fork do
|
|
14
|
+
Dir.chdir RAILS_ROOT do
|
|
15
|
+
# print "S"
|
|
16
|
+
exec("script/server -p #{PORT} &> #{LOG}")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
sleep(5)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def teardown
|
|
23
|
+
# Process.kill(9, @pid) doesn't work because Mongrel has double-forked itself away
|
|
24
|
+
`ps awx | grep #{PORT} | grep -v grep | awk '{print $1}'`.split("\n").each do |pid|
|
|
25
|
+
system("kill -9 #{pid}")
|
|
26
|
+
# print "K"
|
|
27
|
+
end
|
|
28
|
+
sleep(2)
|
|
29
|
+
@pid = nil
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_association_reloading
|
|
33
|
+
assert_match(/Bones: index/, open(URL + 'bones').read)
|
|
34
|
+
assert_match(/Bones: index/, open(URL + 'bones').read)
|
|
35
|
+
assert_match(/Bones: index/, open(URL + 'bones').read)
|
|
36
|
+
assert_match(/Bones: index/, open(URL + 'bones').read)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_verify_autoload_gets_invoked_in_console
|
|
40
|
+
# XXX Probably can use script/runner to test this
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# see http://dev.rubyonrails.org/ticket/5935
|
|
2
|
+
module Aquatic; end
|
|
3
|
+
require 'aquatic/fish'
|
|
4
|
+
require 'aquatic/pupils_whale'
|
|
5
|
+
|
|
6
|
+
class Aquatic::Whale < ActiveRecord::Base
|
|
7
|
+
# set_table_name "whales"
|
|
8
|
+
|
|
9
|
+
has_many_polymorphs(:aquatic_pupils, :from => [:dogs, :"aquatic/fish"],
|
|
10
|
+
:through => "aquatic/pupils_whales") do
|
|
11
|
+
def a_method
|
|
12
|
+
:correct_block_result
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
require 'extension_module'
|
|
3
|
+
|
|
4
|
+
class BeautifulFightRelationship < ActiveRecord::Base
|
|
5
|
+
set_table_name 'keep_your_enemies_close'
|
|
6
|
+
|
|
7
|
+
belongs_to :enemy, :polymorphic => true
|
|
8
|
+
belongs_to :protector, :polymorphic => true
|
|
9
|
+
# polymorphic relationships with column names different from the relationship name
|
|
10
|
+
# are not supported by Rails
|
|
11
|
+
|
|
12
|
+
acts_as_double_polymorphic_join :enemies => [:dogs, :kittens, :frogs],
|
|
13
|
+
:protectors => [:wild_boars, :kittens, :"aquatic/fish", :dogs],
|
|
14
|
+
:enemies_extend => [ExtensionModule, proc {}],
|
|
15
|
+
:protectors_extend => proc {
|
|
16
|
+
def a_method
|
|
17
|
+
:correct_proc_result
|
|
18
|
+
end
|
|
19
|
+
},
|
|
20
|
+
:join_extend => proc {
|
|
21
|
+
def a_method
|
|
22
|
+
:correct_join_result
|
|
23
|
+
end
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
data/test/models/cat.rb
ADDED
data/test/models/dog.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
require 'canine'
|
|
3
|
+
|
|
4
|
+
class Dog < Canine
|
|
5
|
+
attr_accessor :after_find_test, :after_initialize_test
|
|
6
|
+
set_table_name "bow_wows"
|
|
7
|
+
|
|
8
|
+
def after_find
|
|
9
|
+
@after_find_test = true
|
|
10
|
+
# puts "After find called on #{name}."
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def after_initialize
|
|
14
|
+
@after_initialize_test = true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|