let app_file default to the file subclassing Sinatra::Base in modular apps
This commit is contained in:
parent
cf0ed2b0ec
commit
db761b8b07
3
CHANGES
3
CHANGES
|
@ -10,6 +10,9 @@
|
||||||
explicitly to prevent that behavior. (Magnus Holm, Ryan Tomayko, Konstantin
|
explicitly to prevent that behavior. (Magnus Holm, Ryan Tomayko, Konstantin
|
||||||
Haase)
|
Haase)
|
||||||
|
|
||||||
|
* `settings.app_file` now defaults to the file subclassing `Sinatra::Base` in
|
||||||
|
modular applications. (Konstantin Haase)
|
||||||
|
|
||||||
* Set up `Rack::Logger` or `Rack::NullLogger` depending on whether logging
|
* Set up `Rack::Logger` or `Rack::NullLogger` depending on whether logging
|
||||||
was enabled or not. Also, expose that logger with the `logger` helper
|
was enabled or not. Also, expose that logger with the `logger` helper
|
||||||
method. (Konstantin Haase)
|
method. (Konstantin Haase)
|
||||||
|
|
|
@ -1382,7 +1382,7 @@ different default settings:
|
||||||
|
|
||||||
Setting Classic Modular
|
Setting Classic Modular
|
||||||
|
|
||||||
app_file file loading sinatra nil
|
app_file file loading sinatra file subclassing Sinatra::Base
|
||||||
run $0 == app_file false
|
run $0 == app_file false
|
||||||
logging true false
|
logging true false
|
||||||
method_override true false
|
method_override true false
|
||||||
|
|
|
@ -1310,6 +1310,7 @@ module Sinatra
|
||||||
|
|
||||||
def inherited(subclass)
|
def inherited(subclass)
|
||||||
subclass.reset!
|
subclass.reset!
|
||||||
|
subclass.set :app_file, caller_files.first unless subclass.app_file?
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1471,6 +1472,7 @@ module Sinatra
|
||||||
set :method_override, true
|
set :method_override, true
|
||||||
set :run, Proc.new { ! test? }
|
set :run, Proc.new { ! test? }
|
||||||
set :session_secret, Proc.new { super() unless development? }
|
set :session_secret, Proc.new { super() unless development? }
|
||||||
|
set :app_file, nil
|
||||||
|
|
||||||
def self.register(*extensions, &block) #:nodoc:
|
def self.register(*extensions, &block) #:nodoc:
|
||||||
added_methods = extensions.map {|m| m.public_instance_methods }.flatten
|
added_methods = extensions.map {|m| m.public_instance_methods }.flatten
|
||||||
|
|
|
@ -3,10 +3,10 @@ require File.dirname(__FILE__) + '/helper'
|
||||||
class SettingsTest < Test::Unit::TestCase
|
class SettingsTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@base = Sinatra.new(Sinatra::Base)
|
@base = Sinatra.new(Sinatra::Base)
|
||||||
@base.set :environment, :foo
|
@base.set :environment => :foo, :app_file => nil
|
||||||
|
|
||||||
@application = Sinatra.new(Sinatra::Application)
|
@application = Sinatra.new(Sinatra::Application)
|
||||||
@application.set :environment, :foo
|
@application.set :environment => :foo, :app_file => nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets settings to literal values' do
|
it 'sets settings to literal values' do
|
||||||
|
@ -358,9 +358,13 @@ class SettingsTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'app_file' do
|
describe 'app_file' do
|
||||||
it 'is nil' do
|
it 'is nil for base classes' do
|
||||||
assert_nil @base.app_file
|
assert_nil Sinatra::Base.app_file
|
||||||
assert_nil @application.app_file
|
assert_nil Sinatra::Application.app_file
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'defaults to the file subclassing' do
|
||||||
|
assert_equal __FILE__, Sinatra.new.app_file
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue