Skip to content

Commit

Permalink
AO3-6820: add presence validation to belongs_to instead
Browse files Browse the repository at this point in the history
  • Loading branch information
lou-codes committed Feb 1, 2025
1 parent 97fa3e6 commit 4655053
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions app/models/bookmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ class Bookmark < ApplicationRecord
include Taggable

belongs_to :bookmarkable, polymorphic: true, inverse_of: :bookmarks
belongs_to :pseud
validates :pseud_id, presence: true
belongs_to :pseud, optional: false

validates_length_of :bookmarker_notes,
maximum: ArchiveConfig.NOTES_MAX, too_long: ts("must be less than %{max} letters long.", max: ArchiveConfig.NOTES_MAX)
Expand Down
2 changes: 1 addition & 1 deletion spec/models/bookmark_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
it "is invalid without a pseud_id" do
bookmark = build(:bookmark, pseud_id: nil)
expect(bookmark).to_not be_valid
expect(bookmark.errors[:pseud_id].first).to include("can't be blank")
expect(bookmark.errors[:pseud].first).to include("must exist")
end
end

0 comments on commit 4655053

Please sign in to comment.