Add tests for sending long questions with question worker
This commit is contained in:
parent
cfba963b55
commit
4e78efcae7
|
@ -30,7 +30,7 @@ class QuestionWorker
|
|||
return true if follower.banned?
|
||||
return true if muted?(follower, question)
|
||||
return true if user.muting?(question.user)
|
||||
return true if question.long? && !user.profile.allow_long_questions
|
||||
return true if question.long? && !follower.profile.allow_long_questions
|
||||
|
||||
false
|
||||
end
|
||||
|
|
|
@ -6,7 +6,8 @@ describe QuestionWorker do
|
|||
describe "#perform" do
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
let(:user_id) { user.id }
|
||||
let(:question) { FactoryBot.create(:question, user:) }
|
||||
let(:content) { Faker::Lorem.sentence }
|
||||
let(:question) { FactoryBot.create(:question, content:, user:) }
|
||||
let(:question_id) { question.id }
|
||||
|
||||
before do
|
||||
|
@ -92,5 +93,20 @@ describe QuestionWorker do
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
context "long question" do
|
||||
let(:content) { "x" * 1000 }
|
||||
|
||||
it "sends to recipients who allow long questions" do
|
||||
user.followers.first.profile.update(allow_long_questions: true)
|
||||
|
||||
expect { subject }
|
||||
.to(
|
||||
change { Inbox.where(user_id: user.followers.ids, question_id:, new: true).count }
|
||||
.from(0)
|
||||
.to(1)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue