discourse/spec/jobs/notify_category_change_spec.rb
Daniel Waterworth 6e161d3e75
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.
2023-11-09 16:47:59 -06:00

23 lines
710 B
Ruby

# frozen_string_literal: true
RSpec.describe ::Jobs::NotifyCategoryChange do
fab!(:user)
fab!(:regular_user) { Fabricate(:trust_level_4) }
fab!(:post) { Fabricate(:post, user: regular_user) }
fab!(:category) { Fabricate(:category, name: "test") }
it "doesn't create notification for the editor who watches new tag" do
CategoryUser.set_notification_level_for_category(
user,
CategoryUser.notification_levels[:watching_first_post],
category.id,
)
post.topic.update!(category: category)
post.update!(last_editor_id: user.id)
expect { described_class.new.execute(post_id: post.id, notified_user_ids: []) }.not_to change {
Notification.count
}
end
end