Commit a885418b authored by Takuya Noguchi's avatar Takuya Noguchi

Refactor specs around gpg_keys in users_controller_spec.rb

Signed-off-by: default avatarTakuya Noguchi <takninnovationresearch@gmail.com>
parent e6407be9
---
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