mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 11:03:41 +08:00
4ea21fa2d0
This change both speeds up specs (less strings to allocate) and helps catch cases where methods in Discourse are mutating inputs. Overall we will be migrating everything to use #frozen_string_literal: true it will take a while, but this is the first and safest move in this direction
28 lines
763 B
Ruby
28 lines
763 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe Jobs::CleanUpPostReplyKeys do
|
|
it 'removes old post_reply_keys' do
|
|
freeze_time
|
|
|
|
reply_key1 = Fabricate(:post_reply_key, created_at: 1.day.ago)
|
|
reply_key2 = Fabricate(:post_reply_key, created_at: 2.days.ago)
|
|
Fabricate(:post_reply_key, created_at: 3.days.ago)
|
|
|
|
SiteSetting.disallow_reply_by_email_after_days = 0
|
|
|
|
expect { Jobs::CleanUpPostReplyKeys.new.execute({}) }
|
|
.to change { PostReplyKey.count }.by(0)
|
|
|
|
SiteSetting.disallow_reply_by_email_after_days = 2
|
|
|
|
expect { Jobs::CleanUpPostReplyKeys.new.execute({}) }
|
|
.to change { PostReplyKey.count }.by(-1)
|
|
|
|
expect(PostReplyKey.all).to contain_exactly(
|
|
reply_key1, reply_key2
|
|
)
|
|
end
|
|
end
|