mirror of
https://github.com/discourse/discourse.git
synced 2025-01-22 11:58:30 +08:00
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:
parent
d91456fd53
commit
6e161d3e75
|
@ -99,7 +99,7 @@ describe "Automatic user removal from channels" do
|
|||
|
||||
context "when a user is removed from a group" do
|
||||
context "when the user is no longer in any chat_allowed_groups" do
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:group)
|
||||
|
||||
before do
|
||||
group.add(user_1)
|
||||
|
|
|
@ -8,7 +8,7 @@ describe "API keys scoped to chat#create_message" do
|
|||
SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:everyone]
|
||||
end
|
||||
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
fab!(:chat_channel) { Fabricate(:category_channel) }
|
||||
fab!(:chat_channel_2) { Fabricate(:category_channel) }
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ RSpec.describe "Outgoing chat webhooks" do
|
|||
end
|
||||
|
||||
context "for a category channel" do
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:category)
|
||||
fab!(:chat_channel) { Fabricate(:category_channel, chatable: category) }
|
||||
fab!(:chat_message) { Fabricate(:chat_message, chat_channel: chat_channel, user: user1) }
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
describe "chat bbcode quoting in posts" do
|
||||
fab!(:post) { Fabricate(:post) }
|
||||
fab!(:post)
|
||||
|
||||
before { SiteSetting.chat_enabled = true }
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
RSpec.describe "Chat::Thread replies_count cache accuracy" do
|
||||
include ActiveSupport::Testing::TimeHelpers
|
||||
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:thread) { Fabricate(:chat_thread) }
|
||||
|
||||
let(:guardian) { user.guardian }
|
||||
|
|
|
@ -5,7 +5,7 @@ require "rails_helper"
|
|||
describe Jobs::Chat::ChannelArchive do
|
||||
fab!(:chat_channel) { Fabricate(:category_channel) }
|
||||
fab!(:user) { Fabricate(:user, admin: true) }
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:category)
|
||||
fab!(:chat_archive) do
|
||||
Chat::ChannelArchive.create!(
|
||||
chat_channel: chat_channel,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
describe Jobs::Chat::ChannelDelete do
|
||||
fab!(:chat_channel) { Fabricate(:chat_channel) }
|
||||
fab!(:chat_channel)
|
||||
fab!(:user1) { Fabricate(:user) }
|
||||
fab!(:user2) { Fabricate(:user) }
|
||||
fab!(:user3) { Fabricate(:user) }
|
||||
|
|
|
@ -4,7 +4,7 @@ RSpec.describe Jobs::Chat::NotifyWatching do
|
|||
fab!(:user1) { Fabricate(:user) }
|
||||
fab!(:user2) { Fabricate(:user) }
|
||||
fab!(:user3) { Fabricate(:user) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:group)
|
||||
let(:except_user_ids) { [] }
|
||||
|
||||
before do
|
||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe Jobs::Chat::SendMessageNotifications do
|
|||
end
|
||||
|
||||
context "when there's a message" do
|
||||
fab!(:chat_message) { Fabricate(:chat_message) }
|
||||
fab!(:chat_message)
|
||||
|
||||
it "does nothing when the reason is invalid" do
|
||||
Chat::Notifier.expects(:notify_new).never
|
||||
|
|
|
@ -8,7 +8,7 @@ describe Chat::ChannelArchiveService do
|
|||
|
||||
fab!(:channel) { Fabricate(:category_channel) }
|
||||
fab!(:user) { Fabricate(:user, admin: true) }
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:category)
|
||||
|
||||
let(:topic_params) { { topic_title: "This will be a new topic", category_id: category.id } }
|
||||
|
||||
|
@ -304,7 +304,7 @@ describe Chat::ChannelArchiveService do
|
|||
end
|
||||
|
||||
context "when archiving to an existing topic" do
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:topic)
|
||||
let(:topic_params) { { topic_id: topic.id } }
|
||||
|
||||
before { 3.times { Fabricate(:post, topic: topic) } }
|
||||
|
|
|
@ -149,7 +149,7 @@ describe Chat::ChannelFetcher do
|
|||
end
|
||||
|
||||
context "when restricted category" do
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:group)
|
||||
fab!(:group_user) { Fabricate(:group_user, group: group, user: user1) }
|
||||
|
||||
it "does not include the category channel for member of group with readonly access" do
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Chat::ChannelHashtagDataSource do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:user)
|
||||
fab!(:category)
|
||||
fab!(:group)
|
||||
fab!(:private_category) { Fabricate(:private_category, group: group) }
|
||||
fab!(:channel1) do
|
||||
Fabricate(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Chat::ChannelMembershipManager do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:channel1) { Fabricate(:category_channel) }
|
||||
fab!(:channel2) { Fabricate(:category_channel) }
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ RSpec.describe Chat::GuardianExtensions do
|
|||
end
|
||||
|
||||
context "for category channel" do
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:group)
|
||||
fab!(:group_user) { Fabricate(:group_user, group: group, user: user) }
|
||||
|
||||
it "returns true if the user can join the category" do
|
||||
|
@ -207,7 +207,7 @@ RSpec.describe Chat::GuardianExtensions do
|
|||
end
|
||||
|
||||
context "when user can't post in chatable" do
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:group)
|
||||
fab!(:channel) { Fabricate(:private_category_channel, group: group) }
|
||||
|
||||
before do
|
||||
|
|
|
@ -6,7 +6,7 @@ describe Chat::OneboxHandler do
|
|||
fab!(:private_category) { Fabricate(:private_category, group: Fabricate(:group)) }
|
||||
fab!(:private_channel) { Fabricate(:category_channel, chatable: private_category) }
|
||||
fab!(:public_channel) { Fabricate(:category_channel) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:user_2) { Fabricate(:user, active: false) }
|
||||
fab!(:user_3) { Fabricate(:user, staged: true) }
|
||||
fab!(:user_4) { Fabricate(:user, suspended_till: 3.weeks.from_now) }
|
||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe Chat::ParsedMentions do
|
|||
fab!(:channel_member_2) { Fabricate(:user) }
|
||||
fab!(:channel_member_3) { Fabricate(:user) }
|
||||
fab!(:not_a_channel_member) { Fabricate(:user) }
|
||||
fab!(:chat_channel) { Fabricate(:chat_channel) }
|
||||
fab!(:chat_channel)
|
||||
|
||||
before do
|
||||
chat_channel.add(channel_member_1)
|
||||
|
|
|
@ -9,7 +9,7 @@ describe Chat::ReviewQueue do
|
|||
fab!(:flagger) { Fabricate(:user) }
|
||||
fab!(:chat_channel) { Fabricate(:category_channel) }
|
||||
fab!(:message) { Fabricate(:chat_message, user: message_poster, chat_channel: chat_channel) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
|
||||
let(:guardian) { Guardian.new(flagger) }
|
||||
let(:admin_guardian) { Guardian.new(admin) }
|
||||
|
|
|
@ -496,11 +496,11 @@ describe Chat::Message do
|
|||
end
|
||||
|
||||
describe "#rebake!" do
|
||||
fab!(:chat_message) { Fabricate(:chat_message) }
|
||||
fab!(:chat_message)
|
||||
|
||||
describe "hashtags" do
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:category)
|
||||
fab!(:group)
|
||||
fab!(:secure_category) { Fabricate(:private_category, group: group) }
|
||||
|
||||
before do
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Chat::ReviewableMessage, type: :model do
|
||||
fab!(:moderator) { Fabricate(:moderator) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:chat_channel) { Fabricate(:chat_channel) }
|
||||
fab!(:moderator)
|
||||
fab!(:user)
|
||||
fab!(:chat_channel)
|
||||
fab!(:chat_message) { Fabricate(:chat_message, chat_channel: chat_channel, user: user) }
|
||||
fab!(:reviewable) do
|
||||
Fabricate(:chat_reviewable_message, target: chat_message, created_by: moderator)
|
||||
|
|
|
@ -12,7 +12,7 @@ describe Chat do
|
|||
|
||||
describe "register_upload_unused" do
|
||||
fab!(:chat_channel) { Fabricate(:chat_channel, chatable: Fabricate(:category)) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:upload) { Fabricate(:upload, user: user, created_at: 1.month.ago) }
|
||||
fab!(:unused_upload) { Fabricate(:upload, user: user, created_at: 1.month.ago) }
|
||||
|
||||
|
@ -37,7 +37,7 @@ describe Chat do
|
|||
|
||||
describe "register_upload_in_use" do
|
||||
fab!(:chat_channel) { Fabricate(:chat_channel, chatable: Fabricate(:category)) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:message_upload) { Fabricate(:upload, user: user, created_at: 1.month.ago) }
|
||||
fab!(:draft_upload) { Fabricate(:upload, user: user, created_at: 1.month.ago) }
|
||||
fab!(:unused_upload) { Fabricate(:upload, user: user, created_at: 1.month.ago) }
|
||||
|
@ -75,7 +75,7 @@ describe Chat do
|
|||
let!(:user) { Fabricate(:user) }
|
||||
let!(:guardian) { Guardian.new(user) }
|
||||
let(:serializer) { UserCardSerializer.new(target_user, scope: guardian) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:group)
|
||||
|
||||
context "when chat enabled" do
|
||||
before { SiteSetting.chat_enabled = true }
|
||||
|
@ -127,7 +127,7 @@ describe Chat do
|
|||
|
||||
describe "chat oneboxes" do
|
||||
fab!(:chat_channel) { Fabricate(:category_channel) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
fab!(:chat_message) do
|
||||
Fabricate(:chat_message, chat_channel: chat_channel, user: user, message: "Hello world!")
|
||||
|
@ -184,7 +184,7 @@ describe Chat do
|
|||
end
|
||||
|
||||
describe "when a user is created" do
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:category)
|
||||
let(:user) { Fabricate(:user, last_seen_at: nil, first_seen_at: nil) }
|
||||
|
||||
it "queues a job to auto-join the user the first time they log in" do
|
||||
|
@ -210,7 +210,7 @@ describe Chat do
|
|||
end
|
||||
|
||||
describe "when category permissions change" do
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:category)
|
||||
|
||||
let(:chatters_group_permission) do
|
||||
{ chatters_group.name => CategoryGroup.permission_types[:full] }
|
||||
|
@ -261,7 +261,7 @@ describe Chat do
|
|||
SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:everyone]
|
||||
end
|
||||
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
let(:serializer) { CurrentUserSerializer.new(user, scope: Guardian.new(user)) }
|
||||
|
||||
|
@ -330,7 +330,7 @@ describe Chat do
|
|||
SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:everyone]
|
||||
end
|
||||
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
let(:serializer) { CurrentUserSerializer.new(user, scope: Guardian.new(user)) }
|
||||
|
||||
context "when no channels exist" do
|
||||
|
@ -370,7 +370,7 @@ describe Chat do
|
|||
end
|
||||
|
||||
describe "Deleting posts while deleting a user" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
it "queues a job to also delete chat messages" do
|
||||
deletion_opts = { delete_posts: true }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
RSpec.describe Chat::Channel::MessageCreationPolicy do
|
||||
subject(:policy) { described_class.new(context) }
|
||||
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
let(:guardian) { user.guardian }
|
||||
let(:context) { Service::Base::Context.build(channel: channel, guardian: guardian) }
|
||||
|
|
|
@ -295,7 +295,7 @@ describe Chat::ChannelMembershipsQuery do
|
|||
|
||||
context "when user is inactive" do
|
||||
fab!(:channel_1) { Fabricate(:category_channel) }
|
||||
fab!(:inactive_user) { Fabricate(:inactive_user) }
|
||||
fab!(:inactive_user)
|
||||
|
||||
before do
|
||||
Chat::UserChatChannelMembership.create(
|
||||
|
|
|
@ -4,9 +4,9 @@ require "rails_helper"
|
|||
|
||||
RSpec.describe Chat::ChatController do
|
||||
describe "#export_messages" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:moderator) { Fabricate(:moderator) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:user)
|
||||
fab!(:moderator)
|
||||
fab!(:admin)
|
||||
|
||||
it "enqueues the export job and logs into staff actions" do
|
||||
sign_in(admin)
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Chat::Admin::IncomingWebhooksController do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:admin)
|
||||
fab!(:user)
|
||||
fab!(:chat_channel1) { Fabricate(:category_channel) }
|
||||
fab!(:chat_channel2) { Fabricate(:category_channel) }
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ require "rails_helper"
|
|||
|
||||
describe Chat::Api::CategoryChatablesController do
|
||||
describe "#access_by_category" do
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:group)
|
||||
fab!(:private_category) { Fabricate(:private_category, group: group) }
|
||||
|
||||
context "when signed in as an admin" do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
|
||||
before { sign_in(admin) }
|
||||
|
||||
|
@ -90,7 +90,7 @@ describe Chat::Api::CategoryChatablesController do
|
|||
end
|
||||
|
||||
context "when signed in as a regular user" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Chat::Api::ChannelsArchivesController do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:user)
|
||||
fab!(:admin)
|
||||
fab!(:category)
|
||||
fab!(:channel) { Fabricate(:category_channel, chatable: category) }
|
||||
|
||||
let(:new_topic_params) do
|
||||
|
|
|
@ -230,8 +230,8 @@ RSpec.describe Chat::Api::ChannelsController do
|
|||
end
|
||||
|
||||
describe "#create" do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:admin)
|
||||
fab!(:category)
|
||||
|
||||
let(:params) do
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ RSpec.describe Chat::Api::HintsController do
|
|||
end
|
||||
|
||||
context "for logged in users" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:mentionable_group) do
|
||||
Fabricate(:group, mentionable_level: Group::ALIAS_LEVELS[:everyone])
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
RSpec.describe Chat::Api::ChannelMessagesController do
|
||||
fab!(:current_user) { Fabricate(:user) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
|
||||
before do
|
||||
SiteSetting.chat_enabled = true
|
||||
|
@ -68,7 +68,7 @@ RSpec.describe Chat::Api::ChannelMessagesController do
|
|||
|
||||
describe "for category" do
|
||||
fab!(:user_2) { Fabricate(:user) }
|
||||
fab!(:chat_channel) { Fabricate(:chat_channel) }
|
||||
fab!(:chat_channel)
|
||||
fab!(:message) { Fabricate(:chat_message, chat_channel: chat_channel, user: current_user) }
|
||||
fab!(:user_2_message) { Fabricate(:chat_message, chat_channel: chat_channel, user: user_2) }
|
||||
|
||||
|
@ -178,11 +178,11 @@ RSpec.describe Chat::Api::ChannelMessagesController do
|
|||
end
|
||||
end
|
||||
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
fab!(:another_user) { Fabricate(:user) }
|
||||
|
||||
describe "for category" do
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:category)
|
||||
fab!(:chat_channel) { Fabricate(:category_channel, chatable: category) }
|
||||
|
||||
it_behaves_like "chat_message_restoration"
|
||||
|
@ -199,8 +199,8 @@ RSpec.describe Chat::Api::ChannelMessagesController do
|
|||
end
|
||||
|
||||
describe "#create" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:user)
|
||||
fab!(:category)
|
||||
|
||||
let(:message) { "This is a message" }
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ RSpec.describe Chat::Api::ReadsController do
|
|||
|
||||
describe "#read" do
|
||||
describe "marking a single message read" do
|
||||
fab!(:chat_channel) { Fabricate(:chat_channel) }
|
||||
fab!(:chat_channel)
|
||||
fab!(:other_user) { Fabricate(:user) }
|
||||
fab!(:message_1) { Fabricate(:chat_message, chat_channel: chat_channel, user: other_user) }
|
||||
fab!(:message_2) { Fabricate(:chat_message, chat_channel: chat_channel, user: other_user) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
RSpec.describe Chat::Api::SummariesController do
|
||||
fab!(:current_user) { Fabricate(:user) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:group)
|
||||
let(:plugin) { Plugin::Instance.new }
|
||||
|
||||
before do
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Chat::ChatController do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:other_user) { Fabricate(:user) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:admin)
|
||||
fab!(:category)
|
||||
fab!(:chat_channel) { Fabricate(:category_channel, chatable: category) }
|
||||
fab!(:dm_chat_channel) { Fabricate(:direct_message_channel, users: [user, other_user, admin]) }
|
||||
fab!(:tag) { Fabricate(:tag) }
|
||||
fab!(:tag)
|
||||
|
||||
MESSAGE_COUNT = 70
|
||||
MESSAGE_COUNT.times do |n|
|
||||
|
|
|
@ -4,9 +4,9 @@ RSpec.describe CategoriesController do
|
|||
describe "#destroy" do
|
||||
subject(:destroy_category) { delete "/categories/#{category.slug}.json" }
|
||||
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
fab!(:category) { Fabricate(:category, user: admin) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
context "when user is staff" do
|
||||
before { sign_in(admin) }
|
||||
|
|
|
@ -4,7 +4,7 @@ require "rails_helper"
|
|||
|
||||
describe EmailController do
|
||||
describe "unsubscribing from chat email settings" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
it "updates an user chat summary frequency" do
|
||||
SiteSetting.chat_enabled = true
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Chat::DirectMessagesController do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:user1) { Fabricate(:user) }
|
||||
fab!(:user2) { Fabricate(:user) }
|
||||
fab!(:user3) { Fabricate(:user) }
|
||||
|
|
|
@ -5,9 +5,9 @@ require "rails_helper"
|
|||
describe Chat::ChannelSerializer do
|
||||
subject(:serializer) { described_class.new(chat_channel, scope: guardian, root: nil) }
|
||||
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:chat_channel) { Fabricate(:chat_channel) }
|
||||
fab!(:user)
|
||||
fab!(:admin)
|
||||
fab!(:chat_channel)
|
||||
|
||||
let(:guardian_user) { user }
|
||||
let(:guardian) { Guardian.new(guardian_user) }
|
||||
|
@ -52,7 +52,7 @@ describe Chat::ChannelSerializer do
|
|||
|
||||
describe "#meta" do
|
||||
context "for category channels" do
|
||||
fab!(:chat_channel) { Fabricate(:chat_channel) }
|
||||
fab!(:chat_channel)
|
||||
|
||||
it "has the required message_bus_last_ids keys and calls MessageBus" do
|
||||
MessageBus.expects(:last_id).with(Chat::Publisher.root_message_bus_channel(chat_channel.id))
|
||||
|
|
|
@ -56,7 +56,7 @@ RSpec.describe Chat::MessageUserSerializer do
|
|||
end
|
||||
|
||||
context "when user has a primary group" do
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:group)
|
||||
|
||||
before { params[:primary_group_id] = group.id }
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ require "rails_helper"
|
|||
RSpec.describe Chat::InReplyToSerializer do
|
||||
subject(:serializer) { described_class.new(message, scope: guardian, root: nil) }
|
||||
|
||||
fab!(:chat_channel) { Fabricate(:chat_channel) }
|
||||
fab!(:chat_channel)
|
||||
let(:guardian) { Guardian.new(Fabricate(:user)) }
|
||||
|
||||
describe "#user" do
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
RSpec.describe Chat::Action::PublishAndFollowDirectMessageChannel do
|
||||
subject(:action) { described_class.call(channel_membership: membership) }
|
||||
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
let(:membership) { user.user_chat_channel_memberships.last }
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ RSpec.describe Chat::CreateCategoryChannel do
|
|||
subject(:result) { described_class.call(params) }
|
||||
|
||||
fab!(:current_user) { Fabricate(:admin) }
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:category)
|
||||
let(:category_id) { category.id }
|
||||
|
||||
let(:guardian) { Guardian.new(current_user) }
|
||||
|
|
|
@ -22,7 +22,7 @@ RSpec.describe Chat::CreateMessage do
|
|||
describe ".call" do
|
||||
subject(:result) { described_class.call(params) }
|
||||
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:other_user) { Fabricate(:user) }
|
||||
fab!(:channel) { Fabricate(:chat_channel, threading_enabled: true) }
|
||||
fab!(:thread) { Fabricate(:chat_thread, channel: channel) }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
RSpec.describe Chat::ListChannelMessages do
|
||||
subject(:result) { described_class.call(params) }
|
||||
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:channel) { Fabricate(:chat_channel) }
|
||||
|
||||
let(:guardian) { Guardian.new(user) }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
RSpec.describe Chat::ListChannelThreadMessages do
|
||||
subject(:result) { described_class.call(params) }
|
||||
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:thread) do
|
||||
Fabricate(:chat_thread, channel: Fabricate(:chat_channel, threading_enabled: true))
|
||||
end
|
||||
|
|
|
@ -63,7 +63,7 @@ describe Chat::Publisher do
|
|||
describe ".publish_user_tracking_state!" do
|
||||
fab!(:channel) { Fabricate(:category_channel) }
|
||||
fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
let(:data) do
|
||||
MessageBus
|
||||
|
|
|
@ -652,7 +652,7 @@ RSpec.describe Chat::UpdateMessage do
|
|||
end
|
||||
|
||||
describe "watched words" do
|
||||
fab!(:watched_word) { Fabricate(:watched_word) }
|
||||
fab!(:watched_word)
|
||||
|
||||
it "errors when a blocked word is present" do
|
||||
chat_message = create_chat_message(user1, "something", public_chat_channel)
|
||||
|
|
|
@ -25,7 +25,7 @@ RSpec.shared_examples "channel access example" do |verb, endpoint, params|
|
|||
context "when channel can’t be seen by current user" do
|
||||
fab!(:chatable) { Fabricate(:private_category, group: Fabricate(:group)) }
|
||||
fab!(:chat_channel) { Fabricate(:category_channel, chatable: chatable) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:membership) do
|
||||
Fabricate(:user_chat_channel_membership, user: user, chat_channel: chat_channel)
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ RSpec.shared_examples "a chat channel model" do
|
|||
fab!(:user1) { Fabricate(:user) }
|
||||
fab!(:user2) { Fabricate(:user) }
|
||||
fab!(:staff) { Fabricate(:user, admin: true) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:group)
|
||||
fab!(:private_category) { Fabricate(:private_category, group: group) }
|
||||
fab!(:private_category_channel) { Fabricate(:category_channel, chatable: private_category) }
|
||||
fab!(:direct_message_channel) { Fabricate(:direct_message_channel, users: [user1, user2]) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe "Chat CSV exports", type: :system do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
let(:csv_export_pm_page) { PageObjects::Pages::CSVExportPM.new }
|
||||
|
||||
before do
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe "Anonymous", type: :system do
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:topic)
|
||||
|
||||
before { chat_system_bootstrap }
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
RSpec.describe "Summarize a channel since your last visit", type: :system, js: true do
|
||||
fab!(:current_user) { Fabricate(:user) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:group)
|
||||
let(:plugin) { Plugin::Instance.new }
|
||||
|
||||
fab!(:channel) { Fabricate(:chat_channel) }
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
describe "Using #hashtag autocompletion to search for and lookup channels", type: :system do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:channel1) { Fabricate(:chat_channel, name: "Music Lounge", slug: "music") }
|
||||
fab!(:channel2) { Fabricate(:chat_channel, name: "Random", slug: "random") }
|
||||
fab!(:category) { Fabricate(:category, name: "Raspberry", slug: "raspberry-beret") }
|
||||
fab!(:tag) { Fabricate(:tag, name: "razed") }
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:topic)
|
||||
fab!(:post) { Fabricate(:post, topic: topic) }
|
||||
fab!(:message1) { Fabricate(:chat_message, chat_channel: channel1) }
|
||||
let(:chat_page) { PageObjects::Pages::Chat.new }
|
||||
|
@ -128,7 +128,7 @@ describe "Using #hashtag autocompletion to search for and lookup channels", type
|
|||
end
|
||||
|
||||
context "when a user cannot access the category for a cooked channel hashtag" do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
fab!(:manager_group) { Fabricate(:group, name: "Managers") }
|
||||
fab!(:private_category) do
|
||||
Fabricate(:private_category, name: "Management", slug: "management", group: manager_group)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe "Navigation", type: :system do
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:category)
|
||||
fab!(:topic)
|
||||
fab!(:post) { Fabricate(:post, topic: topic) }
|
||||
fab!(:current_user) { Fabricate(:admin) }
|
||||
fab!(:category_channel) { Fabricate(:category_channel) }
|
||||
fab!(:category_channel)
|
||||
fab!(:category_channel_2) { Fabricate(:category_channel) }
|
||||
fab!(:message) { Fabricate(:chat_message, chat_channel: category_channel) }
|
||||
let(:chat_page) { PageObjects::Pages::Chat.new }
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe "Navigation", type: :system do
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:category)
|
||||
fab!(:topic)
|
||||
fab!(:post) { Fabricate(:post, topic: topic) }
|
||||
fab!(:user) { Fabricate(:admin) }
|
||||
fab!(:category_channel) { Fabricate(:category_channel) }
|
||||
fab!(:category_channel)
|
||||
fab!(:category_channel_2) { Fabricate(:category_channel) }
|
||||
let(:chat_page) { PageObjects::Pages::Chat.new }
|
||||
let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
RSpec.describe "Quoting chat message transcripts", type: :system do
|
||||
fab!(:current_user) { Fabricate(:user) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
fab!(:chat_channel_1) { Fabricate(:chat_channel) }
|
||||
|
||||
let(:cdp) { PageObjects::CDP.new }
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe "Visit channel", type: :system do
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:category)
|
||||
fab!(:topic)
|
||||
fab!(:post) { Fabricate(:post, topic: topic) }
|
||||
fab!(:current_user) { Fabricate(:user) }
|
||||
fab!(:category_channel_1) { Fabricate(:category_channel) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
describe "Local dates", type: :system do
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:topic)
|
||||
fab!(:current_user) { Fabricate(:user) }
|
||||
let(:year) { Time.zone.now.year + 1 }
|
||||
let(:month) { Time.zone.now.month }
|
||||
|
|
|
@ -5,7 +5,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
|
|||
fab!(:discobot_user) { narrative_bot.discobot_user }
|
||||
fab!(:discobot_username) { narrative_bot.discobot_username }
|
||||
fab!(:first_post) { Fabricate(:post, user: discobot_user) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
fab!(:topic) do
|
||||
Fabricate(
|
||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
|
|||
fab!(:discobot_user) { narrative_bot.discobot_user }
|
||||
fab!(:discobot_username) { narrative_bot.discobot_username }
|
||||
fab!(:first_post) { Fabricate(:post, user: discobot_user) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
fab!(:topic) do
|
||||
Fabricate(
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
RSpec.describe "discourse-presence" do
|
||||
describe "PresenceChannel configuration" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:user2) { Fabricate(:user) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
|
||||
fab!(:group) do
|
||||
group = Fabricate(:group)
|
||||
|
|
|
@ -4,7 +4,7 @@ require "rails_helper"
|
|||
|
||||
RSpec.describe "DiscoursePoll endpoints" do
|
||||
describe "fetch voters for a poll" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:post) { Fabricate(:post, raw: "[poll public=true]\n- A\n- B\n[/poll]") }
|
||||
|
||||
fab!(:post_with_multiple_poll) { Fabricate(:post, raw: <<~SQL) }
|
||||
|
@ -222,8 +222,8 @@ RSpec.describe "DiscoursePoll endpoints" do
|
|||
end
|
||||
|
||||
context "when topic is in a private category" do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:admin)
|
||||
fab!(:group)
|
||||
fab!(:private_category) { Fabricate(:private_category, group: group) }
|
||||
fab!(:private_topic) { Fabricate(:topic, category: private_category) }
|
||||
fab!(:private_post) { Fabricate(:post, topic: private_topic, raw: <<~SQL) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe DiscoursePoll::Poll do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:user_2) { Fabricate(:user) }
|
||||
|
||||
fab!(:post_with_regular_poll) { Fabricate(:post, raw: <<~RAW) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Search do
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:topic)
|
||||
fab!(:topic2) { Fabricate(:topic) }
|
||||
fab!(:regular_post) { Fabricate(:post, topic: topic, raw: <<~RAW) }
|
||||
Somewhere over the rainbow but no poll.
|
||||
|
|
|
@ -454,7 +454,7 @@ RSpec.describe ApplicationHelper do
|
|||
end
|
||||
|
||||
describe "#html_classes" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
it "includes 'rtl' when the I18n.locale is rtl" do
|
||||
I18n.stubs(:locale).returns(:he)
|
||||
|
@ -679,7 +679,7 @@ RSpec.describe ApplicationHelper do
|
|||
end
|
||||
|
||||
describe "discourse_color_scheme_stylesheets" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
it "returns a stylesheet link tag by default" do
|
||||
cs_stylesheets = helper.discourse_color_scheme_stylesheets
|
||||
|
@ -797,7 +797,7 @@ RSpec.describe ApplicationHelper do
|
|||
end
|
||||
|
||||
describe "html_lang" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
before do
|
||||
I18n.locale = :de
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
require "import_export"
|
||||
|
||||
RSpec.describe ImportExport::CategoryExporter do
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:category)
|
||||
fab!(:group)
|
||||
fab!(:user)
|
||||
fab!(:user2) { Fabricate(:user) }
|
||||
fab!(:user3) { Fabricate(:user) }
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ require "import_export"
|
|||
RSpec.describe ImportExport::TopicExporter do
|
||||
before { STDOUT.stubs(:write) }
|
||||
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:topic) { Fabricate(:topic, user: user) }
|
||||
fab!(:post) { Fabricate(:post, topic: topic, user: user) }
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe "Webhook event handlers" do
|
||||
fab!(:user_badge) { Fabricate(:user_badge) }
|
||||
fab!(:user_badge)
|
||||
fab!(:web_hook) { Fabricate(:user_badge_web_hook) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:badge) { Fabricate(:badge) }
|
||||
fab!(:post) { Fabricate(:post) }
|
||||
fab!(:user)
|
||||
fab!(:badge)
|
||||
fab!(:post)
|
||||
|
||||
describe "user_badge events" do
|
||||
it "enqueues user_badge_granted webhook event" do
|
||||
|
|
|
@ -12,8 +12,8 @@ RSpec.describe "category tag restrictions" do
|
|||
fab!(:tag4) { Fabricate(:tag, name: "tag4") }
|
||||
let(:tag_with_colon) { Fabricate(:tag, name: "with:colon") }
|
||||
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:user)
|
||||
fab!(:admin)
|
||||
|
||||
before do
|
||||
SiteSetting.tagging_enabled = true
|
||||
|
@ -275,7 +275,7 @@ RSpec.describe "category tag restrictions" do
|
|||
|
||||
context "with tag groups restricted to a category" do
|
||||
fab!(:tag_group1) { Fabricate(:tag_group) }
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:category)
|
||||
fab!(:other_category) { Fabricate(:category) }
|
||||
|
||||
before do
|
||||
|
@ -760,8 +760,8 @@ RSpec.describe "category tag restrictions" do
|
|||
end
|
||||
|
||||
RSpec.describe "tag topic counts per category" do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:admin)
|
||||
fab!(:category)
|
||||
fab!(:category2) { Fabricate(:category) }
|
||||
fab!(:tag1) { Fabricate(:tag) }
|
||||
fab!(:tag2) { Fabricate(:tag) }
|
||||
|
|
|
@ -25,7 +25,7 @@ RSpec.describe EmailStyle do
|
|||
context "with invite" do
|
||||
subject(:mail_html) { Email::Renderer.new(invite_mail).html }
|
||||
|
||||
fab!(:invite) { Fabricate(:invite) }
|
||||
fab!(:invite)
|
||||
|
||||
let(:invite_mail) { InviteMailer.send_invite(invite) }
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
describe "Secure uploads" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:user)
|
||||
fab!(:group)
|
||||
fab!(:secure_category) { Fabricate(:private_category, group: group) }
|
||||
|
||||
before do
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
RSpec.describe "spam rules for users" do
|
||||
describe "auto-silence users based on flagging" do
|
||||
fab!(:admin) { Fabricate(:admin) } # needed to send a system message
|
||||
fab!(:moderator) { Fabricate(:moderator) }
|
||||
fab!(:admin) # needed to send a system message
|
||||
fab!(:moderator)
|
||||
fab!(:user1) { Fabricate(:user) }
|
||||
fab!(:user2) { Fabricate(:user) }
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
RSpec.describe "Updating tag counts" do
|
||||
fab!(:tag1) { Fabricate(:tag) }
|
||||
fab!(:tag2) { Fabricate(:tag) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:group)
|
||||
fab!(:public_category) { Fabricate(:category) }
|
||||
fab!(:public_category2) { Fabricate(:category) }
|
||||
fab!(:private_category) { Fabricate(:private_category, group: group) }
|
||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe "Topic Thumbnails" do
|
|||
|
||||
fab!(:image) { Fabricate(:image_upload, width: 50, height: 50) }
|
||||
fab!(:topic) { Fabricate(:topic, image_upload_id: image.id) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
describe "latest" do
|
||||
def get_topic
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
RSpec.describe WatchedWord do
|
||||
fab!(:tl2_user) { Fabricate(:user, trust_level: TrustLevel[2]) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:moderator) { Fabricate(:moderator) }
|
||||
fab!(:admin)
|
||||
fab!(:moderator)
|
||||
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:topic)
|
||||
fab!(:first_post) { Fabricate(:post, topic: topic) }
|
||||
|
||||
let(:require_approval_word) do
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe ::Jobs::AdminProblems do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
|
||||
it "creates notification when problems persist for at least 2 days" do
|
||||
Discourse.redis.setex(AdminDashboardData.problems_started_key, 14.days.to_i, Time.zone.now.to_s)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
RSpec.describe Jobs::BookmarkReminderNotifications do
|
||||
subject(:job) { described_class.new }
|
||||
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
let(:five_minutes_ago) { Time.zone.now - 5.minutes }
|
||||
let(:bookmark1) { Fabricate(:bookmark, user: user) }
|
||||
let(:bookmark2) { Fabricate(:bookmark, user: user) }
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
RSpec.describe Jobs::BulkInvite do
|
||||
describe "#execute" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:east_coast_user) { Fabricate(:east_coast_user) }
|
||||
fab!(:user)
|
||||
fab!(:admin)
|
||||
fab!(:east_coast_user)
|
||||
fab!(:group1) { Fabricate(:group, name: "group1") }
|
||||
fab!(:group2) { Fabricate(:group, name: "group2") }
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:topic)
|
||||
let(:staged_user) { Fabricate(:user, staged: true, active: false) }
|
||||
let(:email) { "test@discourse.org" }
|
||||
let(:invites) do
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Jobs::BumpTopic do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:admin)
|
||||
fab!(:user)
|
||||
|
||||
it "can bump a topic" do
|
||||
topic = Fabricate(:topic_timer, user: admin).topic
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Jobs::CleanUpUserExportTopics do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
it "should delete ancient user export system messages" do
|
||||
post_en =
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Jobs::CloseTopic do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
|
||||
fab!(:topic) { Fabricate(:topic_timer, user: admin).topic }
|
||||
|
||||
|
@ -48,7 +48,7 @@ RSpec.describe Jobs::CloseTopic do
|
|||
end
|
||||
|
||||
describe "when user is no longer authorized to close topics" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
fab!(:topic) { Fabricate(:topic_timer, user: user).topic }
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe Jobs::CreateLinkedTopic do
|
|||
end
|
||||
|
||||
context "with a post" do
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:category)
|
||||
fab!(:topic) { Fabricate(:topic, category: category) }
|
||||
fab!(:post) { Fabricate(:post, topic: topic) }
|
||||
fab!(:user_1) { Fabricate(:user) }
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Jobs::DeleteReplies do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:topic)
|
||||
fab!(:topic_timer) do
|
||||
Fabricate(
|
||||
:topic_timer,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Jobs::DeleteTopic do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
|
||||
fab!(:topic) { Fabricate(:topic_timer, user: admin).topic }
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
RSpec.describe Jobs::DisableBootstrapMode do
|
||||
describe ".execute" do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
|
||||
before do
|
||||
SiteSetting.bootstrap_mode_enabled = true
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Jobs::DownloadAvatarFromUrl do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
describe "when url is invalid" do
|
||||
it "should not raise any error" do
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Jobs::DownloadProfileBackgroundFromUrl do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
describe "when url is invalid" do
|
||||
it "should not raise any error" do
|
||||
|
|
|
@ -7,8 +7,8 @@ RSpec.describe Jobs::EmitWebHookEvent do
|
|||
|
||||
fab!(:post_hook) { Fabricate(:web_hook) }
|
||||
fab!(:inactive_hook) { Fabricate(:inactive_web_hook) }
|
||||
fab!(:post) { Fabricate(:post) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:post)
|
||||
fab!(:user)
|
||||
|
||||
it "raises an error when there is no web hook record" do
|
||||
expect { job.execute(event_type: "post", payload: {}) }.to raise_error(
|
||||
|
@ -175,8 +175,8 @@ RSpec.describe Jobs::EmitWebHookEvent do
|
|||
end
|
||||
|
||||
context "with category filters" do
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:category)
|
||||
fab!(:topic)
|
||||
fab!(:topic_with_category) { Fabricate(:topic, category_id: category.id) }
|
||||
fab!(:topic_hook) { Fabricate(:topic_web_hook, categories: [category]) }
|
||||
|
||||
|
@ -204,7 +204,7 @@ RSpec.describe Jobs::EmitWebHookEvent do
|
|||
end
|
||||
|
||||
context "with tag filters" do
|
||||
fab!(:tag) { Fabricate(:tag) }
|
||||
fab!(:tag)
|
||||
fab!(:topic) { Fabricate(:topic, tags: [tag]) }
|
||||
fab!(:topic_hook) { Fabricate(:topic_web_hook, tags: [tag]) }
|
||||
|
||||
|
@ -240,7 +240,7 @@ RSpec.describe Jobs::EmitWebHookEvent do
|
|||
end
|
||||
|
||||
context "with group filters" do
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:group)
|
||||
fab!(:user) { Fabricate(:user, groups: [group]) }
|
||||
fab!(:like_hook) { Fabricate(:like_web_hook, groups: [group]) }
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
RSpec.describe Jobs::EnableBootstrapMode do
|
||||
describe ".execute" do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
|
||||
before { SiteSetting.bootstrap_mode_enabled = false }
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe Jobs::ExportUserArchive do
|
|||
end
|
||||
let(:component) { raise "component not set" }
|
||||
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
fab!(:category) { Fabricate(:category_with_definition, name: "User Archive Category") }
|
||||
fab!(:subcategory) { Fabricate(:category_with_definition, parent_category_id: category.id) }
|
||||
fab!(:topic) { Fabricate(:topic, category: category) }
|
||||
|
|
|
@ -12,8 +12,8 @@ RSpec.describe Jobs::FeatureTopicUsers do
|
|||
context "with a topic" do
|
||||
let!(:post) { create_post }
|
||||
let(:topic) { post.topic }
|
||||
fab!(:coding_horror) { Fabricate(:coding_horror) }
|
||||
fab!(:evil_trout) { Fabricate(:evil_trout) }
|
||||
fab!(:coding_horror)
|
||||
fab!(:evil_trout)
|
||||
let!(:second_post) { create_post(topic: topic, user: coding_horror) }
|
||||
let!(:third_post) { create_post(topic: topic, user: evil_trout) }
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ RSpec.describe Jobs::InviteEmail do
|
|||
let (:mailer) {
|
||||
Mail::Message.new(to: "eviltrout@test.domain")
|
||||
}
|
||||
fab!(:invite) { Fabricate(:invite) }
|
||||
fab!(:invite)
|
||||
|
||||
it "delegates to the test mailer" do
|
||||
Email::Sender.any_instance.expects(:send)
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
RSpec.describe Jobs::MassAwardBadge do
|
||||
describe "#execute" do
|
||||
fab!(:badge) { Fabricate(:badge) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:badge)
|
||||
fab!(:user)
|
||||
let(:email_mode) { "email" }
|
||||
|
||||
it "creates the badge for an existing user" do
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe ::Jobs::NotifyCategoryChange do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:regular_user) { Fabricate(:trust_level_4) }
|
||||
fab!(:post) { Fabricate(:post, user: regular_user) }
|
||||
fab!(:category) { Fabricate(:category, name: "test") }
|
||||
|
|
|
@ -8,9 +8,9 @@ RSpec.describe Jobs::NotifyMailingListSubscribers do
|
|||
end
|
||||
before { SiteSetting.tagging_enabled = true }
|
||||
|
||||
fab!(:tag) { Fabricate(:tag) }
|
||||
fab!(:tag)
|
||||
fab!(:topic) { Fabricate(:topic, tags: [tag]) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:post) { Fabricate(:post, topic: topic, user: user) }
|
||||
|
||||
shared_examples "no emails" do
|
||||
|
|
|
@ -17,7 +17,7 @@ RSpec.describe Jobs::NotifyMovedPosts do
|
|||
fab!(:p1) { Fabricate(:post) }
|
||||
fab!(:p2) { Fabricate(:post, user: Fabricate(:evil_trout), topic: p1.topic) }
|
||||
fab!(:p3) { Fabricate(:post, user: p1.user, topic: p1.topic) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
|
||||
let(:moved_post_notifications) do
|
||||
Notification.where(notification_type: Notification.types[:moved_post])
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
RSpec.describe Jobs::NotifyReviewable do
|
||||
describe "#execute" do
|
||||
fab!(:admin) { Fabricate(:admin, moderator: true) }
|
||||
fab!(:moderator) { Fabricate(:moderator) }
|
||||
fab!(:group_user) { Fabricate(:group_user) }
|
||||
fab!(:moderator)
|
||||
fab!(:group_user)
|
||||
fab!(:group) { group_user.group }
|
||||
fab!(:user) { group_user.user }
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe ::Jobs::NotifyTagChange do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
fab!(:regular_user) { Fabricate(:trust_level_4) }
|
||||
fab!(:post) { Fabricate(:post, user: regular_user) }
|
||||
fab!(:tag) { Fabricate(:tag, name: "test") }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Jobs::OpenTopic do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:admin)
|
||||
|
||||
fab!(:topic) { Fabricate(:topic_timer, user: admin).topic }
|
||||
|
||||
|
@ -49,7 +49,7 @@ RSpec.describe Jobs::OpenTopic do
|
|||
end
|
||||
|
||||
describe "when user is no longer authorized to open topics" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
|
||||
fab!(:topic) { Fabricate(:topic_timer, user: user).topic }
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
RSpec.describe Jobs::PostUpdateTopicTrackingState do
|
||||
subject(:job) { described_class.new }
|
||||
|
||||
fab!(:post) { Fabricate(:post) }
|
||||
fab!(:post)
|
||||
|
||||
it "should publish messages" do
|
||||
messages = MessageBus.track_publish { job.execute({ post_id: post.id }) }
|
||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe Jobs::ProcessPost do
|
|||
end
|
||||
|
||||
context "with a post" do
|
||||
fab!(:post) { Fabricate(:post) }
|
||||
fab!(:post)
|
||||
|
||||
it "does not erase posts when CookedPostProcessor malfunctions" do
|
||||
# Look kids, an actual reason why you want to use mocks
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
RSpec.describe Jobs::ProcessShelvedNotifications do
|
||||
subject(:job) { described_class.new }
|
||||
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:user)
|
||||
let(:post) { Fabricate(:post) }
|
||||
|
||||
it "removes all past do not disturb timings" do
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user