2013-11-13 23:09:17 +01:00
|
|
|
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
|
2013-11-13 23:09:17 +01:00
|
|
|
# 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'
|
2013-11-13 23:09:17 +01:00
|
|
|
alias_attribute :number, :order_number
|
|
|
|
alias_attribute :updated_on, :updated_at
|
2014-05-21 14:12:38 +02:00
|
|
|
def category
|
2014-11-21 14:37:56 +01:00
|
|
|
ArticleCategory.where(id: article_category_id).first
|
2014-05-21 14:12:38 +02:00
|
|
|
end
|
2021-03-01 15:27:26 +01:00
|
|
|
|
2013-11-13 23:09:17 +01:00
|
|
|
def self.find_by_number(n)
|
|
|
|
find_by_order_number(n)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|