has_many_polymorphs 2.11 → 2.12

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,85 +0,0 @@
1
- class StatesController < ApplicationController
2
- # GET /states
3
- # GET /states.xml
4
- def index
5
- @states = State.find(:all)
6
-
7
- respond_to do |format|
8
- format.html # index.html.erb
9
- format.xml { render :xml => @states }
10
- end
11
- end
12
-
13
- # GET /states/1
14
- # GET /states/1.xml
15
- def show
16
- @state = State.find(params[:id])
17
-
18
- respond_to do |format|
19
- format.html # show.html.erb
20
- format.xml { render :xml => @state }
21
- end
22
- end
23
-
24
- # GET /states/new
25
- # GET /states/new.xml
26
- def new
27
- @state = State.new
28
-
29
- respond_to do |format|
30
- format.html # new.html.erb
31
- format.xml { render :xml => @state }
32
- end
33
- end
34
-
35
- # GET /states/1/edit
36
- def edit
37
- @state = State.find(params[:id])
38
- end
39
-
40
- # POST /states
41
- # POST /states.xml
42
- def create
43
- @state = State.new(params[:state])
44
-
45
- respond_to do |format|
46
- if @state.save
47
- flash[:notice] = 'State was successfully created.'
48
- format.html { redirect_to(@state) }
49
- format.xml { render :xml => @state, :status => :created, :location => @state }
50
- else
51
- format.html { render :action => "new" }
52
- format.xml { render :xml => @state.errors, :status => :unprocessable_entity }
53
- end
54
- end
55
- end
56
-
57
- # PUT /states/1
58
- # PUT /states/1.xml
59
- def update
60
- @state = State.find(params[:id])
61
-
62
- respond_to do |format|
63
- if @state.update_attributes(params[:state])
64
- flash[:notice] = 'State was successfully updated.'
65
- format.html { redirect_to(@state) }
66
- format.xml { head :ok }
67
- else
68
- format.html { render :action => "edit" }
69
- format.xml { render :xml => @state.errors, :status => :unprocessable_entity }
70
- end
71
- end
72
- end
73
-
74
- # DELETE /states/1
75
- # DELETE /states/1.xml
76
- def destroy
77
- @state = State.find(params[:id])
78
- @state.destroy
79
-
80
- respond_to do |format|
81
- format.html { redirect_to(states_url) }
82
- format.xml { head :ok }
83
- end
84
- end
85
- end
@@ -1,85 +0,0 @@
1
- class UsersController < ApplicationController
2
- # GET /users
3
- # GET /users.xml
4
- def index
5
- @users = User.find(:all)
6
-
7
- respond_to do |format|
8
- format.html # index.html.erb
9
- format.xml { render :xml => @users }
10
- end
11
- end
12
-
13
- # GET /users/1
14
- # GET /users/1.xml
15
- def show
16
- @user = User.find(params[:id])
17
-
18
- respond_to do |format|
19
- format.html # show.html.erb
20
- format.xml { render :xml => @user }
21
- end
22
- end
23
-
24
- # GET /users/new
25
- # GET /users/new.xml
26
- def new
27
- @user = User.new
28
-
29
- respond_to do |format|
30
- format.html # new.html.erb
31
- format.xml { render :xml => @user }
32
- end
33
- end
34
-
35
- # GET /users/1/edit
36
- def edit
37
- @user = User.find(params[:id])
38
- end
39
-
40
- # POST /users
41
- # POST /users.xml
42
- def create
43
- @user = User.new(params[:user])
44
-
45
- respond_to do |format|
46
- if @user.save
47
- flash[:notice] = 'User was successfully created.'
48
- format.html { redirect_to(@user) }
49
- format.xml { render :xml => @user, :status => :created, :location => @user }
50
- else
51
- format.html { render :action => "new" }
52
- format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
53
- end
54
- end
55
- end
56
-
57
- # PUT /users/1
58
- # PUT /users/1.xml
59
- def update
60
- @user = User.find(params[:id])
61
-
62
- respond_to do |format|
63
- if @user.update_attributes(params[:user])
64
- flash[:notice] = 'User was successfully updated.'
65
- format.html { redirect_to(@user) }
66
- format.xml { head :ok }
67
- else
68
- format.html { render :action => "edit" }
69
- format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
70
- end
71
- end
72
- end
73
-
74
- # DELETE /users/1
75
- # DELETE /users/1.xml
76
- def destroy
77
- @user = User.find(params[:id])
78
- @user.destroy
79
-
80
- respond_to do |format|
81
- format.html { redirect_to(users_url) }
82
- format.xml { head :ok }
83
- end
84
- end
85
- end
@@ -1,4 +0,0 @@
1
- class Address < ActiveRecord::Base
2
- belongs_to :user
3
- belongs_to :state
4
- end
@@ -1,3 +0,0 @@
1
- class Citation < ActiveRecord::Base
2
- has_many_polymorphs :items, :from => [:users, :sellers]
3
- end
@@ -1,4 +0,0 @@
1
- class CitationsItem < ActiveRecord::Base
2
- belongs_to :citation
3
- belongs_to :item, :polymorphic => true
4
- end
@@ -1,4 +0,0 @@
1
- class Seller < ActiveRecord::Base
2
- belongs_to :user
3
- delegate :address, :to => :user
4
- end
@@ -1,3 +0,0 @@
1
- class State < ActiveRecord::Base
2
- has_many :addresses
3
- end
@@ -1,4 +0,0 @@
1
- class User < ActiveRecord::Base
2
- has_one :seller
3
- has_one :address
4
- end
@@ -1,16 +0,0 @@
1
- class CreateUsers < ActiveRecord::Migration
2
- def self.up
3
- create_table "users", :force => true do |t|
4
- t.string "login", :limit => 64, :default => "", :null => false
5
- t.string "email", :default => "", :null => false
6
- t.string "crypted_password", :limit => 64, :default => "", :null => false
7
- t.string "salt", :limit => 64, :default => "", :null => false
8
- t.datetime "created_at"
9
- t.datetime "updated_at"
10
- end
11
- end
12
-
13
- def self.down
14
- drop_table :users
15
- end
16
- end
@@ -1,14 +0,0 @@
1
- class CreateSellers < ActiveRecord::Migration
2
- def self.up
3
- create_table "sellers", :force => true do |t|
4
- t.integer "user_id", :null => false
5
- t.string "company_name"
6
- t.datetime "created_at"
7
- t.datetime "updated_at"
8
- end
9
- end
10
-
11
- def self.down
12
- drop_table :sellers
13
- end
14
- end
@@ -1,19 +0,0 @@
1
- class CreateAddresses < ActiveRecord::Migration
2
- def self.up
3
- create_table "addresses", :force => true do |t|
4
- t.integer "user_id", :null => false
5
- t.string "name"
6
- t.string "line_1", :default => "", :null => false
7
- t.string "line_2"
8
- t.string "city", :default => "", :null => false
9
- t.integer "state_id", :null => false
10
- t.string "province_region"
11
- t.string "zip_postal_code"
12
- t.integer "country_id", :null => false
13
- end
14
- end
15
-
16
- def self.down
17
- drop_table :addresses
18
- end
19
- end
@@ -1,12 +0,0 @@
1
- class CreateStates < ActiveRecord::Migration
2
- def self.up
3
- create_table "states", :force => true do |t|
4
- t.string "name", :default => "", :null => false
5
- t.string "abbreviation", :default => "", :null => false
6
- end
7
- end
8
-
9
- def self.down
10
- drop_table "states"
11
- end
12
- end
@@ -1,9 +0,0 @@
1
- class AddCapitalizationToSeller < ActiveRecord::Migration
2
- def self.up
3
- add_column :sellers, :capitalization, :float, :default => 0.0
4
- end
5
-
6
- def self.down
7
- remove_column :sellers, :capitalization
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class AddDeletedToUser < ActiveRecord::Migration
2
- def self.up
3
- add_column :users, :deleted, :boolean, :default => false
4
- end
5
-
6
- def self.down
7
- remove_column :users, :deleted
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- class AddLatAndLongToAddress < ActiveRecord::Migration
2
- def self.up
3
- add_column :addresses, :lat, :float
4
- add_column :addresses, :long, :float
5
- end
6
-
7
- def self.down
8
- remove_column :addresses, :lat
9
- remove_column :addresses, :long
10
- end
11
- end
@@ -1,12 +0,0 @@
1
- class CreateCitations < ActiveRecord::Migration
2
- def self.up
3
- create_table :citations do |t|
4
- t.string :name
5
- t.timestamps
6
- end
7
- end
8
-
9
- def self.down
10
- drop_table :citations
11
- end
12
- end
@@ -1,14 +0,0 @@
1
- class CreateCitationsItems < ActiveRecord::Migration
2
- def self.up
3
- create_table :citations_items do |t|
4
- t.integer :citation_id, :null => false
5
- t.integer :item_id, :null => false
6
- t.string :item_type, :null => false
7
- t.timestamps
8
- end
9
- end
10
-
11
- def self.down
12
- drop_table :citations_items
13
- end
14
- end
@@ -1,109 +0,0 @@
1
-
2
- class Aquatic::Fish
3
-
4
- has_many :aquatic_pupils_whales,
5
- :extend => [],
6
- :dependent => :destroy,
7
- :conditions => nil,
8
- :as => :aquatic_pupil,
9
- :class_name => "Aquatic::PupilsWhale",
10
- :order => nil
11
- # called from line 57
12
-
13
- has_many :whales,
14
- :source => :whale,
15
- :extend => [],
16
- :foreign_key => "whale_id",
17
- :limit => nil,
18
- :through => :aquatic_pupils_whales,
19
- :group => nil,
20
- :conditions => nil,
21
- :offset => nil,
22
- :class_name => "Aquatic::Whale",
23
- :order => nil
24
- # called from line 57
25
-
26
- has_many_polymorphs :enemies,
27
- :singular_reverse_association_id => :protector,
28
- :extend => [ExtensionModule, #<Proc:0x00000000@/Users/eweaver/Desktop/projects/fauna/has_many_polymorphs/trunk/test/models/beautiful_fight_relationship.rb:14>],
29
- :foreign_key => "protector_id",
30
- :is_double => true,
31
- :from => [:dogs,
32
- :kittens,
33
- :frogs],
34
- :through => :beautiful_fight_relationships,
35
- :foreign_type_key => "protector_type",
36
- :join_extend => [#<Proc:0x03be672c@/Users/eweaver/Desktop/projects/fauna/has_many_polymorphs/trunk/test/models/beautiful_fight_relationship.rb:20>],
37
- :conflicts => [:dogs,
38
- :kittens],
39
- :as => :protector
40
- # called from line 57
41
-
42
- has_many :beautiful_fight_relationships_as_protector,
43
- :extend => [Aquatic::FishEnemyPolymorphicJoinAssociationExtension0],
44
- :dependent => :destroy,
45
- :foreign_key => "protector_id",
46
- :conditions => "protector_type = 'Aquatic::Fish'",
47
- :as => :protector,
48
- :class_name => "BeautifulFightRelationship"
49
- # called from line 57
50
-
51
- has_many :frogs,
52
- :source => :enemy,
53
- :extend => [Aquatic::FishFrogPolymorphicChildAssociationExtension, ExtensionModule, Aquatic::FishEnemyPolymorphicAssociationExtension0],
54
- :limit => nil,
55
- :through => :beautiful_fight_relationships_as_protector,
56
- :group => nil,
57
- :conditions => nil,
58
- :source_type => "Frog",
59
- :class_name => "Frog",
60
- :order => nil
61
- # called from line 57
62
-
63
- has_many :kittens,
64
- :source => :enemy,
65
- :extend => [Aquatic::FishKittenPolymorphicChildAssociationExtension, ExtensionModule, Aquatic::FishEnemyPolymorphicAssociationExtension0],
66
- :limit => nil,
67
- :through => :beautiful_fight_relationships_as_protector,
68
- :group => nil,
69
- :conditions => nil,
70
- :source_type => "Cat",
71
- :class_name => "Kitten",
72
- :order => nil
73
- # called from line 57
74
-
75
- has_many :dogs,
76
- :source => :enemy,
77
- :extend => [Aquatic::FishDogPolymorphicChildAssociationExtension, ExtensionModule, Aquatic::FishEnemyPolymorphicAssociationExtension0],
78
- :limit => nil,
79
- :through => :beautiful_fight_relationships_as_protector,
80
- :group => nil,
81
- :conditions => nil,
82
- :source_type => "Dog",
83
- :class_name => "Dog",
84
- :order => nil
85
- # called from line 57
86
-
87
- has_many :eaters_foodstuffs,
88
- :extend => [Petfood::PetfoodEaterPolymorphicJoinAssociationExtension0],
89
- :dependent => :destroy,
90
- :conditions => "NULL IS NULL OR NULL != 'Snausages'",
91
- :as => :eater,
92
- :class_name => "EatersFoodstuff",
93
- :order => "NULL DESC"
94
- # called from line 57
95
-
96
- has_many :foodstuffs_of_eaters,
97
- :source => :foodstuff,
98
- :extend => [Petfood::PetfoodEaterPolymorphicParentAssociationExtension0],
99
- :foreign_key => "foodstuff_id",
100
- :limit => nil,
101
- :through => :eaters_foodstuffs,
102
- :group => nil,
103
- :conditions => "petfoods.name IS NULL OR petfoods.name != 'Snausages'",
104
- :offset => nil,
105
- :class_name => "Petfood",
106
- :order => "petfoods.the_petfood_primary_key DESC"
107
- # called from line 57
108
-
109
- end