Skip to content

Commit

Permalink
rename methodoverride setting to method_override
Browse files Browse the repository at this point in the history
for consistancy with others settings which are all snake case
  • Loading branch information
sr committed Jan 29, 2010
1 parent f942ad7 commit e153415
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
11 changes: 8 additions & 3 deletions lib/sinatra/base.rb
Expand Up @@ -951,7 +951,7 @@ def new(*args, &bk)
builder = Rack::Builder.new
builder.use Rack::Session::Cookie if sessions?
builder.use Rack::CommonLogger if logging?
builder.use Rack::MethodOverride if methodoverride?
builder.use Rack::MethodOverride if method_override?
builder.use ShowExceptions if show_exceptions?
middleware.each { |c,a,b| builder.use(c, *a, &b) }

Expand Down Expand Up @@ -1030,7 +1030,12 @@ def caller_locations
set :clean_trace, true
set :sessions, false
set :logging, false
set :methodoverride, false
set :method_override, false

class << self
alias_method :methodoverride?, :method_override?
alias_method :methodoverride=, :method_override=
end

set :run, false # start server via at-exit hook?
set :running, false # is the built-in server running now?
Expand Down Expand Up @@ -1099,7 +1104,7 @@ class Application < Base
set :dump_errors, true
set :sessions, false
set :logging, Proc.new { ! test? }
set :methodoverride, true
set :method_override, true
set :run, Proc.new { ! test? }
set :static, true

Expand Down
13 changes: 9 additions & 4 deletions test/settings_test.rb
Expand Up @@ -93,28 +93,33 @@ def foo=(value)
assert !@base.bar
end


it 'is accessible from instances via #settings' do
assert_equal :foo, @base.new.settings.environment
end

describe 'methodoverride' do
it 'is disabled on Base' do
assert ! @base.methodoverride?
assert ! @base.method_override?
end

it 'is enabled on Application' do
assert @application.methodoverride?
assert @application.method_override?
end

it 'enables MethodOverride middleware' do
@base.set :methodoverride, true
@base.set :method_override, true
@base.put('/') { 'okay' }
@app = @base
post '/', {'_method'=>'PUT'}, {}
assert_equal 200, status
assert_equal 'okay', body
end

it 'is backward compatible with methodoverride' do
assert ! @base.methodoverride?
@base.enable :methodoverride
assert @base.methodoverride?
end
end

describe 'clean_trace' do
Expand Down

1 comment on commit e153415

@akahn
Copy link

@akahn akahn commented on e153415 Jan 30, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Win.

Please sign in to comment.