mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 09:14:14 +08:00
03c012bd97
* we want to be able to get these records for the bookmark even if they are trashed, for serialization for the bookmark list
36 lines
866 B
Ruby
36 lines
866 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe UserBookmarkSerializer do
|
|
let(:bookmark) do
|
|
Fabricate(:bookmark)
|
|
Bookmark.all.includes(post: :user).includes(:topic).last
|
|
end
|
|
|
|
subject { described_class.new(bookmark) }
|
|
|
|
context "when the topic is deleted" do
|
|
before do
|
|
bookmark.topic.trash!
|
|
bookmark.reload
|
|
end
|
|
it "still returns the topic title because the relationship is unscoped" do
|
|
expect(subject.title).not_to eq(nil)
|
|
end
|
|
end
|
|
|
|
context "when the post is deleted" do
|
|
before do
|
|
bookmark.post.trash!
|
|
bookmark.reload
|
|
end
|
|
it "still returns the post number because the relationship is unscoped" do
|
|
expect(subject.linked_post_number).not_to eq(nil)
|
|
end
|
|
it "still returns the post username" do
|
|
expect(subject.username).not_to eq(nil)
|
|
end
|
|
end
|
|
end
|