DEV: Allow fab! without block (#24314)

The most common thing that we do with fab! is:

    fab!(:thing) { Fabricate(:thing) }

This commit adds a shorthand for this which is just simply:

    fab!(:thing)

i.e. If you omit the block, then, by default, you'll get a `Fabricate`d object using the fabricator of the same name.
This commit is contained in:
Daniel Waterworth
2023-11-09 16:47:59 -06:00
committed by GitHub
parent d91456fd53
commit 6e161d3e75
471 changed files with 1277 additions and 1273 deletions

View File

@ -128,7 +128,7 @@ RSpec.describe ApplicationController do
describe "#redirect_to_second_factor_if_required" do
let(:admin) { Fabricate(:admin) }
fab!(:user) { Fabricate(:user) }
fab!(:user)
before do
admin # to skip welcome wizard at home page `/`
@ -430,8 +430,8 @@ RSpec.describe ApplicationController do
let!(:theme) { Fabricate(:theme, user_selectable: true) }
let!(:theme2) { Fabricate(:theme, user_selectable: true) }
let!(:non_selectable_theme) { Fabricate(:theme, user_selectable: false) }
fab!(:user) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin) }
fab!(:user)
fab!(:admin)
before { sign_in(user) }
@ -1061,7 +1061,7 @@ RSpec.describe ApplicationController do
end
describe "Discourse-Rate-Limit-Error-Code header" do
fab!(:admin) { Fabricate(:admin) }
fab!(:admin)
before { RateLimiter.enable }
@ -1152,7 +1152,7 @@ RSpec.describe ApplicationController do
describe "#banner_json" do
let(:admin) { Fabricate(:admin) }
let(:user) { Fabricate(:user) }
fab!(:banner_topic) { Fabricate(:banner_topic) }
fab!(:banner_topic)
fab!(:p1) { Fabricate(:post, topic: banner_topic, raw: "A banner topic") }
before do
@ -1252,7 +1252,7 @@ RSpec.describe ApplicationController do
end
context "when user is regular user" do
fab!(:user) { Fabricate(:user) }
fab!(:user)
before { sign_in(user) }