DEV: Avoid multiple fabrications in spec (#21606)

This commit is contained in:
Alan Guo Xiang Tan 2023-05-17 15:28:31 +09:00 committed by GitHub
parent c991b8f6a0
commit 8d58b1c6b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 6 deletions

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true
RSpec.describe SvgSpriteController do
fab!(:user) { Fabricate(:user) }
describe "#show" do
before { SvgSprite.expire_cache }
@ -38,7 +40,7 @@ RSpec.describe SvgSpriteController do
end
it "should return symbol for FA icon search" do
user = sign_in(Fabricate(:user))
sign_in(user)
get "/svg-sprite/search/fa-bolt"
expect(response.status).to eq(200)
@ -46,7 +48,7 @@ RSpec.describe SvgSpriteController do
end
it "should return 404 when looking for non-existent FA icon" do
user = sign_in(Fabricate(:user))
sign_in(user)
get "/svg-sprite/search/fa-not-a-valid-icon"
expect(response.status).to eq(404)
@ -68,7 +70,7 @@ RSpec.describe SvgSpriteController do
SiteSetting.default_theme_id = theme.id
user = sign_in(Fabricate(:user))
sign_in(user)
get "/svg-sprite/search/fa-my-custom-theme-icon"
expect(response.status).to eq(200)
@ -84,7 +86,7 @@ RSpec.describe SvgSpriteController do
end
it "should work with no filter and max out at 200 results" do
user = sign_in(Fabricate(:user))
sign_in(user)
get "/svg-sprite/picker-search"
expect(response.status).to eq(200)
@ -95,7 +97,7 @@ RSpec.describe SvgSpriteController do
end
it "should filter" do
user = sign_in(Fabricate(:user))
sign_in(user)
get "/svg-sprite/picker-search", params: { filter: "500px" }
@ -107,7 +109,7 @@ RSpec.describe SvgSpriteController do
end
it "should display only available" do
sign_in(Fabricate(:user))
sign_in(user)
get "/svg-sprite/picker-search"
data = response.parsed_body