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

@ -9,7 +9,7 @@ RSpec.describe Email::Processor do
context "when reply via email is too short" do
let(:mail) { file_from_fixtures("chinese_reply.eml", "emails").read }
fab!(:post) { Fabricate(:post) }
fab!(:post)
fab!(:user) { Fabricate(:user, email: "discourse@bar.com") }
fab!(:post_reply_key) do
@ -177,7 +177,7 @@ RSpec.describe Email::Processor do
describe "when replying to a post that is too old" do
fab!(:user) { Fabricate(:user, email: "discourse@bar.com") }
fab!(:topic) { Fabricate(:topic) }
fab!(:topic)
fab!(:post) { Fabricate(:post, topic: topic, created_at: 3.days.ago) }
let(:mail) do
file_from_fixtures("old_destination.eml", "emails")