dovadi-with_properties 0.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.
data/History.txt ADDED
@@ -0,0 +1,3 @@
1
+ === 0.0.1 2009-08-20
2
+
3
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,32 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.textile
4
+ Rakefile
5
+ lib/with_properties/core.rb
6
+ lib/with_properties.rb
7
+ tasks/with_properties.rake
8
+ test/factories/general.rb
9
+ test/rails_root/app/models/customer.rb
10
+ test/rails_root/app/models/customer_detail.rb
11
+ test/rails_root/app/models/employee.rb
12
+ test/rails_root/app/models/employee_property.rb
13
+ test/rails_root/app/models/manager.rb
14
+ test/rails_root/app/models/person.rb
15
+ test/rails_root/config/boot.rb
16
+ test/rails_root/config/database.yml
17
+ test/rails_root/config/environment.rb
18
+ test/rails_root/config/environments/test.rb
19
+ test/rails_root/config/routes.rb
20
+ test/rails_root/db/migrate/20090820105348_create_people.rb
21
+ test/rails_root/db/migrate/20090820105521_create_employee_properties.rb
22
+ test/rails_root/db/migrate/20090820110621_create_customer_details.rb
23
+ test/rails_root/db/schema.rb
24
+ test/rails_root/db/test.sqlite3
25
+ test/test_helper.rb
26
+ test/unit/customer_detail_test.rb
27
+ test/unit/customer_test.rb
28
+ test/unit/employee_property_test.rb
29
+ test/unit/employee_test.rb
30
+ test/unit/manager_test.rb
31
+ test/unit/person_test.rb
32
+ with_properties.gemspec
data/README.textile ADDED
@@ -0,0 +1,79 @@
1
+ h2. With_properties
2
+
3
+ Download: http://github.com/dovadi/with_properties
4
+
5
+ h2. Description:
6
+
7
+ Add extra properties to individual STI subclasses (ActiveRecord)
8
+
9
+ h2. Synopsis:
10
+
11
+ h4. Setup
12
+ <pre>
13
+ create_table "customer_details", :force => true do |t|
14
+ t.string "phone"
15
+ t.integer "customer_id"
16
+ t.datetime "created_at"
17
+ t.datetime "updated_at"
18
+ end
19
+
20
+ create_table "people", :force => true do |t|
21
+ t.string "type"
22
+ t.string "name"
23
+ t.string "email"
24
+ t.datetime "created_at"
25
+ t.datetime "updated_at"
26
+ end
27
+ </pre>
28
+
29
+ h4. Example
30
+ <pre>
31
+ class Person < ActiveRecord::Base
32
+ end
33
+
34
+ class Customer < Person
35
+ with_properties :customer_details
36
+ validates_uniqeness_of :phone
37
+ end
38
+
39
+ customer = Customer.create(:name =>'Dovadi', :email=>'frank@dovadi.com', :phone=>'0649416406')
40
+ customer.update_attributes(:phone=>'0222300100')
41
+ </pre>
42
+
43
+ h2. Install:
44
+
45
+ * git clone http://github.com/dovadi/with_properties
46
+
47
+ * sudo gem install dovadi-with_properties
48
+
49
+ h2. Credits
50
+
51
+ This project is funded and maintained by "Agile Dovadi BV":http://dovadi.com, contact "Frank Oxener":mailto:frank@dovadi.com
52
+
53
+
54
+ h2. Licence:
55
+
56
+ <pre>
57
+ (The MIT License)
58
+
59
+ Copyright (c) 2009 Frank Oxener - Agile Dovadi B.V.
60
+
61
+ Permission is hereby granted, free of charge, to any person obtaining
62
+ a copy of this software and associated documentation files (the
63
+ 'Software'), to deal in the Software without restriction, including
64
+ without limitation the rights to use, copy, modify, merge, publish,
65
+ distribute, sublicense, and/or sell copies of the Software, and to
66
+ permit persons to whom the Software is furnished to do so, subject to
67
+ the following conditions:
68
+
69
+ The above copyright notice and this permission notice shall be
70
+ included in all copies or substantial portions of the Software.
71
+
72
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
73
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
74
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
75
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
76
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
77
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
78
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
79
+ </pre>
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ Dir['tasks/**/*.rake'].each { |t| load t }
@@ -0,0 +1,74 @@
1
+ module WithProperties
2
+ module Core
3
+
4
+ def self.included(base)
5
+ base.extend(ClassMethods)
6
+ end
7
+
8
+ module ClassMethods
9
+
10
+ def with_properties table
11
+ properties = table.to_s
12
+ has_one table
13
+ before_save :save_properties
14
+
15
+ define_getters_and_setters(properties)
16
+ define_save_properties(properties)
17
+ override_create(properties)
18
+ end
19
+
20
+ private
21
+
22
+ def define_save_properties(properties)
23
+ class_eval %{
24
+ def save_properties
25
+ #{properties}.save if #{properties} && #{properties}.changed?
26
+ end
27
+ }
28
+ end
29
+
30
+ def define_getters_and_setters(properties)
31
+ column_names = properties.camelize.constantize.column_names.reject {|column| column=~/^id$|_id|_at/}
32
+ column_names.each do |column|
33
+ class_eval %{
34
+ def #{column}
35
+ #{properties}.nil? ? '' : #{properties}.#{column}
36
+ end
37
+ def #{column}=(value)
38
+ #{properties}.#{column}=value if #{properties}
39
+ end
40
+ }
41
+ end
42
+ end
43
+
44
+ def override_create(properties)
45
+ instance_eval %{
46
+ def create(attributes = nil, &block)
47
+ attributes.stringify_keys!
48
+ attributes_without_associated = attributes.reject{|k,v| k if reflections[k.to_sym]}
49
+
50
+ attribute_keys = attributes_without_associated.keys.map{|k| k.to_s}
51
+ attributes_only_associated_keys = attributes.keys - attributes_without_associated.keys
52
+
53
+ property_attribute_keys = (attribute_keys - column_names)
54
+ parent_attribute_keys = attribute_keys - property_attribute_keys
55
+
56
+ parent_attributes = {}
57
+ property_attributes ={}
58
+ attributes.each do |k,v|
59
+ parent_attributes[k]=v if parent_attribute_keys.include?(k) || attributes_only_associated_keys.include?(k)
60
+ property_attributes[k]=v if property_attribute_keys.include?(k)
61
+ end
62
+ instance_of_property_model = "#{properties}".camelize.constantize.new(property_attributes)
63
+
64
+ attributes = parent_attributes.merge(:#{properties}=>instance_of_property_model)
65
+
66
+ super
67
+ end
68
+ }
69
+ end
70
+
71
+ end
72
+
73
+ end
74
+ end
@@ -0,0 +1,6 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+ require 'activerecord'
4
+ require 'with_properties/core'
5
+
6
+ ActiveRecord::Base.send(:include, WithProperties::Core)
@@ -0,0 +1,33 @@
1
+ require 'rake/testtask'
2
+
3
+ namespace :test do
4
+ desc "Run the with_properties tests"
5
+ Rake::TestTask.new(:with_properties) do |t|
6
+ t.libs << "test"
7
+ t.test_files = FileList['test/unit/*_test.rb']
8
+ t.verbose = true
9
+ end
10
+ end
11
+
12
+ desc "Run the tests"
13
+ task :default => ['test:with_properties']
14
+
15
+ namespace :with_properties do
16
+ gem_spec = Gem::Specification.new do |gem_spec|
17
+ gem_spec.name = "with_properties"
18
+ gem_spec.version = "0.1"
19
+ gem_spec.summary = "Add extra properties to individual STI subclasses (ActiveRecord)."
20
+ gem_spec.email = "frank.oxener@dovadi.com"
21
+ gem_spec.homepage = "http://github.com/dovadi/with_properties"
22
+ gem_spec.description = "Add extra properties to individual STI subclasses (ActiveRecord)"
23
+ gem_spec.authors = ["Frank Oxener"]
24
+ gem_spec.files = FileList["[A-Z]*", "{lib,tasks,test}/**/*"]
25
+ end
26
+
27
+ desc "Generate a gemspec file"
28
+ task :gemspec do
29
+ File.open("#{gem_spec.name}.gemspec", 'w') do |f|
30
+ f.write gem_spec.to_yaml
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ Factory.sequence :email do |n|
2
+ "person#{n}@example.com"
3
+ end
4
+
5
+ Factory.sequence :name do |n|
6
+ "name-#{n}"
7
+ end
8
+
9
+ Factory.define :person do |person|
10
+ person.email {Factory.next :email}
11
+ person.name {Factory.next :name }
12
+ end
13
+
14
+ Factory.define :customer do |customer|
15
+ end
16
+
17
+ Factory.define :manager do |customer|
18
+ end
19
+
20
+ Factory.define :employee do |customer|
21
+ end
22
+
23
+ Factory.define :customer_detail do |customer_detail|
24
+ customer_detail.phone ""
25
+ end
26
+
27
+ Factory.define :employee_property do |employee_property|
28
+ end
@@ -0,0 +1,6 @@
1
+ class Customer < Person
2
+ with_properties :customer_detail
3
+
4
+ validates_format_of :phone, :with=>/^\d{10}$/, :allow_blank=>true, :message=>"Only and exactly 10 numbers [0-9]"
5
+ validates_length_of :phone, :within => 10..10, :allow_blank=>true
6
+ end
@@ -0,0 +1,2 @@
1
+ class CustomerDetail < ActiveRecord::Base
2
+ end
@@ -0,0 +1,3 @@
1
+ class Employee < Person
2
+ with_properties :employee_property
3
+ end
@@ -0,0 +1,2 @@
1
+ class EmployeeProperty < ActiveRecord::Base
2
+ end
@@ -0,0 +1,2 @@
1
+ class Manager < Person
2
+ end
@@ -0,0 +1,2 @@
1
+ class Person < ActiveRecord::Base
2
+ end
@@ -0,0 +1,110 @@
1
+ # Don't change this file!
2
+ # Configure your app in config/environment.rb and config/environments/*.rb
3
+
4
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
+
6
+ module Rails
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ preinitialize
11
+ pick_boot.run
12
+ end
13
+ end
14
+
15
+ def booted?
16
+ defined? Rails::Initializer
17
+ end
18
+
19
+ def pick_boot
20
+ (vendor_rails? ? VendorBoot : GemBoot).new
21
+ end
22
+
23
+ def vendor_rails?
24
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
25
+ end
26
+
27
+ def preinitialize
28
+ load(preinitializer_path) if File.exist?(preinitializer_path)
29
+ end
30
+
31
+ def preinitializer_path
32
+ "#{RAILS_ROOT}/config/preinitializer.rb"
33
+ end
34
+ end
35
+
36
+ class Boot
37
+ def run
38
+ load_initializer
39
+ Rails::Initializer.run(:set_load_path)
40
+ end
41
+ end
42
+
43
+ class VendorBoot < Boot
44
+ def load_initializer
45
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
+ Rails::Initializer.run(:install_gem_spec_stubs)
47
+ Rails::GemDependency.add_frozen_gem_path
48
+ end
49
+ end
50
+
51
+ class GemBoot < Boot
52
+ def load_initializer
53
+ self.class.load_rubygems
54
+ load_rails_gem
55
+ require 'initializer'
56
+ end
57
+
58
+ def load_rails_gem
59
+ if version = self.class.gem_version
60
+ gem 'rails', version
61
+ else
62
+ gem 'rails'
63
+ end
64
+ rescue Gem::LoadError => load_error
65
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66
+ exit 1
67
+ end
68
+
69
+ class << self
70
+ def rubygems_version
71
+ Gem::RubyGemsVersion rescue nil
72
+ end
73
+
74
+ def gem_version
75
+ if defined? RAILS_GEM_VERSION
76
+ RAILS_GEM_VERSION
77
+ elsif ENV.include?('RAILS_GEM_VERSION')
78
+ ENV['RAILS_GEM_VERSION']
79
+ else
80
+ parse_gem_version(read_environment_rb)
81
+ end
82
+ end
83
+
84
+ def load_rubygems
85
+ require 'rubygems'
86
+ min_version = '1.3.1'
87
+ unless rubygems_version >= min_version
88
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
+ exit 1
90
+ end
91
+
92
+ rescue LoadError
93
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94
+ exit 1
95
+ end
96
+
97
+ def parse_gem_version(text)
98
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99
+ end
100
+
101
+ private
102
+ def read_environment_rb
103
+ File.read("#{RAILS_ROOT}/config/environment.rb")
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ # All that for this:
110
+ Rails.boot!
@@ -0,0 +1,11 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
+
4
+ # Warning: The database defined as "test" will be erased and
5
+ # re-generated from your development database when you run "rake".
6
+ # Do not set this db to the same as development or production.
7
+ test:
8
+ adapter: sqlite3
9
+ database: db/test.sqlite3
10
+ pool: 5
11
+ timeout: 5000
@@ -0,0 +1,12 @@
1
+ # Be sure to restart your server when you modify this file
2
+
3
+ # Specifies gem version of Rails to use when vendor/rails is not present
4
+ RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
5
+
6
+ # Bootstrap the Rails environment, frameworks, and default configuration
7
+ require File.join(File.dirname(__FILE__), 'boot')
8
+
9
+ Rails::Initializer.run do |config|
10
+ config.action_controller.session = { :key => "_myapp_session",
11
+ :secret => "some secret phrase which is longer than 30 characters" }
12
+ end
File without changes
File without changes
@@ -0,0 +1,15 @@
1
+ class CreatePeople < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :people do |t|
4
+ t.string :type
5
+ t.string :name
6
+ t.string :email
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :people
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class CreateEmployeeProperties < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :employee_properties do |t|
4
+ t.integer :reports_to
5
+ t.string :department
6
+ t.integer :employee_id
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :employee_properties
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ class CreateCustomerDetails < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :customer_details do |t|
4
+ t.string :phone
5
+ t.integer :customer_id
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :customer_details
13
+ end
14
+ end
@@ -0,0 +1,37 @@
1
+ # This file is auto-generated from the current state of the database. Instead of editing this file,
2
+ # please use the migrations feature of Active Record to incrementally modify your database, and
3
+ # then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your database schema. If you need
6
+ # to create the application database on another system, you should be using db:schema:load, not running
7
+ # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
8
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
9
+ #
10
+ # It's strongly recommended to check this file into your version control system.
11
+
12
+ ActiveRecord::Schema.define(:version => 20090820110621) do
13
+
14
+ create_table "customer_details", :force => true do |t|
15
+ t.string "phone"
16
+ t.integer "customer_id"
17
+ t.datetime "created_at"
18
+ t.datetime "updated_at"
19
+ end
20
+
21
+ create_table "employee_properties", :force => true do |t|
22
+ t.integer "reports_to"
23
+ t.string "department"
24
+ t.integer "employee_id"
25
+ t.datetime "created_at"
26
+ t.datetime "updated_at"
27
+ end
28
+
29
+ create_table "people", :force => true do |t|
30
+ t.string "type"
31
+ t.string "name"
32
+ t.string "email"
33
+ t.datetime "created_at"
34
+ t.datetime "updated_at"
35
+ end
36
+
37
+ end
Binary file
@@ -0,0 +1,15 @@
1
+ # Using the STI example from 'Agile Web development with Rails' Second Edition - 18.4
2
+
3
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
4
+ $: << File.join(File.dirname(__FILE__))
5
+
6
+ ENV["RAILS_ENV"] = "test"
7
+
8
+ require 'with_properties'
9
+ require File.expand_path(File.dirname(__FILE__) + "/rails_root/config/environment")
10
+ require 'test_help'
11
+ require 'shoulda'
12
+ require 'factory_girl'
13
+ require 'test/factories/general'
14
+ require 'set'
15
+
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class CustomerDetailTest < Test::Unit::TestCase
4
+ context 'A customer_detail' do
5
+ setup do
6
+ @customer_detail = Factory(:customer_detail)
7
+ end
8
+
9
+ should 'be valid' do
10
+ assert_valid @customer_detail
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,70 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class CustomerTest < Test::Unit::TestCase
4
+ context 'A customer with_properties' do
5
+ setup do
6
+ @customer = Factory(:customer)
7
+ @customer.customer_detail=Factory(:customer_detail, :phone=>'0222311304', :customer_id=>@customer)
8
+ @customer.save
9
+ end
10
+
11
+ should_have_one :customer_detail
12
+ should_have_class_methods :with_properties
13
+ should_have_instance_methods :save_properties
14
+ should_have_instance_methods :phone
15
+ should_have_instance_methods :phone=
16
+
17
+ should 'be valid' do
18
+ assert_valid @customer
19
+ end
20
+
21
+ should 'return its phone number (based on customer properties)' do
22
+ assert_equal '0222311304', @customer.phone
23
+ end
24
+
25
+ should 'create a customer with its properties' do
26
+ customer = Customer.create(:name =>'Dovadi', :email=>'frank@dovadi.com', :phone=>'0649416406')
27
+ assert_valid customer
28
+ assert_valid customer.customer_detail
29
+ end
30
+
31
+ should 'update attributes with a property' do
32
+ customer = Customer.create(:name =>'Dovadi', :email=>'frank@dovadi.com')
33
+ customer.update_attributes(:phone=>'0222300100')
34
+ customer.reload
35
+ assert_equal '0222300100', customer.phone
36
+ end
37
+
38
+ should 'update one attribute with a property' do
39
+ customer = Customer.create(:name =>'Dovadi', :email=>'frank@dovadi.com')
40
+ customer.update_attribute(:phone,'0222300200')
41
+ customer.reload
42
+ assert_equal '0222300200', customer.phone
43
+ end
44
+ end
45
+
46
+ context 'Validations of a property (through customer_detail)' do
47
+ setup do
48
+ @customer = Factory(:customer)
49
+ @customer.customer_detail=Factory(:customer_detail, :phone=>'0222311304', :customer_id=>@customer)
50
+ @customer.save
51
+ end
52
+ should_ensure_length_in_range :phone, 10..10
53
+
54
+ should "validate length of phone (which is a property through customer_detail)" do
55
+ @customer.phone="012345678"
56
+ assert !@customer.save
57
+ end
58
+
59
+ should "validate format of phone (which is a property through customer_detail)" do
60
+ @customer.phone="012345678A"
61
+ assert !@customer.save
62
+ end
63
+
64
+ should "allow blank a phone number (which is a property through customer_detail)" do
65
+ @customer.phone=""
66
+ assert @customer.save
67
+ end
68
+ end
69
+
70
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class EmployeePropertyTest < Test::Unit::TestCase
4
+ context 'A employee_property' do
5
+ setup do
6
+ @employee_property = Factory(:employee_property)
7
+ end
8
+
9
+ should 'be valid' do
10
+ assert_valid @employee_property
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,48 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class EmployeeTest < Test::Unit::TestCase
4
+ context 'An employee with_properties' do
5
+ setup do
6
+ @employee = Factory(:employee)
7
+ @employee.employee_property=Factory(:employee_property, :reports_to=>123, :department=>'Sales', :employee_id=>@employee)
8
+ @employee.save
9
+ end
10
+
11
+ should_have_one :employee_property
12
+ should_have_class_methods :with_properties
13
+ should_have_instance_methods :save_properties
14
+ should_have_instance_methods :department
15
+ should_have_instance_methods :department=
16
+ should_have_instance_methods :reports_to
17
+ should_have_instance_methods :reports_to=
18
+
19
+ should 'be valid' do
20
+ assert_valid @employee
21
+ end
22
+
23
+ should 'return its department (based on employee properties)' do
24
+ assert_equal 'Sales', @employee.department
25
+ end
26
+
27
+ should 'create a employee with its properties' do
28
+ employee = Employee.create(:name =>'Dovadi', :email=>'frank@dovadi.com', :reports_to=>55, :department=>'Customer support')
29
+ assert_valid employee
30
+ assert_valid employee.employee_property
31
+ end
32
+
33
+ should 'update attributes with a property' do
34
+ employee = Employee.create(:name =>'Dovadi', :email=>'frank@dovadi.com')
35
+ employee.update_attributes(:reports_to=>100)
36
+ employee.reload
37
+ assert_equal 100, employee.reports_to
38
+ end
39
+
40
+ should 'update one attribute with a property' do
41
+ employee = Employee.create(:name =>'Dovadi', :email=>'frank@dovadi.com')
42
+ employee.update_attribute(:reports_to,200)
43
+ employee.reload
44
+ assert_equal 200, employee.reports_to
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ManagerTest < Test::Unit::TestCase
4
+ context 'A manager' do
5
+ setup do
6
+ @manager = Factory(:manager)
7
+ end
8
+
9
+ should 'be valid' do
10
+ assert_valid @manager
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class PersonTest < Test::Unit::TestCase
4
+ context 'A person' do
5
+ setup do
6
+ @person = Factory(:person)
7
+ end
8
+
9
+ should 'be valid' do
10
+ assert_valid @person
11
+ end
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dovadi-with_properties
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.1"
5
+ platform: ruby
6
+ authors:
7
+ - Frank Oxener
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-19 15:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Add extra properties to individual STI subclasses (ActiveRecord)
17
+ email: frank.oxener@dovadi.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - History.txt
26
+ - Manifest.txt
27
+ - Rakefile
28
+ - README.textile
29
+ - lib/with_properties
30
+ - lib/with_properties/core.rb
31
+ - lib/with_properties.rb
32
+ - tasks/with_properties.rake
33
+ - test/factories
34
+ - test/factories/general.rb
35
+ - test/rails_root
36
+ - test/rails_root/app
37
+ - test/rails_root/app/models
38
+ - test/rails_root/app/models/customer.rb
39
+ - test/rails_root/app/models/customer_detail.rb
40
+ - test/rails_root/app/models/employee.rb
41
+ - test/rails_root/app/models/employee_property.rb
42
+ - test/rails_root/app/models/manager.rb
43
+ - test/rails_root/app/models/person.rb
44
+ - test/rails_root/config
45
+ - test/rails_root/config/boot.rb
46
+ - test/rails_root/config/database.yml
47
+ - test/rails_root/config/environment.rb
48
+ - test/rails_root/config/environments
49
+ - test/rails_root/config/environments/test.rb
50
+ - test/rails_root/config/routes.rb
51
+ - test/rails_root/db
52
+ - test/rails_root/db/migrate
53
+ - test/rails_root/db/migrate/20090820105348_create_people.rb
54
+ - test/rails_root/db/migrate/20090820105521_create_employee_properties.rb
55
+ - test/rails_root/db/migrate/20090820110621_create_customer_details.rb
56
+ - test/rails_root/db/schema.rb
57
+ - test/rails_root/db/test.sqlite3
58
+ - test/test_helper.rb
59
+ - test/unit
60
+ - test/unit/customer_detail_test.rb
61
+ - test/unit/customer_test.rb
62
+ - test/unit/employee_property_test.rb
63
+ - test/unit/employee_test.rb
64
+ - test/unit/manager_test.rb
65
+ - test/unit/person_test.rb
66
+ has_rdoc: false
67
+ homepage: http://github.com/dovadi/with_properties
68
+ licenses:
69
+ post_install_message:
70
+ rdoc_options: []
71
+
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "0"
85
+ version:
86
+ requirements: []
87
+
88
+ rubyforge_project:
89
+ rubygems_version: 1.3.5
90
+ signing_key:
91
+ specification_version: 2
92
+ summary: Add extra properties to individual STI subclasses (ActiveRecord).
93
+ test_files: []
94
+