More prefabrication

This commit is contained in:
Daniel Waterworth 2019-05-10 11:59:31 +01:00 committed by Robin Ward
parent 54cfc48975
commit bf7594b327
10 changed files with 25 additions and 25 deletions

View File

@ -52,11 +52,11 @@ describe Category do
end end
describe "#review_group_id" do describe "#review_group_id" do
let(:group) { Fabricate(:group) } fab!(:group) { Fabricate(:group) }
let(:category) { Fabricate(:category, reviewable_by_group: group) } fab!(:category) { Fabricate(:category, reviewable_by_group: group) }
let(:topic) { Fabricate(:topic, category: category) } fab!(:topic) { Fabricate(:topic, category: category) }
let(:post) { Fabricate(:post, topic: topic) } fab!(:post) { Fabricate(:post, topic: topic) }
let(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
it "will add the group to the reviewable" do it "will add the group to the reviewable" do
SiteSetting.enable_category_group_review = true SiteSetting.enable_category_group_review = true

View File

@ -90,7 +90,7 @@ describe Invite do
end end
context 'when added by another user' do context 'when added by another user' do
let(:coding_horror) { Fabricate(:coding_horror) } fab!(:coding_horror) { Fabricate(:coding_horror) }
let(:new_invite) do let(:new_invite) do
Invite.invite_by_email(iceking, coding_horror, topic) Invite.invite_by_email(iceking, coding_horror, topic)
@ -199,7 +199,7 @@ describe Invite do
context '.redeem' do context '.redeem' do
let!(:invite) { Fabricate(:invite) } fab!(:invite) { Fabricate(:invite) }
it 'creates a notification for the invitee' do it 'creates a notification for the invitee' do
expect { invite.redeem }.to change(Notification, :count) expect { invite.redeem }.to change(Notification, :count)

View File

@ -89,7 +89,7 @@ describe Notification do
describe 'unread counts' do describe 'unread counts' do
let(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
context 'a regular notification' do context 'a regular notification' do
it 'increases unread_notifications' do it 'increases unread_notifications' do
@ -254,7 +254,7 @@ describe Notification do
describe '.filter_by_display_username_and_type' do describe '.filter_by_display_username_and_type' do
let(:post) { Fabricate(:post) } let(:post) { Fabricate(:post) }
let(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
before do before do
PostActionNotifier.enable PostActionNotifier.enable
@ -287,7 +287,7 @@ end
# pulling this out cause I don't want an observer # pulling this out cause I don't want an observer
describe Notification do describe Notification do
describe '#recent_report' do describe '#recent_report' do
let(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
let(:post) { Fabricate(:post) } let(:post) { Fabricate(:post) }
def fab(type, read) def fab(type, read)

View File

@ -85,7 +85,7 @@ RSpec.describe MetadataController do
end end
describe 'opensearch.xml' do describe 'opensearch.xml' do
let(:upload) { Fabricate(:upload) } fab!(:upload) { Fabricate(:upload) }
it 'returns the right output' do it 'returns the right output' do
title = 'MyApp' title = 'MyApp'

View File

@ -3,7 +3,8 @@
require 'rails_helper' require 'rails_helper'
describe PostActionUsersController do describe PostActionUsersController do
let(:post) { Fabricate(:post, user: sign_in(Fabricate(:user))) } fab!(:user) { Fabricate(:user) }
let(:post) { Fabricate(:post, user: sign_in(user)) }
context 'with render' do context 'with render' do
it 'always allows you to see your own actions' do it 'always allows you to see your own actions' do

View File

@ -6,7 +6,7 @@ describe ReviewableClaimedTopicsController do
fab!(:moderator) { Fabricate(:moderator) } fab!(:moderator) { Fabricate(:moderator) }
describe '#create' do describe '#create' do
let(:topic) { Fabricate(:topic) } fab!(:topic) { Fabricate(:topic) }
let(:params) do let(:params) do
{ reviewable_claimed_topic: { topic_id: topic.id } } { reviewable_claimed_topic: { topic_id: topic.id } }
end end
@ -37,7 +37,7 @@ describe ReviewableClaimedTopicsController do
end end
describe '#destroy' do describe '#destroy' do
let(:claimed) { Fabricate(:reviewable_claimed_topic) } fab!(:claimed) { Fabricate(:reviewable_claimed_topic) }
before do before do
sign_in(moderator) sign_in(moderator)

View File

@ -291,7 +291,7 @@ describe ReviewablesController do
end end
context "claims" do context "claims" do
let(:qp) { Fabricate(:reviewable_queued_post) } fab!(:qp) { Fabricate(:reviewable_queued_post) }
it "fails when reviewables must be claimed" do it "fails when reviewables must be claimed" do
SiteSetting.reviewable_claiming = 'required' SiteSetting.reviewable_claiming = 'required'

View File

@ -149,7 +149,7 @@ describe PostSerializer do
end end
context "a hidden revised post" do context "a hidden revised post" do
let(:post) { Fabricate(:post, raw: 'Hello world!', hidden: true) } fab!(:post) { Fabricate(:post, raw: 'Hello world!', hidden: true) }
before do before do
SiteSetting.editing_grace_period_max_diff = 1 SiteSetting.editing_grace_period_max_diff = 1
@ -202,9 +202,9 @@ describe PostSerializer do
end end
context "a post with notices" do context "a post with notices" do
let(:user) { Fabricate(:user, trust_level: 1) } fab!(:user) { Fabricate(:user, trust_level: 1) }
let(:user_tl1) { Fabricate(:user, trust_level: 1) } fab!(:user_tl1) { Fabricate(:user, trust_level: 1) }
let(:user_tl2) { Fabricate(:user, trust_level: 2) } fab!(:user_tl2) { Fabricate(:user, trust_level: 2) }
let(:post) { let(:post) {
post = Fabricate(:post, user: user) post = Fabricate(:post, user: user)

View File

@ -41,11 +41,11 @@ describe UserSerializer do
end end
context "with a user" do context "with a user" do
let(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
let(:serializer) { UserSerializer.new(user, scope: Guardian.new, root: false) } let(:serializer) { UserSerializer.new(user, scope: Guardian.new, root: false) }
let(:json) { serializer.as_json } let(:json) { serializer.as_json }
let(:upload) { Fabricate(:upload) } fab!(:upload) { Fabricate(:upload) }
let(:upload2) { Fabricate(:upload) } fab!(:upload2) { Fabricate(:upload) }
context "with `enable_names` true" do context "with `enable_names` true" do
before do before do

View File

@ -3,7 +3,6 @@
require "rails_helper" require "rails_helper"
describe UserAnonymizer do describe UserAnonymizer do
let(:admin) { Fabricate(:admin) } let(:admin) { Fabricate(:admin) }
describe "event" do describe "event" do
@ -27,7 +26,7 @@ describe UserAnonymizer do
describe "make_anonymous" do describe "make_anonymous" do
let(:original_email) { "edward@example.net" } let(:original_email) { "edward@example.net" }
let(:user) { Fabricate(:user, username: "edward", email: original_email) } let(:user) { Fabricate(:user, username: "edward", email: original_email) }
let(:another_user) { Fabricate(:evil_trout) } fab!(:another_user) { Fabricate(:evil_trout) }
subject(:make_anonymous) { described_class.make_anonymous(user, admin) } subject(:make_anonymous) { described_class.make_anonymous(user, admin) }
it "changes username" do it "changes username" do
@ -297,7 +296,7 @@ describe UserAnonymizer do
let(:old_ip) { "1.2.3.4" } let(:old_ip) { "1.2.3.4" }
let(:anon_ip) { "0.0.0.0" } let(:anon_ip) { "0.0.0.0" }
let(:user) { Fabricate(:user, ip_address: old_ip, registration_ip_address: old_ip) } let(:user) { Fabricate(:user, ip_address: old_ip, registration_ip_address: old_ip) }
let(:post) { Fabricate(:post) } fab!(:post) { Fabricate(:post) }
let(:topic) { post.topic } let(:topic) { post.topic }
it "doesn't anonymize ips by default" do it "doesn't anonymize ips by default" do