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 Admin::UserFieldsController do
fab!(:admin) { Fabricate(:admin) }
fab!(:moderator) { Fabricate(:moderator) }
fab!(:user) { Fabricate(:user) }
fab!(:admin)
fab!(:moderator)
fab!(:user)
describe "#create" do
context "when logged in as an admin" do
@ -75,7 +75,7 @@ RSpec.describe Admin::UserFieldsController do
end
describe "#index" do
fab!(:user_field) { Fabricate(:user_field) }
fab!(:user_field)
context "when logged in as an admin" do
before { sign_in(admin) }
@ -112,7 +112,7 @@ RSpec.describe Admin::UserFieldsController do
end
describe "#destroy" do
fab!(:user_field) { Fabricate(:user_field) }
fab!(:user_field)
context "when logged in as an admin" do
before { sign_in(admin) }
@ -150,7 +150,7 @@ RSpec.describe Admin::UserFieldsController do
end
describe "#update" do
fab!(:user_field) { Fabricate(:user_field) }
fab!(:user_field)
context "when logged in as an admin" do
before { sign_in(admin) }