foodsoft/spec/support/shared_database.rb

21 lines
746 B
Ruby
Raw Normal View History

ActiveSupport.on_load(:after_initialize) do
# We simulate the shared database by pointing to our own database.
# This allows running tests without additional database setup.
# But take care when designing tests using the shared database.
2014-11-21 14:37:56 +01:00
SharedSupplier.establish_connection Rails.env.to_sym
SharedArticle.establish_connection Rails.env.to_sym
# hack for different structure of shared database
SharedArticle.class_eval do
2014-11-21 14:37:56 +01:00
belongs_to :supplier, class_name: 'SharedSupplier'
alias_attribute :number, :order_number
alias_attribute :updated_on, :updated_at
def category
2014-11-21 14:37:56 +01:00
ArticleCategory.where(id: article_category_id).first
end
def self.find_by_number(n)
find_by_order_number(n)
end
end
end