Add tests for inbox locking

This commit is contained in:
Andreas Nedbal 2022-11-06 15:02:12 +01:00
parent 8bdf00e0e8
commit fdf42d4169
2 changed files with 28 additions and 0 deletions

View File

@ -328,6 +328,23 @@ describe Ajax::QuestionController, :ajax_controller, type: :controller do
include_examples "does not create the question"
end
end
context "when users inbox is locked" do
let(:user_allows_anonymous_questions) { true }
let(:expected_response) do
{
"success" => false,
"status" => "inbox_locked",
"message" => anything
}
end
before do
target_user.update(privacy_lock_inbox: true)
end
include_examples "does not create the question"
end
end
context "when rcpt is followers" do

View File

@ -40,5 +40,16 @@ describe QuestionWorker do
.to(4)
)
end
it "respects inbox locks" do
user.followers.first.update(privacy_lock_inbox: true)
expect { subject }
.to(
change { Inbox.where(user_id: user.followers.ids, question_id: question_id, new: true).count }
.from(0)
.to(4)
)
end
end
end