Commit fb919a631c16f0046c5599a9e9e9fa38ff4a699a

Authored by Dmitriy Zaporozhets
2 parents 60c3e841 ac35ee37

Merge branch 'dmedvinsky-username-keys-content-type'

CHANGELOG
... ... @@ -30,6 +30,7 @@ v 6.7.0
30 30 - Requires at least 2 unicorn workers
31 31 - Requires gitlab-shell v1.9+
32 32 - Replaced gemoji(due to closed licencing problem) with Phantom Open Emoji library(combined SIL Open Font License, MIT License and the CC 3.0 License)
  33 + - Fix `/:username.keys` response content type (Dmitry Medvinsky)
33 34  
34 35 v 6.6.5
35 36 - Added option to remove issue assignee on project issue page and issue edit page (Jason Blanchard)
... ...
app/controllers/profiles/keys_controller.rb
... ... @@ -41,7 +41,7 @@ class Profiles::KeysController < ApplicationController
41 41 begin
42 42 user = User.find_by_username(params[:username])
43 43 if user.present?
44   - render text: user.all_ssh_keys.join("\n")
  44 + render text: user.all_ssh_keys.join("\n"), content_type: "text/plain"
45 45 else
46 46 render_404 and return
47 47 end
... ...
spec/controllers/profile_keys_controller_spec.rb
... ... @@ -24,6 +24,11 @@ describe Profiles::KeysController do
24 24  
25 25 expect(response.body).to eq("")
26 26 end
  27 +
  28 + it "should respond with text/plain content type" do
  29 + get :get_keys, username: user.username
  30 + expect(response.content_type).to eq("text/plain")
  31 + end
27 32 end
28 33  
29 34 describe "user with keys" do
... ... @@ -44,6 +49,11 @@ describe Profiles::KeysController do
44 49 expect(response.body).not_to eq("")
45 50 expect(response.body).to eq(user.all_ssh_keys.join("\n"))
46 51 end
  52 +
  53 + it "should respond with text/plain content type" do
  54 + get :get_keys, username: user.username
  55 + expect(response.content_type).to eq("text/plain")
  56 + end
47 57 end
48 58 end
49 59 end
... ...