Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Commit

Permalink
Recognize a Rails 3 app.
Browse files Browse the repository at this point in the history
Closes #47, closes #48.
  • Loading branch information
alloy committed Jun 11, 2010
1 parent ff77189 commit 3e30026
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/models/passenger_application.rb
Expand Up @@ -214,9 +214,11 @@ def blank?(value)
value.nil? || value.empty?
end

RAILS_APP_REGEXP = /Rails::Initializer|Application\.initialize!/

def check_application_type
env_file = File.join(@path, 'config', 'environment.rb')
(File.exist?(env_file) and File.read(env_file) =~ /Rails::Initializer/) ? RAILS : RACK
(File.exist?(env_file) and File.read(env_file) =~ RAILS_APP_REGEXP) ? RAILS : RACK
end

def load_data_from_vhost_file(file = config_path)
Expand Down
6 changes: 6 additions & 0 deletions test/passenger_application_test.rb
Expand Up @@ -104,6 +104,12 @@ def after_setup
@passenger_app.application_type.should == PassengerApplication::RAILS
end

it "should recognize it as a Rails application if there's a config/environment.rb file, which contains `Application.initialize!'" do
File.stubs(:exist?).with('/Users/het-manfred/rails code/blog/config/environment.rb').returns(true)
File.stubs(:read).with('/Users/het-manfred/rails code/blog/config/environment.rb').returns("# Initialize the rails application\nRoomTemperature::Application.initialize!\n")
@passenger_app.application_type.should == PassengerApplication::RAILS
end

it "should recognize it as a Rack application if there's a config/environment.rb file, but doesn't contain the string `Rails::Initializer'" do
File.stubs(:exist?).with('/Users/het-manfred/rails code/blog/config/environment.rb').returns(true)
File.stubs(:read).with('/Users/het-manfred/rails code/blog/config/environment.rb').returns("Foo bar")
Expand Down

0 comments on commit 3e30026

Please sign in to comment.