better way of declaring a hosting env

This commit is contained in:
Didier Lafforgue 2012-02-18 15:55:20 +01:00
parent ffee024a96
commit 8f1ac5968f
2 changed files with 11 additions and 4 deletions

View File

@ -93,9 +93,16 @@ module Locomotive
end
def self.enable_hosting
if (!Rails.env.test? && !Rails.env.development?) && !self.config.hosting.blank? && self.respond_to?(:"enable_#{self.config.hosting}")
self.send(:"enable_#{self.config.hosting}")
end
return if Rails.env.test? || Rails.env.development? || self.config.hosting.blank?
target = self.config.hosting[:target]
method = :"enable_#{target}"
self.send(method) if self.respond_to?(method)
# if (!Rails.env.test? && !Rails.env.development?) && !self.config.hosting.blank? && self.respond_to?(:"enable_#{self.config.hosting}")
# self.send(:"enable_#{self.config.hosting}")
# end
end
def self.define_subdomain_and_domains_options

View File

@ -15,7 +15,7 @@ describe Locomotive::Configuration do
it 'calls the hosting enabler if provided' do
Rails.env.stubs(:test?).returns(false)
Locomotive.expects(:enable_bushido).once
Locomotive.config.hosting = :bushido
Locomotive.config.hosting = { :target => :bushido }
Locomotive.enable_hosting
end