acts_as_relation 0.1 → 0.1.1

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 (59) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +1 -1
  3. data/MIT-LICENSE +20 -0
  4. data/README.rdoc +3 -3
  5. data/acts_as_relation.gemspec +3 -1
  6. data/init.rb +1 -0
  7. data/lib/active_record/acts_as_relation.rb +15 -11
  8. data/lib/version.rb +1 -1
  9. data/spec/{acts_as_relation/acts_as_relation_spec.rb → acts_as_relation_spec.rb} +19 -4
  10. data/spec/acts_as_superclass_spec.rb +14 -0
  11. data/spec/dummy/.rspec +1 -0
  12. data/spec/dummy/README.rdoc +261 -0
  13. data/spec/dummy/Rakefile +7 -0
  14. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  15. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  16. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  17. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  18. data/spec/dummy/app/mailers/.gitkeep +0 -0
  19. data/spec/dummy/app/models/.gitkeep +0 -0
  20. data/spec/dummy/app/models/pen.rb +6 -0
  21. data/spec/dummy/app/models/pencil.rb +3 -0
  22. data/spec/dummy/app/models/product.rb +11 -0
  23. data/spec/dummy/app/models/store.rb +2 -0
  24. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  25. data/spec/dummy/config.ru +4 -0
  26. data/spec/dummy/config/application.rb +64 -0
  27. data/spec/dummy/config/boot.rb +10 -0
  28. data/spec/dummy/config/database.yml +25 -0
  29. data/spec/dummy/config/environment.rb +5 -0
  30. data/spec/dummy/config/environments/development.rb +37 -0
  31. data/spec/dummy/config/environments/production.rb +67 -0
  32. data/spec/dummy/config/environments/test.rb +37 -0
  33. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  34. data/spec/dummy/config/initializers/inflections.rb +15 -0
  35. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  36. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  37. data/spec/dummy/config/initializers/session_store.rb +8 -0
  38. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  39. data/spec/dummy/config/locales/en.yml +5 -0
  40. data/spec/dummy/config/routes.rb +58 -0
  41. data/spec/dummy/db/migrate/001_create_stores.rb +9 -0
  42. data/spec/dummy/db/migrate/002_create_products.rb +10 -0
  43. data/spec/dummy/db/migrate/003_create_pens.rb +9 -0
  44. data/spec/dummy/db/migrate/004_create_pencils.rb +8 -0
  45. data/spec/dummy/db/schema.rb +44 -0
  46. data/spec/dummy/lib/assets/.gitkeep +0 -0
  47. data/spec/dummy/log/.gitkeep +0 -0
  48. data/spec/dummy/public/404.html +26 -0
  49. data/spec/dummy/public/422.html +26 -0
  50. data/spec/dummy/public/500.html +25 -0
  51. data/spec/dummy/public/favicon.ico +0 -0
  52. data/spec/dummy/script/rails +6 -0
  53. data/spec/spec_helper.rb +9 -6
  54. metadata +161 -26
  55. data/spec/acts_as_migration/acts_as_migratoin_spec.rb +0 -24
  56. data/spec/acts_as_migration/models.rb +0 -7
  57. data/spec/acts_as_migration/schema.rb +0 -33
  58. data/spec/acts_as_relation/models.rb +0 -25
  59. data/spec/acts_as_relation/schema.rb +0 -28
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "create_table acts_as_superclass" do
4
- before :all do
5
- ActsAsSuperclassSchema.migrate
6
- end
7
-
8
- it "creates foreign key and type columns on" do
9
- name = Product.acts_as_association_name
10
- Product.attribute_names.should include("#{name}_id")
11
- Product.attribute_names.should include("#{name}_type")
12
- end
13
- end
14
-
15
- describe "create_table acts_as_superclass option withname" do
16
- before :all do
17
- ActsAsSuperclassWithNameSchema.migrate
18
- end
19
-
20
- it "creates foreign key and type columns on" do
21
- OtherProduct.attribute_names.should include("producible_id")
22
- OtherProduct.attribute_names.should include("producible_type")
23
- end
24
- end
@@ -1,7 +0,0 @@
1
- class Product < ActiveRecord::Base
2
- acts_as_superclass
3
- end
4
-
5
- class OtherProduct < ActiveRecord::Base
6
- acts_as_superclass
7
- end
@@ -1,33 +0,0 @@
1
- module ActsAsSuperclassSchema
2
- def self.migrate
3
- ActiveRecord::Base.establish_connection(
4
- :adapter => "sqlite3",
5
- :database => ":memory:"
6
- )
7
- ActiveRecord::Schema.define do
8
- suppress_messages do
9
- create_table :products, :as_relation_superclass => true do |t|
10
- end
11
- end
12
- end
13
-
14
- require Pathname(__FILE__).parent.join("models.rb")
15
- end
16
- end
17
-
18
- module ActsAsSuperclassWithNameSchema
19
- def self.migrate
20
- ActiveRecord::Base.establish_connection(
21
- :adapter => "sqlite3",
22
- :database => ":memory:"
23
- )
24
- ActiveRecord::Schema.define do
25
- suppress_messages do
26
- create_table :other_products, :as_relation_superclass => :producible do |t|
27
- end
28
- end
29
- end
30
-
31
- require Pathname(__FILE__).parent.join("models.rb")
32
- end
33
- end
@@ -1,25 +0,0 @@
1
- class Store < ActiveRecord::Base
2
- has_many :products
3
- end
4
-
5
- class Product < ActiveRecord::Base
6
- acts_as_superclass
7
-
8
- belongs_to :store
9
- validates_presence_of :name, :price
10
-
11
- def parent_method
12
- "#{name} - #{price}"
13
- end
14
- end
15
-
16
- class Pen < ActiveRecord::Base
17
- acts_as_superclass
18
-
19
- acts_as :product
20
- validates_presence_of :color
21
- end
22
-
23
- class Pencil < ActiveRecord::Base
24
- acts_as :pen
25
- end
@@ -1,28 +0,0 @@
1
- module ActsAsRelationSchema
2
- def self.migrate
3
- ActiveRecord::Base.establish_connection(
4
- :adapter => "sqlite3",
5
- :database => ":memory:"
6
- )
7
- ActiveRecord::Schema.define do
8
- suppress_messages do
9
- create_table :stores do |t|
10
- t.string :store_name
11
- end
12
-
13
- create_table :products, :as_relation_superclass => true do |t|
14
- t.string :name
15
- t.float :price
16
- end
17
-
18
- create_table :pens, :as_relation_superclass => true do |t|
19
- t.string :color
20
- end
21
-
22
- create_table :pencils
23
- end
24
- end
25
-
26
- require Pathname(__FILE__).parent.join("models.rb")
27
- end
28
- end