From ed439d0b08c5cad66e477af52639694c8f3d44f3 Mon Sep 17 00:00:00 2001 From: wvengen Date: Fri, 28 Mar 2014 12:52:11 +0100 Subject: [PATCH] use minimal app_config for tests --- lib/foodsoft_config.rb | 5 ++++- spec/app_config.yml | 33 +++++++++++++++++++++++++++++++++ spec/spec_helper.rb | 1 + 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 spec/app_config.yml diff --git a/lib/foodsoft_config.rb b/lib/foodsoft_config.rb index eb31b5cb..bbc37527 100644 --- a/lib/foodsoft_config.rb +++ b/lib/foodsoft_config.rb @@ -1,6 +1,9 @@ class FoodsoftConfig mattr_accessor :scope, :config - APP_CONFIG = YAML.load(File.read(File.join(Rails.root, "/config/app_config.yml"))) + APP_CONFIG_FILE = ENV['FOODSOFT_APP_CONFIG'] || 'config/app_config.yml' + # Rails.logger isn't ready yet - and we don't want to litter rspec invocation with this msg + puts "-> Loading app configuration from #{APP_CONFIG_FILE}" unless defined? RSpec + APP_CONFIG = YAML.load(File.read(File.expand_path(APP_CONFIG_FILE, Rails.root))) class << self diff --git a/spec/app_config.yml b/spec/app_config.yml new file mode 100644 index 00000000..1a3fc7cf --- /dev/null +++ b/spec/app_config.yml @@ -0,0 +1,33 @@ +# Minimal Foodsoft configuration +# +# Without those settings, Foodsoft may not even work. +# This file is used when running tests. When plugins would modify foodsoft behaviour +# and they are enabled in the sample configuration, there is stable base to test with. + +default: &defaults + multi_coop_install: false + default_scope: 'f' + + host: localhost + + name: FC Minimal + contact: + email: fc@minimal.test + + # true by default to keep compat with older installations, but test with false here + use_nick: false + + # do we really need the following ones? + price_markup: 5.0 + tax_default: 6.0 + email_sender: noreply@minimal.test + + +development: + <<: *defaults + +test: + <<: *defaults + +production: + <<: *defaults diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bba0b6b7..c27ce50f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,6 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' +ENV["FOODSOFT_APP_CONFIG"] ||= 'spec/app_config.yml' # load special foodsoft config require_relative 'support/coverage' # needs to be first require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails'