Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## 1) Update database.yml to support pp_#{RAILS_ENV}
- # In general, we want to have the database connection name followed
- # by _, then the RAILS_ENV
- #
- # #{name}_#{RAILS_ENV}
- #
- # So for "pp", we could have these:
- pp_test:
- adapter: mysql
- database: pp_test
- username: user
- password: pass
- pp_development:
- adapter: mysql
- database: pp_dev
- username: user
- password: pass
- # During the deployment, we really don't need these two. But there
- # here for completeness.
- pp_stage:
- adapter: mysql
- database: pp_stage
- username: user
- password: pass
- pp_production:
- adapter: mysql
- database: pp_production
- username: user
- password: pass
- ## 2) Extend/modify /lib/product_pricing_database_connection.rb to be RAILS_ENV aware
- class DummyProductPricingModel < ActiveRecord::Base
- # Add logic here to connect to the appropriate environment
- # using the pp_#{RAILS_ENV} connections in database.yml
- establish_connection ":pp_#{RAILS_ENV}"
- end
- ## 3) Update fixtures to support connecting and using the new database
- describe ... do
- fixtures :personas, "pp:products"
- it "should ..." do
- # This is the standard, it uses the "test" database
- # connection and fixtures in ./spec/fixtures/personas.yml
- social_persona = personas(:social_persona)
- # This is the enhanced fixtures, it uses the "pp_test" database
- # for testing/specs. The fixtures are in ./spec/fixtures/pp/products.yml
- # NOTE: we are replacing the : with an _ for ruby syntax
- ipod_from_pp = pp_products(:ipod_from_pp)
- end
- end
Add Comment
Please, Sign In to add comment