Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of the default_filters method #1781

Merged
merged 1 commit into from Oct 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -30,6 +30,7 @@ group :development do
gem "erubis", ">= 2.7.0"
gem "slim", ">= 1.3.0"
gem "builder", ">= 2.1.2"
gem "sass"
platforms :jruby do
gem "jruby-openssl"
end
Expand Down
1 change: 0 additions & 1 deletion padrino-core/lib/padrino-core/application.rb
Expand Up @@ -65,7 +65,6 @@ def reload!
reset_router!
Padrino.require_dependencies(settings.app_file, :force => true)
require_dependencies
default_filters
default_routes
default_errors
I18n.reload! if defined?(I18n)
Expand Down
11 changes: 0 additions & 11 deletions padrino-core/lib/padrino-core/application/application_setup.rb
Expand Up @@ -42,7 +42,6 @@ def default_configuration!
def setup_application!
return if @_configured
require_dependencies
default_filters
default_routes
default_errors
setup_locale
Expand Down Expand Up @@ -109,16 +108,6 @@ def setup_default_middleware(builder)
setup_application!
end

##
# This filter it's used for know the format of the request, and
# automatically set the content type.
#
def default_filters
before do
response['Content-Type'] = 'text/html;charset=utf-8' unless @_content_type
end
end

##
# We need to add almost __sinatra__ images.
#
Expand Down
4 changes: 2 additions & 2 deletions padrino-core/test/test_reloader_simple.rb
Expand Up @@ -79,7 +79,7 @@
get "/rand"
assert ok?
last_body = body
assert_equal 2, @app.filters[:before].size # one is ours the other is default_filter for content type
assert_equal 1, @app.filters[:before].size
assert_equal 1, @app.errors.size
assert_equal 2, @app.filters[:after].size # app + content-type + padrino-flash
assert_equal 0, @app.middleware.size
Expand All @@ -89,7 +89,7 @@
@app.reload!
get "/rand"
refute_equal last_body, body
assert_equal 2, @app.filters[:before].size # one is ours the other is default_filter for content type
assert_equal 1, @app.filters[:before].size
assert_equal 1, @app.errors.size
assert_equal 2, @app.filters[:after].size
assert_equal 0, @app.middleware.size
Expand Down
10 changes: 10 additions & 0 deletions padrino-helpers/test/test_rendering.rb
Expand Up @@ -691,4 +691,14 @@ class Application < Sinatra::Base
end
end
end

describe 'sinatra template helpers' do
it "should respect default_content_type option defined by sinatra" do
mock_app do
get(:index){ sass ".hey\n border: 0" }
end
get '/'
assert_equal "text/css;charset=utf-8", response['Content-Type']
end
end
end