mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 02:19:27 +08:00
More prefabrication
This commit is contained in:
parent
54cfc48975
commit
bf7594b327
|
@ -52,11 +52,11 @@ describe Category do
|
|||
end
|
||||
|
||||
describe "#review_group_id" do
|
||||
let(:group) { Fabricate(:group) }
|
||||
let(:category) { Fabricate(:category, reviewable_by_group: group) }
|
||||
let(:topic) { Fabricate(:topic, category: category) }
|
||||
let(:post) { Fabricate(:post, topic: topic) }
|
||||
let(:user) { Fabricate(:user) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:category) { Fabricate(:category, reviewable_by_group: group) }
|
||||
fab!(:topic) { Fabricate(:topic, category: category) }
|
||||
fab!(:post) { Fabricate(:post, topic: topic) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
|
||||
it "will add the group to the reviewable" do
|
||||
SiteSetting.enable_category_group_review = true
|
||||
|
|
|
@ -90,7 +90,7 @@ describe Invite do
|
|||
end
|
||||
|
||||
context 'when added by another user' do
|
||||
let(:coding_horror) { Fabricate(:coding_horror) }
|
||||
fab!(:coding_horror) { Fabricate(:coding_horror) }
|
||||
|
||||
let(:new_invite) do
|
||||
Invite.invite_by_email(iceking, coding_horror, topic)
|
||||
|
@ -199,7 +199,7 @@ describe Invite do
|
|||
|
||||
context '.redeem' do
|
||||
|
||||
let!(:invite) { Fabricate(:invite) }
|
||||
fab!(:invite) { Fabricate(:invite) }
|
||||
|
||||
it 'creates a notification for the invitee' do
|
||||
expect { invite.redeem }.to change(Notification, :count)
|
||||
|
|
|
@ -89,7 +89,7 @@ describe Notification do
|
|||
|
||||
describe 'unread counts' do
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
|
||||
context 'a regular notification' do
|
||||
it 'increases unread_notifications' do
|
||||
|
@ -254,7 +254,7 @@ describe Notification do
|
|||
|
||||
describe '.filter_by_display_username_and_type' do
|
||||
let(:post) { Fabricate(:post) }
|
||||
let(:user) { Fabricate(:user) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
PostActionNotifier.enable
|
||||
|
@ -287,7 +287,7 @@ end
|
|||
# pulling this out cause I don't want an observer
|
||||
describe Notification do
|
||||
describe '#recent_report' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
let(:post) { Fabricate(:post) }
|
||||
|
||||
def fab(type, read)
|
||||
|
|
|
@ -85,7 +85,7 @@ RSpec.describe MetadataController do
|
|||
end
|
||||
|
||||
describe 'opensearch.xml' do
|
||||
let(:upload) { Fabricate(:upload) }
|
||||
fab!(:upload) { Fabricate(:upload) }
|
||||
|
||||
it 'returns the right output' do
|
||||
title = 'MyApp'
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
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
|
||||
it 'always allows you to see your own actions' do
|
||||
|
|
|
@ -6,7 +6,7 @@ describe ReviewableClaimedTopicsController do
|
|||
fab!(:moderator) { Fabricate(:moderator) }
|
||||
|
||||
describe '#create' do
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
let(:params) do
|
||||
{ reviewable_claimed_topic: { topic_id: topic.id } }
|
||||
end
|
||||
|
@ -37,7 +37,7 @@ describe ReviewableClaimedTopicsController do
|
|||
end
|
||||
|
||||
describe '#destroy' do
|
||||
let(:claimed) { Fabricate(:reviewable_claimed_topic) }
|
||||
fab!(:claimed) { Fabricate(:reviewable_claimed_topic) }
|
||||
|
||||
before do
|
||||
sign_in(moderator)
|
||||
|
|
|
@ -291,7 +291,7 @@ describe ReviewablesController do
|
|||
end
|
||||
|
||||
context "claims" do
|
||||
let(:qp) { Fabricate(:reviewable_queued_post) }
|
||||
fab!(:qp) { Fabricate(:reviewable_queued_post) }
|
||||
|
||||
it "fails when reviewables must be claimed" do
|
||||
SiteSetting.reviewable_claiming = 'required'
|
||||
|
|
|
@ -149,7 +149,7 @@ describe PostSerializer do
|
|||
end
|
||||
|
||||
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
|
||||
SiteSetting.editing_grace_period_max_diff = 1
|
||||
|
@ -202,9 +202,9 @@ describe PostSerializer do
|
|||
end
|
||||
|
||||
context "a post with notices" do
|
||||
let(:user) { Fabricate(:user, trust_level: 1) }
|
||||
let(:user_tl1) { Fabricate(:user, trust_level: 1) }
|
||||
let(:user_tl2) { Fabricate(:user, trust_level: 2) }
|
||||
fab!(:user) { Fabricate(:user, trust_level: 1) }
|
||||
fab!(:user_tl1) { Fabricate(:user, trust_level: 1) }
|
||||
fab!(:user_tl2) { Fabricate(:user, trust_level: 2) }
|
||||
|
||||
let(:post) {
|
||||
post = Fabricate(:post, user: user)
|
||||
|
|
|
@ -41,11 +41,11 @@ describe UserSerializer do
|
|||
end
|
||||
|
||||
context "with a user" do
|
||||
let(:user) { Fabricate(:user) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
let(:serializer) { UserSerializer.new(user, scope: Guardian.new, root: false) }
|
||||
let(:json) { serializer.as_json }
|
||||
let(:upload) { Fabricate(:upload) }
|
||||
let(:upload2) { Fabricate(:upload) }
|
||||
fab!(:upload) { Fabricate(:upload) }
|
||||
fab!(:upload2) { Fabricate(:upload) }
|
||||
|
||||
context "with `enable_names` true" do
|
||||
before do
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
describe UserAnonymizer do
|
||||
|
||||
let(:admin) { Fabricate(:admin) }
|
||||
|
||||
describe "event" do
|
||||
|
@ -27,7 +26,7 @@ describe UserAnonymizer do
|
|||
describe "make_anonymous" do
|
||||
let(:original_email) { "edward@example.net" }
|
||||
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) }
|
||||
|
||||
it "changes username" do
|
||||
|
@ -297,7 +296,7 @@ describe UserAnonymizer do
|
|||
let(:old_ip) { "1.2.3.4" }
|
||||
let(:anon_ip) { "0.0.0.0" }
|
||||
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 }
|
||||
|
||||
it "doesn't anonymize ips by default" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user