From 4c696603c6983b9737c840ca49221a5762e1043a Mon Sep 17 00:00:00 2001 From: MrZYX <pr0fkill@gmail.com> Date: Wed, 6 Apr 2011 16:26:01 +0200 Subject: [PATCH] some better http status codes --- app/controllers/aspects_controller.rb | 2 +- app/controllers/comments_controller.rb | 2 +- app/controllers/messages_controller.rb | 4 ++-- app/controllers/notifications_controller.rb | 2 +- app/controllers/publics_controller.rb | 2 +- spec/controllers/comments_controller_spec.rb | 2 +- spec/controllers/messages_controller_spec.rb | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index d874a63585..f6b72300c3 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -137,7 +137,7 @@ class AspectsController < ApplicationController else flash[:error] = I18n.t 'aspects.update.failure', :name => @aspect.name end - render :nothing => true + render :nothing => true, :status => 204 end def toggle_contact_visibility diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 97f9f58865..18e0e72777 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -55,7 +55,7 @@ class CommentsController < ApplicationController else respond_to do |format| format.mobile {redirect_to :back} - format.js {render :nothing => true, :status => 401} + format.js {render :nothing => true, :status => 403} end end else diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 2dac50dda8..97f21556c0 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -22,10 +22,10 @@ class MessagesController < ApplicationController redirect_to conversations_path(:conversation_id => cnv.id) else - render :nothing => true, :status => 406 + render :nothing => true, :status => 422 end else - render :nothing => true, :status => 406 + render :nothing => true, :status => 422 end end diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index fc9e73cf3e..1d6963d260 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -13,7 +13,7 @@ class NotificationsController < ApplicationController note.update_attributes(:unread => false) render :nothing => true else - render :nothing => true, :code => 404 + render :nothing => true, :status => 404 end end diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index 6e54615067..a7700babf4 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -58,6 +58,6 @@ class PublicsController < ApplicationController @user = person.owner Resque.enqueue(Job::ReceiveSalmon, @user.id, CGI::unescape(params[:xml])) - render :nothing => true, :status => 200 + render :nothing => true, :status => 202 end end diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 308b4866cb..6649afd238 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -102,7 +102,7 @@ describe CommentsController do it 'does not let the user destroy comments he does not own' do alice.should_not_receive(:retract).with(@comment2) delete :destroy, :format => "js", :id => @comment3.id - response.status.should == 401 + response.status.should == 403 end end end diff --git a/spec/controllers/messages_controller_spec.rb b/spec/controllers/messages_controller_spec.rb index 8c9b777bb5..369f9219b1 100644 --- a/spec/controllers/messages_controller_spec.rb +++ b/spec/controllers/messages_controller_spec.rb @@ -69,7 +69,7 @@ describe MessagesController do end it 'posts no comment' do post :create, @message_hash - response.code.should == '406' + response.code.should == '422' end end end -- GitLab