This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Initializer configuration overrides Railtie configuration if set

  • Loading branch information...
Daniel Barron authored and joshuaclayton committed Aug 23, 2010
1 parent 3da3df7 commit 15358af455b22d2a3c2bbbabbde03b218a6fc4ee
Showing with 25 additions and 3 deletions.
  1. +21 −0 features/rails.feature
  2. +1 −0 features/step_definitions/rails_application_steps.rb
  3. +3 −3 lib/hoptoad_notifier/railtie.rb
View
@@ -33,6 +33,27 @@ Feature: Install the Gem in a Rails application
And I run the hoptoad generator with ""
Then I should receive a Hoptoad notification
+ Scenario: Configuration within initializer isn't overridden by Railtie
+ When I generate a new Rails application
+ And I configure the Hoptoad shim
+ And I configure my application to require the "hoptoad_notifier" gem
+ And I run the hoptoad generator with "-k myapikey"
+ Then the command should have run successfully
+ When I configure the notifier to use the following configuration lines:
+ """
+ config.api_key = "myapikey"
+ config.project_root = "argle/bargle"
+ """
+ And I define a response for "TestController#index":
+ """
+ session[:value] = "test"
+ raise RuntimeError, "some message"
+ """
+ And I route "/test/index" to "test#index"
+ And I perform a request to "http://example.com:123/test/index?param=value"
+ Then I should receive the following Hoptoad notification:
+ | project-root | argle/bargle |
+
Scenario: Try to install without an api key
When I generate a new Rails application
And I configure my application to require the "hoptoad_notifier" gem
@@ -217,6 +217,7 @@ def rails_non_initializer_hoptoad_config_file
doc.should have_content('//component', hash['component']) if hash['component']
doc.should have_content('//action', hash['action']) if hash['action']
+ doc.should have_content('//server-environment/project-root', hash['project-root']) if hash['project-root']
if hash['session']
session_key, session_value = hash['session'].split(': ')
@@ -13,9 +13,9 @@ class Railtie < Rails::Railtie
config.after_initialize do
HoptoadNotifier.configure(true) do |config|
- config.logger = Rails.logger
- config.environment_name = Rails.env
- config.project_root = Rails.root
+ config.logger ||= Rails.logger
+ config.environment_name ||= Rails.env
+ config.project_root ||= Rails.root
config.framework = "Rails: #{::Rails::VERSION::STRING}"
end

0 comments on commit 15358af

Please sign in to comment.