Skip to content

Commit

Permalink
AO3-6820: switch back to separate pseud validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lou-codes committed Jan 31, 2025
1 parent 4200240 commit c8c28e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/models/bookmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class Bookmark < ApplicationRecord
include Taggable

belongs_to :bookmarkable, polymorphic: true, inverse_of: :bookmarks
belongs_to :pseud, required: true
belongs_to :pseud
validates_presence_of :pseud_id

Check warning on line 9 in app/models/bookmark.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Prefer the new style validations `validates :column, presence: value` over `validates_presence_of`. Raw Output: app/models/bookmark.rb:9:3: C: Rails/Validation: Prefer the new style validations `validates :column, presence: value` over `validates_presence_of`.

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
3 changes: 0 additions & 3 deletions features/bookmarks/bookmark_create.feature
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,6 @@ Scenario: I cannot create a bookmark that I don't own
When I attempt to create a bookmark of "Random Work" with a pseud that is not mine
Then I should not see "Bookmark was successfully created"
And I should see "You can't bookmark with that pseud."
When I attempt to create a bookmark of "Random Work" without a pseud
Then I should not see "Bookmark was successfully created"
And I should see "Pseud can't be blank"

Scenario: I cannot edit an existing bookmark to transfer it to a pseud I don't own
Given I am logged in as "original_bookmarker"
Expand Down
6 changes: 6 additions & 0 deletions spec/models/bookmark_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@
it "has a valid factory for series bookmarks" do
expect(build(:series_bookmark)).to be_valid
end

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")
end
end

0 comments on commit c8c28e4

Please sign in to comment.