Skip to content

Commit

Permalink
AO3-6868 Change short limit from 5 to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
connie-feng committed Dec 28, 2024
1 parent e25ad32 commit 35eb306
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/language.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Language < ApplicationRecord
include WorksOwner
validates :short, presence: true, uniqueness: true, length: { maximum: 5 }
validates :short, presence: true, uniqueness: true, length: { maximum: 4 }

Check warning on line 3 in app/models/language.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Uniqueness validation should have a unique index on the database column. Raw Output: app/models/language.rb:3:3: C: Rails/UniqueValidationWithoutIndex: Uniqueness validation should have a unique index on the database column.
validates :name, presence: true, uniqueness: true

Check warning on line 4 in app/models/language.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Uniqueness validation should have a unique index on the database column. Raw Output: app/models/language.rb:4:3: C: Rails/UniqueValidationWithoutIndex: Uniqueness validation should have a unique index on the database column.

has_many :works
Expand Down
6 changes: 3 additions & 3 deletions spec/models/language_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

describe "validations" do
context "for :short" do
it "is valid with a value 5 characters or fewer" do
it "is valid with a value 4 characters or fewer" do
korean = Language.new(name: "Korean", short: "ko")

expect(korean).to be_valid
end

it "is invalid if longer than 5 characters" do
it "is invalid if longer than 4 characters" do
korean = Language.new(name: "Korean", short: "korean")

expect(korean).not_to be_valid
expect(korean.errors[:short]).to include("is too long (maximum is 5 characters)")
expect(korean.errors[:short]).to include("is too long (maximum is 4 characters)")
end
end

Expand Down

0 comments on commit 35eb306

Please sign in to comment.