DEV: Prefer fab! over let!.

This commit is contained in:
Guo Xiang Tan 2020-06-29 11:11:06 +08:00
parent 69803599a9
commit 89bac20b8e
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20

View File

@ -19,7 +19,7 @@ describe TopicViewSerializer do
fab!(:admin) { Fabricate(:admin) }
describe '#featured_link and #featured_link_root_domain' do
let(:featured_link) { 'http://meta.discourse.org' }
fab!(:featured_link) { 'http://meta.discourse.org' }
describe 'when topic featured link is disable' do
it 'should return the right attributes' do
@ -46,7 +46,7 @@ describe TopicViewSerializer do
end
describe '#image_url' do
let(:image_upload) { Fabricate(:image_upload, width: 5000, height: 5000) }
fab!(:image_upload) { Fabricate(:image_upload, width: 5000, height: 5000) }
describe 'when a topic has an image' do
before { topic.update!(image_upload_id: image_upload.id) }
@ -90,7 +90,7 @@ describe TopicViewSerializer do
end
describe '#suggested_topics' do
let(:topic2) { Fabricate(:topic) }
fab!(:topic2) { Fabricate(:topic) }
before do
TopicUser.update_last_read(user, topic2.id, 0, 0, 0)
@ -105,8 +105,8 @@ describe TopicViewSerializer do
end
describe 'when not loading last chunk' do
let(:post) { Fabricate(:post, topic: topic) }
let(:post2) { Fabricate(:post, topic: topic) }
fab!(:post) { Fabricate(:post, topic: topic) }
fab!(:post2) { Fabricate(:post, topic: topic) }
it 'should not include suggested topics' do
post
@ -120,7 +120,7 @@ describe TopicViewSerializer do
end
describe 'with private messages' do
let!(:topic) do
fab!(:topic) do
Fabricate(:private_message_topic,
highest_post_number: 1,
topic_allowed_users: [
@ -129,7 +129,7 @@ describe TopicViewSerializer do
)
end
let!(:topic2) do
fab!(:topic2) do
Fabricate(:private_message_topic,
highest_post_number: 1,
topic_allowed_users: [
@ -155,9 +155,9 @@ describe TopicViewSerializer do
end
describe 'when tags added to private message topics' do
let(:moderator) { Fabricate(:moderator) }
let(:tag) { Fabricate(:tag) }
let(:pm) do
fab!(:moderator) { Fabricate(:moderator) }
fab!(:tag) { Fabricate(:tag) }
fab!(:pm) do
Fabricate(:private_message_topic, tags: [tag], topic_allowed_users: [
Fabricate.build(:topic_allowed_user, user: moderator),
Fabricate.build(:topic_allowed_user, user: user)
@ -192,12 +192,12 @@ describe TopicViewSerializer do
end
describe 'with hidden tags' do
let(:hidden_tag) { Fabricate(:tag, name: 'hidden') }
let(:staff_tag_group) { Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [hidden_tag.name]) }
fab!(:hidden_tag) { Fabricate(:tag, name: 'hidden') }
fab!(:staff_tag_group) { Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [hidden_tag.name]) }
before do
SiteSetting.tagging_enabled = true
staff_tag_group
hidden_tag.tag_groups << staff_tag_group
topic.tags << hidden_tag
end
@ -213,8 +213,8 @@ describe TopicViewSerializer do
end
context "with flags" do
let!(:post) { Fabricate(:post, topic: topic) }
let!(:other_post) { Fabricate(:post, topic: topic) }
fab!(:post) { Fabricate(:post, topic: topic) }
fab!(:other_post) { Fabricate(:post, topic: topic) }
it "will return reviewable counts on posts" do
r = PostActionCreator.inappropriate(Fabricate(:user), post).reviewable
@ -239,7 +239,7 @@ describe TopicViewSerializer do
SiteSetting.approve_post_count = 1
end
let!(:queued_post) do
fab!(:queued_post) do
ReviewableQueuedPost.needs_review!(
topic: topic,
payload: { raw: "hello my raw contents" },