summaryrefslogtreecommitdiff
path: root/spec/controllers/application_controller_spec.rb
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2017-06-20 15:53:05 +0200
committerPawel Chojnacki <pawel@chojnacki.ws>2017-06-20 15:53:23 +0200
commit15b7b9ec4117bf19168ea0f923ea11e926edcc5c (patch)
tree76c9092445c3619d343c810541e49a84522624b1 /spec/controllers/application_controller_spec.rb
parent57ff963129a37b27f3944f0ec2d0212da9b23e84 (diff)
downloadgitlab-ce-15b7b9ec4117bf19168ea0f923ea11e926edcc5c.tar.gz
Add rescue_from(ActionController::UnknownFormat) in Application Controller
Diffstat (limited to 'spec/controllers/application_controller_spec.rb')
-rw-r--r--spec/controllers/application_controller_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index 3f99e2ff596..a2720c9b81e 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -99,6 +99,36 @@ describe ApplicationController do
end
end
+ describe 'response format' do
+ controller(described_class) do
+ def index
+ respond_to do |format|
+ format.json do
+ head :ok
+ end
+ end
+ end
+ end
+
+ context 'when format is handled' do
+ let(:requested_format) { :json }
+
+ it 'returns 200 response' do
+ get :index, private_token: user.private_token, format: requested_format
+
+ expect(response).to have_http_status 200
+ end
+ end
+
+ context 'when format is not handled' do
+ it 'returns 404 response' do
+ get :index, private_token: user.private_token
+
+ expect(response).to have_http_status 404
+ end
+ end
+ end
+
describe '#authenticate_user_from_rss_token' do
describe "authenticating a user from an RSS token" do
controller(described_class) do