diff --git a/spec/lib/use_case/question/create_followers_spec.rb b/spec/lib/use_case/question/create_followers_spec.rb index b5511459..00331cbb 100644 --- a/spec/lib/use_case/question/create_followers_spec.rb +++ b/spec/lib/use_case/question/create_followers_spec.rb @@ -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 diff --git a/spec/lib/use_case/question/create_spec.rb b/spec/lib/use_case/question/create_spec.rb index a31e9073..a5ee2bd9 100644 --- a/spec/lib/use_case/question/create_spec.rb +++ b/spec/lib/use_case/question/create_spec.rb @@ -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