From: Tom Hughes Date: Fri, 19 Jul 2013 10:14:55 +0000 (+0100) Subject: Replace `:nothing => true` with `:text => ""` X-Git-Tag: live~4886 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/3880ac5de8150eef3cc5b26eb9814f5c1d681afa Replace `:nothing => true` with `:text => ""` Using `:nothing => true` confusingly actually causes a single space to be sent as the content by rails. --- diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 815270f02..5ee483ed4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -45,7 +45,7 @@ class ApplicationController < ActionController::Base if request.get? redirect_to :controller => 'user', :action => 'login', :referer => request.fullpath else - render :nothing => true, :status => :forbidden + render :text => "", :status => :forbidden end end end @@ -124,7 +124,7 @@ class ApplicationController < ActionController::Base flash[:error] = t('application.require_moderator.not_a_moderator') redirect_to :action => 'index' else - render :nothing => true, :status => :forbidden + render :text => "", :status => :forbidden end end end @@ -325,7 +325,7 @@ class ApplicationController < ActionController::Base begin yield rescue ActiveRecord::RecordNotFound => ex - render :nothing => true, :status => :not_found + render :text => "", :status => :not_found rescue LibXML::XML::Error, ArgumentError => ex report_error ex.message, :bad_request rescue ActiveRecord::RecordInvalid => ex @@ -405,7 +405,7 @@ class ApplicationController < ActionController::Base respond_to do |format| format.html { render :template => "user/no_such_user", :status => :not_found } - format.all { render :nothing => true, :status => :not_found } + format.all { render :text => "", :status => :not_found } end end diff --git a/app/controllers/changeset_controller.rb b/app/controllers/changeset_controller.rb index c7cb245f3..5575e47bf 100644 --- a/app/controllers/changeset_controller.rb +++ b/app/controllers/changeset_controller.rb @@ -55,7 +55,7 @@ class ChangesetController < ApplicationController changeset.set_closed_time_now changeset.save! - render :nothing => true + render :text => "" end ## @@ -243,7 +243,7 @@ class ChangesetController < ApplicationController render :text => changeset.to_xml, :mime_type => "text/xml" else - render :nothing => true, :status => :bad_request + render :text => "", :status => :bad_request end end diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index 08e00419d..e900733e4 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -127,7 +127,7 @@ class DiaryEntryController < ApplicationController @description = I18n.t('diary_entry.feed.user.description', :user => user.display_name) @link = "http://#{SERVER_URL}/user/#{user.display_name}/diary" else - render :nothing => true, :status => :not_found + render :text => "", :status => :not_found return end else diff --git a/app/controllers/old_controller.rb b/app/controllers/old_controller.rb index c23df70df..a542a9bde 100644 --- a/app/controllers/old_controller.rb +++ b/app/controllers/old_controller.rb @@ -39,7 +39,7 @@ class OldController < ApplicationController def version if @old_element.redacted? and not show_redactions? - render :nothing => true, :status => :forbidden + render :text => "", :status => :forbidden else response.last_modified = @old_element.timestamp @@ -66,7 +66,7 @@ class OldController < ApplicationController end # just return an empty 200 OK for success - render :nothing => true + render :text => "" end private diff --git a/app/controllers/relation_controller.rb b/app/controllers/relation_controller.rb index 0b989d11e..39021218f 100644 --- a/app/controllers/relation_controller.rb +++ b/app/controllers/relation_controller.rb @@ -45,7 +45,7 @@ class RelationController < ApplicationController relation.update_from new_relation, @user render :text => relation.version.to_s, :content_type => "text/plain" else - render :nothing => true, :status => :bad_request + render :text => "", :status => :bad_request end end @@ -56,7 +56,7 @@ class RelationController < ApplicationController relation.delete_with_history!(new_relation, @user) render :text => relation.version.to_s, :content_type => "text/plain" else - render :nothing => true, :status => :bad_request + render :text => "", :status => :bad_request end end @@ -125,7 +125,7 @@ class RelationController < ApplicationController render :text => doc.to_s, :content_type => "text/xml" else - render :nothing => true, :status => :gone + render :text => "", :status => :gone end end diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 622ebb1ce..dd7c2febe 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -32,13 +32,13 @@ class SearchController < ApplicationController if do_nodes response.headers['Error'] = "Searching of nodes is currently unavailable" - render :nothing => true, :status => :service_unavailable + render :text => "", :status => :service_unavailable return false end unless value response.headers['Error'] = "Searching for a key without value is currently unavailable" - render :nothing => true, :status => :service_unavailable + render :text => "", :status => :service_unavailable return false end diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index c4467159d..0725957bf 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -150,17 +150,17 @@ class TraceController < ApplicationController if trace.visible? and (trace.public? or (@user and @user == trace.user)) if Acl.no_trace_download(request.remote_ip) - render :nothing => true, :status => :forbidden + render :text => "", :status => :forbidden elsif request.format == Mime::XML send_file(trace.xml_file, :filename => "#{trace.id}.xml", :type => Mime::XML.to_s, :disposition => 'attachment') else send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => 'attachment') end else - render :nothing => true, :status => :not_found + render :text => "", :status => :not_found end rescue ActiveRecord::RecordNotFound - render :nothing => true, :status => :not_found + render :text => "", :status => :not_found end def edit @@ -177,10 +177,10 @@ class TraceController < ApplicationController end end else - render :nothing => true, :status => :forbidden + render :text => "", :status => :forbidden end rescue ActiveRecord::RecordNotFound - render :nothing => true, :status => :not_found + render :text => "", :status => :not_found end def delete @@ -193,13 +193,13 @@ class TraceController < ApplicationController flash[:notice] = t 'trace.delete.scheduled_for_deletion' redirect_to :action => :list, :display_name => @user.display_name else - render :nothing => true, :status => :not_found + render :text => "", :status => :not_found end else - render :nothing => true, :status => :forbidden + render :text => "", :status => :forbidden end rescue ActiveRecord::RecordNotFound - render :nothing => true, :status => :not_found + render :text => "", :status => :not_found end def georss @@ -234,13 +234,13 @@ class TraceController < ApplicationController expires_in 7.days, :private => !trace.public?, :public => trace.public? send_file(trace.large_picture_name, :filename => "#{trace.id}.gif", :type => 'image/gif', :disposition => 'inline') else - render :nothing => true, :status => :forbidden + render :text => "", :status => :forbidden end else - render :nothing => true, :status => :not_found + render :text => "", :status => :not_found end rescue ActiveRecord::RecordNotFound - render :nothing => true, :status => :not_found + render :text => "", :status => :not_found end def icon @@ -251,13 +251,13 @@ class TraceController < ApplicationController expires_in 7.days, :private => !trace.public?, :public => trace.public? send_file(trace.icon_picture_name, :filename => "#{trace.id}_icon.gif", :type => 'image/gif', :disposition => 'inline') else - render :nothing => true, :status => :forbidden + render :text => "", :status => :forbidden end else - render :nothing => true, :status => :not_found + render :text => "", :status => :not_found end rescue ActiveRecord::RecordNotFound - render :nothing => true, :status => :not_found + render :text => "", :status => :not_found end def api_read @@ -266,7 +266,7 @@ class TraceController < ApplicationController if trace.public? or trace.user == @user render :text => trace.to_xml.to_s, :content_type => "text/xml" else - render :nothing => true, :status => :forbidden + render :text => "", :status => :forbidden end end @@ -285,9 +285,9 @@ class TraceController < ApplicationController trace.visibility = new_trace.visibility trace.save! - render :nothing => true, :status => :ok + render :text => "", :status => :ok else - render :nothing => true, :status => :forbidden + render :text => "", :status => :forbidden end end @@ -298,9 +298,9 @@ class TraceController < ApplicationController trace.visible = false trace.save! - render :nothing => true, :status => :ok + render :text => "", :status => :ok else - render :nothing => true, :status => :forbidden + render :text => "", :status => :forbidden end end @@ -314,7 +314,7 @@ class TraceController < ApplicationController send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => 'attachment') end else - render :nothing => true, :status => :forbidden + render :text => "", :status => :forbidden end end @@ -337,12 +337,12 @@ class TraceController < ApplicationController if @trace.id render :text => @trace.id.to_s, :content_type => "text/plain" elsif @trace.valid? - render :nothing => true, :status => :internal_server_error + render :text => "", :status => :internal_server_error else - render :nothing => true, :status => :bad_request + render :text => "", :status => :bad_request end else - render :nothing => true, :status => :bad_request + render :text => "", :status => :bad_request end end diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 875dc2d14..b96b66464 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -393,7 +393,7 @@ class UserController < ApplicationController end def api_read - render :nothing => true, :status => :gone unless @this_user.visible? + render :text => "", :status => :gone unless @this_user.visible? end def api_details diff --git a/app/controllers/user_preference_controller.rb b/app/controllers/user_preference_controller.rb index df5f279b8..059f00bbe 100644 --- a/app/controllers/user_preference_controller.rb +++ b/app/controllers/user_preference_controller.rb @@ -62,7 +62,7 @@ class UserPreferenceController < ApplicationController preference.save! end - render :nothing => true, :content_type => "text/plain" + render :text => "", :content_type => "text/plain" end ## @@ -79,7 +79,7 @@ class UserPreferenceController < ApplicationController pref.v = request.raw_post.chomp pref.save! - render :nothing => true, :content_type => "text/plain" + render :text => "", :content_type => "text/plain" end ## @@ -87,6 +87,6 @@ class UserPreferenceController < ApplicationController def delete_one UserPreference.find(@user.id, params[:preference_key]).delete - render :nothing => true, :content_type => "text/plain" + render :text => "", :content_type => "text/plain" end end diff --git a/app/controllers/way_controller.rb b/app/controllers/way_controller.rb index 9f797d1d8..6ea27deaf 100644 --- a/app/controllers/way_controller.rb +++ b/app/controllers/way_controller.rb @@ -19,7 +19,7 @@ class WayController < ApplicationController way.create_with_history @user render :text => way.id.to_s, :content_type => "text/plain" else - render :nothing => true, :status => :bad_request + render :text => "", :status => :bad_request end end @@ -43,7 +43,7 @@ class WayController < ApplicationController way.update_from(new_way, @user) render :text => way.version.to_s, :content_type => "text/plain" else - render :nothing => true, :status => :bad_request + render :text => "", :status => :bad_request end end @@ -56,7 +56,7 @@ class WayController < ApplicationController way.delete_with_history!(new_way, @user) render :text => way.version.to_s, :content_type => "text/plain" else - render :nothing => true, :status => :bad_request + render :text => "", :status => :bad_request end end @@ -99,7 +99,7 @@ class WayController < ApplicationController render :text => doc.to_s, :content_type => "text/xml" else - render :nothing => true, :status => :bad_request + render :text => "", :status => :bad_request end end diff --git a/test/functional/user_preference_controller_test.rb b/test/functional/user_preference_controller_test.rb index f5369387b..32ece63cd 100644 --- a/test/functional/user_preference_controller_test.rb +++ b/test/functional/user_preference_controller_test.rb @@ -108,7 +108,7 @@ class UserPreferenceControllerTest < ActionController::TestCase end assert_response :success assert_equal "text/plain", @response.content_type - assert_equal " ", @response.body + assert_equal "", @response.body assert_equal "new_value", UserPreference.find(1, "key").v assert_equal "value", UserPreference.find(1, "new_key").v assert_raises ActiveRecord::RecordNotFound do @@ -156,7 +156,7 @@ class UserPreferenceControllerTest < ActionController::TestCase end assert_response :success assert_equal "text/plain", @response.content_type - assert_equal " ", @response.body + assert_equal "", @response.body assert_equal "new_value", UserPreference.find(1, "new_key").v # try changing the value of a preference @@ -166,7 +166,7 @@ class UserPreferenceControllerTest < ActionController::TestCase end assert_response :success assert_equal "text/plain", @response.content_type - assert_equal " ", @response.body + assert_equal "", @response.body assert_equal "newer_value", UserPreference.find(1, "new_key").v end @@ -189,7 +189,7 @@ class UserPreferenceControllerTest < ActionController::TestCase end assert_response :success assert_equal "text/plain", @response.content_type - assert_equal " ", @response.body + assert_equal "", @response.body assert_raises ActiveRecord::RecordNotFound do UserPreference.find(1, "key") end