Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Fix the initializer syntax in the Rails 3 Railtie
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Morrison committed Jun 2, 2010
1 parent e646561 commit 9c4f29e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion SUPPORTED_RAILS_VERSIONS
Expand Up @@ -6,4 +6,4 @@
2.3.2
2.3.4
2.3.5
3.0.0.beta
3.0.0.beta3
2 changes: 1 addition & 1 deletion features/rails.feature
Expand Up @@ -22,7 +22,7 @@ Feature: Install the Gem in a Rails application
When I uninstall the "hoptoad_notifier" gem
And I install cached gems
And I run "rake hoptoad:test"
Then the command should have run successfully
Then I should see "** [Hoptoad] Success: Net::HTTPOK"
And I should receive two Hoptoad notifications

Scenario: Configure the notifier by hand
Expand Down
14 changes: 3 additions & 11 deletions features/step_definitions/rails_application_steps.rb
Expand Up @@ -4,22 +4,14 @@
@terminal.cd(TEMP_DIR)
version_string = ENV['RAILS_VERSION']

rails3 = version_string =~ /^3/

if rails3
rails_binary_gem = 'railties'
else
rails_binary_gem = 'rails'
end

load_rails = <<-RUBY
gem '#{rails_binary_gem}', '#{version_string}'; \
load Gem.bin_path('#{rails_binary_gem}', 'rails', '#{version_string}')
gem 'rails', '#{version_string}'; \
load Gem.bin_path('rails', 'rails', '#{version_string}')
RUBY

@terminal.run(%{ruby -rubygems -e "#{load_rails.strip!}" rails_root})
if rails_root_exists?
@terminal.echo("Generated a Rails #{rails_version} application")
@terminal.echo("Generated a Rails #{version_string} application")
else
raise "Unable to generate a Rails application:\n#{@terminal.output}"
end
Expand Down
2 changes: 1 addition & 1 deletion features/support/rails.rb
Expand Up @@ -14,7 +14,7 @@ def rails_uses_rack?
def rails_version
@rails_version ||= begin
if bundler_manages_gems?
rails_version = open(gemfile_path).read.match(/gem.*rails".*"(.+)"/)[1]
rails_version = open(gemfile_path).read.match(/gem.*rails["'].*["'](.+)["']/)[1]
else
environment_file = File.join(RAILS_ROOT, 'config', 'environment.rb')
rails_version = `grep RAILS_GEM_VERSION #{environment_file}`.match(/[\d.]+/)[0]
Expand Down
4 changes: 3 additions & 1 deletion lib/hoptoad_notifier/railtie.rb
Expand Up @@ -7,7 +7,9 @@ class Railtie < Rails::Railtie
require "hoptoad_notifier/rails3_tasks"
end

config.app_middleware.insert_after "::ActionDispatch::ShowExceptions", "HoptoadNotifier::Rack"
initializer "hoptoad.use_rack_middleware" do |app|
app.config.middleware.insert_after "::ActionDispatch::ShowExceptions", "HoptoadNotifier::Rack"
end

config.after_initialize do
HoptoadNotifier.configure(true) do |config|
Expand Down

0 comments on commit 9c4f29e

Please sign in to comment.