diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 361636c9d..5953993a9 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -65,14 +65,15 @@ class StatusMessagesController < ApplicationController end respond_to do |format| - format.html { redirect_to :back} - format.mobile{ redirect_to stream_path} - format.json{ render :json => @status_message.as_api_response(:backbone), :status => 201 } + format.html { redirect_to :back } + format.mobile { redirect_to stream_path } + format.json { render :json => @status_message.as_api_response(:backbone), :status => 201 } end else respond_to do |format| - format.json { render :nothing, :status => 403 } format.html { redirect_to :back } + format.mobile { redirect_to stream_path } + format.json { render :nothing => true , :status => 403 } end end end diff --git a/spec/controllers/status_messages_controller_spec.rb b/spec/controllers/status_messages_controller_spec.rb index 12b79da03..b6dbd587d 100644 --- a/spec/controllers/status_messages_controller_spec.rb +++ b/spec/controllers/status_messages_controller_spec.rb @@ -79,6 +79,40 @@ describe StatusMessagesController do :aspect_ids => [@aspect1.id.to_s] } } + it 'creates with valid html' do + post :create, status_message_hash + response.status.should == 302 + response.should be_redirect + end + + it 'creates with invalid html' do + post :create, status_message_hash.merge(:status_message => { :text => "0123456789" * 7000 }) + response.status.should == 302 + response.should be_redirect + end + + it 'creates with valid json' do + post :create, status_message_hash.merge(:format => 'json') + response.status.should == 201 + end + + it 'creates with invalid json' do + post :create, status_message_hash.merge(:status_message => { :text => "0123456789" * 7000 }, :format => 'json') + response.status.should == 403 + end + + it 'creates with valid mobile' do + post :create, status_message_hash.merge(:format => 'mobile') + response.status.should == 302 + response.should be_redirect + end + + it 'creates with invalid mobile' do + post :create, status_message_hash.merge(:status_message => { :text => "0123456789" * 7000 }, :format => 'mobile') + response.status.should == 302 + response.should be_redirect + end + it 'removes getting started from new users' do @controller.should_receive(:remove_getting_started) post :create, status_message_hash