discourse/spec/fabricators/bookmark_fabricator.rb
Martin Brennan b8828d4a2d
FEATURE: Polymorphic bookmarks pt. 1 (CRUD) (#16308)
This commit introduces a new use_polymorphic_bookmarks site setting
that is default false and hidden, that will be used to help continuous
development of polymorphic bookmarks. This setting **should not** be
enabled anywhere in production yet, it is purely for local development.

This commit uses the setting to enable create/update/delete actions
for polymorphic bookmarks on the server and client side. The bookmark
interactions on topics/posts are all usable. Listing, searching,
sending bookmark reminders, and other edge cases will be handled
in subsequent PRs.

Comprehensive UI tests will be added in the final PR -- we already
have them for regular bookmarks, so it will just be a matter of
changing them to be for polymorphic bookmarks.
2022-03-30 12:43:11 +10:00

33 lines
822 B
Ruby

# frozen_string_literal: true
Fabricator(:bookmark) do
user
post { Fabricate(:post) }
name "This looked interesting"
reminder_at { 1.day.from_now.iso8601 }
reminder_set_at { Time.zone.now }
# TODO (martin) [POLYBOOK] Not relevant once polymorphic bookmarks are implemented.
before_create do |bookmark|
if bookmark.bookmarkable_id.present? || bookmark.bookmarkable.present?
bookmark.post = nil
bookmark.post_id = nil
bookmark.for_topic = false
end
end
end
Fabricator(:bookmark_next_business_day_reminder, from: :bookmark) do
reminder_at do
date = if Time.zone.now.friday?
Time.zone.now + 3.days
elsif Time.zone.now.saturday?
Time.zone.now + 2.days
else
Time.zone.now + 1.day
end
date.iso8601
end
reminder_set_at { Time.zone.now }
end