mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 00:24:39 +08:00
DEV: Prefabrication (test optimization) (#7414)
* Introduced fab!, a helper that creates database state for a group It's almost identical to let_it_be, except: 1. It creates a new object for each test by default, 2. You can disable it using PREFABRICATION=0
This commit is contained in:
@ -8,7 +8,7 @@ describe Admin::UserFieldsController do
|
||||
end
|
||||
|
||||
context "when logged in" do
|
||||
let(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
|
||||
before do
|
||||
sign_in(admin)
|
||||
@ -44,7 +44,7 @@ describe Admin::UserFieldsController do
|
||||
end
|
||||
|
||||
describe '#index' do
|
||||
let!(:user_field) { Fabricate(:user_field) }
|
||||
fab!(:user_field) { Fabricate(:user_field) }
|
||||
|
||||
it "returns a list of user fields" do
|
||||
get "/admin/customize/user_fields.json"
|
||||
@ -55,7 +55,7 @@ describe Admin::UserFieldsController do
|
||||
end
|
||||
|
||||
describe '#destroy' do
|
||||
let!(:user_field) { Fabricate(:user_field) }
|
||||
fab!(:user_field) { Fabricate(:user_field) }
|
||||
|
||||
it "deletes the user field" do
|
||||
expect {
|
||||
@ -66,7 +66,7 @@ describe Admin::UserFieldsController do
|
||||
end
|
||||
|
||||
describe '#update' do
|
||||
let!(:user_field) { Fabricate(:user_field) }
|
||||
fab!(:user_field) { Fabricate(:user_field) }
|
||||
|
||||
it "updates the user field" do
|
||||
put "/admin/customize/user_fields/#{user_field.id}.json", params: {
|
||||
|
Reference in New Issue
Block a user