1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Make debug_exception_response_format config depends on api_only when is not set

This commit is contained in:
Jorge Bejar 2015-12-04 18:05:45 -03:00
parent 2430268f18
commit a0343d11f1
2 changed files with 37 additions and 2 deletions

View file

@ -16,7 +16,7 @@ module Rails
:railties_order, :relative_url_root, :secret_key_base, :secret_token, :railties_order, :relative_url_root, :secret_key_base, :secret_token,
:ssl_options, :public_file_server, :ssl_options, :public_file_server,
:session_options, :time_zone, :reload_classes_only_on_change, :session_options, :time_zone, :reload_classes_only_on_change,
:beginning_of_week, :filter_redirect, :debug_exception_response_format, :x :beginning_of_week, :filter_redirect, :x
attr_writer :log_level attr_writer :log_level
attr_reader :encoding, :api_only, :static_cache_control attr_reader :encoding, :api_only, :static_cache_control
@ -52,7 +52,7 @@ module Rails
@secret_token = nil @secret_token = nil
@secret_key_base = nil @secret_key_base = nil
@api_only = false @api_only = false
@debug_exception_response_format = :default @debug_exception_response_format = nil
@x = Custom.new @x = Custom.new
end end
@ -96,6 +96,16 @@ module Rails
def api_only=(value) def api_only=(value)
@api_only = value @api_only = value
generators.api_only = value generators.api_only = value
@debug_exception_response_format ||= :api
end
def debug_exception_response_format
@debug_exception_response_format || :default
end
def debug_exception_response_format=(value)
@debug_exception_response_format = value
end end
def paths def paths

View file

@ -1408,5 +1408,30 @@ module ApplicationTests
Rails.application.load_generators Rails.application.load_generators
assert Rails.configuration.api_only assert Rails.configuration.api_only
end end
test "debug_exception_response_format is :api by default if only_api is enabled" do
add_to_config <<-RUBY
config.api_only = true
RUBY
app 'development'
assert_equal :api, Rails.configuration.debug_exception_response_format
end
test "debug_exception_response_format can be override" do
add_to_config <<-RUBY
config.api_only = true
RUBY
app_file 'config/environments/development.rb', <<-RUBY
Rails.application.configure do
config.debug_exception_response_format = :default
end
RUBY
app 'development'
assert_equal :default, Rails.configuration.debug_exception_response_format
end
end end
end end