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

@ -1,9 +1,9 @@
# frozen_string_literal: true
RSpec.describe UserBadgesController do
fab!(:user) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin) }
fab!(:badge) { Fabricate(:badge) }
fab!(:user)
fab!(:admin)
fab!(:badge)
describe "#index" do
fab!(:badge) { Fabricate(:badge, target_posts: true, show_posts: false) }
@ -42,11 +42,11 @@ RSpec.describe UserBadgesController do
end
describe "#index" do
fab!(:post) { Fabricate(:post) }
fab!(:private_message_post) { Fabricate(:private_message_post) }
fab!(:post)
fab!(:private_message_post)
let(:topic) { post.topic }
let(:private_message_topic) { private_message_post.topic }
fab!(:group) { Fabricate(:group) }
fab!(:group)
fab!(:private_category) { Fabricate(:private_category, group: group) }
fab!(:restricted_topic) { Fabricate(:topic, category: private_category) }
fab!(:restricted_post) { Fabricate(:post, topic: restricted_topic) }