Guest User

Untitled

a guest
Mar 16th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. ## 1) Update database.yml to support pp_#{RAILS_ENV}
  2.  
  3. # In general, we want to have the database connection name followed
  4. # by _, then the RAILS_ENV
  5. #
  6. # #{name}_#{RAILS_ENV}
  7. #
  8. # So for "pp", we could have these:
  9. pp_test:
  10. adapter: mysql
  11. database: pp_test
  12. username: user
  13. password: pass
  14.  
  15. pp_development:
  16. adapter: mysql
  17. database: pp_dev
  18. username: user
  19. password: pass
  20.  
  21. # During the deployment, we really don't need these two. But there
  22. # here for completeness.
  23. pp_stage:
  24. adapter: mysql
  25. database: pp_stage
  26. username: user
  27. password: pass
  28.  
  29. pp_production:
  30. adapter: mysql
  31. database: pp_production
  32. username: user
  33. password: pass
  34.  
  35. ## 2) Extend/modify /lib/product_pricing_database_connection.rb to be RAILS_ENV aware
  36.  
  37. class DummyProductPricingModel < ActiveRecord::Base
  38. # Add logic here to connect to the appropriate environment
  39. # using the pp_#{RAILS_ENV} connections in database.yml
  40. establish_connection ":pp_#{RAILS_ENV}"
  41. end
  42.  
  43. ## 3) Update fixtures to support connecting and using the new database
  44.  
  45. describe ... do
  46.  
  47. fixtures :personas, "pp:products"
  48.  
  49. it "should ..." do
  50.  
  51. # This is the standard, it uses the "test" database
  52. # connection and fixtures in ./spec/fixtures/personas.yml
  53. social_persona = personas(:social_persona)
  54.  
  55. # This is the enhanced fixtures, it uses the "pp_test" database
  56. # for testing/specs. The fixtures are in ./spec/fixtures/pp/products.yml
  57. # NOTE: we are replacing the : with an _ for ruby syntax
  58. ipod_from_pp = pp_products(:ipod_from_pp)
  59.  
  60. end
  61.  
  62. end
Add Comment
Please, Sign In to add comment