discourse/spec/jobs/bump_topic_spec.rb
Jarek Radosz 694b5f108b
DEV: Fix various rubocop lints (#24749)
These (21 + 3 from previous PRs) are soon to be enabled in rubocop-discourse:

Capybara/VisibilityMatcher
Lint/DeprecatedOpenSSLConstant
Lint/DisjunctiveAssignmentInConstructor
Lint/EmptyConditionalBody
Lint/EmptyEnsure
Lint/LiteralInInterpolation
Lint/NonLocalExitFromIterator
Lint/ParenthesesAsGroupedExpression
Lint/RedundantCopDisableDirective
Lint/RedundantRequireStatement
Lint/RedundantSafeNavigation
Lint/RedundantStringCoercion
Lint/RedundantWithIndex
Lint/RedundantWithObject
Lint/SafeNavigationChain
Lint/SafeNavigationConsistency
Lint/SelfAssignment
Lint/UnreachableCode
Lint/UselessMethodDefinition
Lint/Void

Previous PRs:
Lint/ShadowedArgument
Lint/DuplicateMethods
Lint/BooleanSymbol
RSpec/SpecFilePathSuffix
2023-12-06 23:25:00 +01:00

35 lines
892 B
Ruby

# frozen_string_literal: true
RSpec.describe Jobs::BumpTopic do
fab!(:admin)
fab!(:user)
it "can bump a topic" do
topic = Fabricate(:topic_timer, user: admin).topic
create_post(topic: topic)
freeze_time(2.hours.from_now)
expect do
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id)
end.to change { topic.posts.count }.by(1)
expect(topic.reload.public_topic_timer).to eq(nil)
end
it "respects the guardian" do
topic = Fabricate(:topic_timer, user: user).topic
create_post(topic: topic)
topic.category = Fabricate(:private_category, group: Fabricate(:group))
topic.save!
freeze_time(2.hours.from_now)
expect do
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id)
end.not_to change { topic.posts.count }
expect(topic.reload.public_topic_timer).to eq(nil)
end
end