diff --git a/config/initializers/cost_centers.rb b/config/initializers/cost_centers.rb index 1714eda..4c8c950 100644 --- a/config/initializers/cost_centers.rb +++ b/config/initializers/cost_centers.rb @@ -13,9 +13,14 @@ def load_from_s3(bucket, key) return data end +def load_dummy_cost_centres() + File.read(File.join(Rails.root, 'config', 'cost_centre_fixture.csv')) +end + def get_cost_centre_data() - if Rails.env.development? - return File.read(File.join(Rails.root, 'config', 'cost_centre_fixture.csv')) + # dont load the cost centers from s3 if were not running the server or we're not in RAILS_ENV != production + if Rails.env.development? or !defined?(Rails::Server) + return load_dummy_cost_centres() end begin @@ -28,4 +33,5 @@ def get_cost_centre_data() end end + COST_CENTRES = CostCentreReader.new(get_cost_centre_data())