Add specs to check for upper maximum question length

This commit is contained in:
Andreas Nedbal 2024-03-10 20:30:47 +01:00 committed by Andreas Nedbal
parent b7e8187cd4
commit 70f6e581b6
2 changed files with 29 additions and 0 deletions

View File

@ -36,5 +36,13 @@ describe UseCase::Question::CreateFollowers do
it "increments the asked count" do
expect { subject }.to change { source_user.reload.asked_count }.by(1)
end
context "content is over 32768 characters long" do
let(:content) { "a" * 32769 }
it "raises an error" do
expect { subject }.to raise_error(Errors::QuestionTooLong)
end
end
end
end

View File

@ -75,6 +75,27 @@ describe UseCase::Question::Create do
it_behaves_like "creates the question"
end
end
context "content is over 32768 characters long" do
let(:content) { "a" * 32769 }
context "recipient does not allow long questions" do
it "raises an error" do
expect { subject }.to raise_error(Errors::QuestionTooLong)
end
end
context "recipient allows long questions" do
before do
target_user.profile.allow_long_questions = true
target_user.profile.save
end
it "raises an error" do
expect { subject }.to raise_error(Errors::QuestionTooLong)
end
end
end
end
shared_examples "filters questions" do