Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent unlettered submissions of quotes #157

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add tests for the minimum and maximum length of a quote
lef237 committed Dec 4, 2023
commit e69ec4dcdc0310ebedbcfdc9420a37ed83f52b49
4 changes: 2 additions & 2 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
@@ -17,5 +17,5 @@ ja:
quote:
attributes:
sentence:
too_short: "文が短すぎます。最低限の長さは%{count}文字です。"
too_long: "文が長すぎます。最大の長さは%{count}文字です。"
too_short: "文が短すぎます。引用文は%{count}文字以上で入力してください。"
too_long: "文が長すぎます。引用文は%{count}文字以内で入力してください。"
12 changes: 12 additions & 0 deletions spec/system/quote_edit_spec.rb
Original file line number Diff line number Diff line change
@@ -34,6 +34,18 @@
expect(page).to have_content('まだ引用はありません')
expect(page).not_to have_content('これはテストの引用文です。')
end

# 0文字の投稿を禁じる
it 'does not create a quote with 0 characters' do
add_quote('', 42)
expect(page).to have_content('引用文は1文字以上で入力してください')
end

# 301文字の投稿を禁じる
it 'does not create a quote with 301 characters' do
add_quote('a' * 301, 42)
expect(page).to have_content('引用文は300文字以内で入力してください')
end
end

private