Commit 8ef35df0 authored by Michael Kozono's avatar Michael Kozono

Merge branch '293967-refactor-users_controller_spec-gpg_keys' into 'master'

Refactor specs around gpg_keys in users_controller_spec.rb

See merge request gitlab-org/gitlab!50337
parents e6407be9 a885418b
---
title: Refactor specs around gpg_keys in users_controller_spec.rb
merge_request: 50337
author: Takuya Noguchi
type: other
......@@ -337,22 +337,12 @@ RSpec.describe UsersController do
end
describe "user with no keys" do
it "does generally work" do
it "responds the empty body with text/plain content type" do
get :gpg_keys, params: { username: user.username }
expect(response).to be_successful
end
it "renders all keys separated with a new line" do
get :gpg_keys, params: { username: user.username }
expect(response.body).to eq("")
end
it "responds with text/plain content type" do
get :gpg_keys, params: { username: user.username }
expect(response.content_type).to eq("text/plain")
expect(response.body).to eq("")
end
end
......@@ -371,21 +361,17 @@ RSpec.describe UsersController do
expect(response).to be_successful
end
it "renders all verified keys separated with a new line" do
it "renders all verified keys separated with a new line with text/plain content type" do
get :gpg_keys, params: { username: user.username }
expect(response.content_type).to eq("text/plain")
expect(response.body).not_to eq('')
expect(response.body).to eq(user.gpg_keys.select(&:verified?).map(&:key).join("\n"))
expect(response.body).to include(gpg_key.key)
expect(response.body).to include(another_gpg_key.key)
end
it "responds with text/plain content type" do
get :gpg_keys, params: { username: user.username }
expect(response.content_type).to eq("text/plain")
end
end
describe 'when logged out' do
......@@ -399,21 +385,17 @@ RSpec.describe UsersController do
expect(response).to be_successful
end
it "renders all verified keys separated with a new line" do
it "renders all verified keys separated with a new line with text/plain content type" do
get :gpg_keys, params: { username: user.username }
expect(response.content_type).to eq("text/plain")
expect(response.body).not_to eq('')
expect(response.body).to eq(user.gpg_keys.map(&:key).join("\n"))
expect(response.body).to include(gpg_key.key)
expect(response.body).to include(another_gpg_key.key)
end
it "responds with text/plain content type" do
get :gpg_keys, params: { username: user.username }
expect(response.content_type).to eq("text/plain")
end
end
describe 'when revoked' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment