foodsoft/spec/support/shared_database.rb
Philipp Rothmann fb2b4d8a8a chore: rubocop
chore: fix api test conventions

chore: rubocop -A spec/

chore: more rubocop -A

fix failing test

rubocop fixes

removes helper methods that are in my opinion dead code

more rubocop fixes

rubocop -a --auto-gen-config
2023-06-09 17:35:05 +02:00

20 lines
747 B
Ruby

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.
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
belongs_to :supplier, class_name: 'SharedSupplier'
alias_attribute :number, :order_number
alias_attribute :updated_on, :updated_at
def category
ArticleCategory.where(id: article_category_id).first
end
def self.find_by_number(n)
find_by_order_number(n)
end
end
end