Skip to content
This repository has been archived by the owner on Sep 23, 2022. It is now read-only.

Commit

Permalink
refactor spec
Browse files Browse the repository at this point in the history
  • Loading branch information
broothie committed Apr 23, 2022
1 parent 4ac8bb8 commit 7bd4d8d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/jobs/message_deletion_job.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class MessageDeletionJob
include Sidekiq::Worker

MAX_MESSAGE_COUNT = ENV.fetch('MAX_MESSAGE_COUNT', 9000).to_i

def perform
message_surplus = Message.count - max_message_count
return if message_surplus <= 0
Expand All @@ -16,6 +18,6 @@ def perform
private

def max_message_count
ENV.fetch('MAX_MESSAGE_COUNT', 9000).to_i
MAX_MESSAGE_COUNT
end
end
2 changes: 1 addition & 1 deletion spec/jobs/message_deletion_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let(:messages) { Array.new(count) { FactoryBot.create(:message, channel: channel) } }

before do
allow(ENV).to receive(:fetch).with('MAX_MESSAGE_COUNT', 9000).and_return(max)
allow(job).to receive(:max_message_count).and_return(max)

messages
end
Expand Down

0 comments on commit 7bd4d8d

Please sign in to comment.