mirror of
https://github.com/discourse/discourse-solved.git
synced 2025-03-09 14:37:15 +00:00
c.f. de983796e1b66aa2ab039a4fb6e32cec8a65a098 There will soon be additional login_required checks for Guardian, and the intent of many checks by automated systems is better fulfilled by using BasicUser, which simulates a logged in TL0 forum user, rather than an anon user.
27 lines
721 B
Ruby
27 lines
721 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "rails_helper"
|
|
|
|
describe TopicAnswerMixin do
|
|
let(:topic) { Fabricate(:topic) }
|
|
let(:post) { Fabricate(:post, topic: topic) }
|
|
let(:guardian) { Guardian.basic_user }
|
|
|
|
before do
|
|
topic.custom_fields["accepted_answer_post_id"] = post.id
|
|
topic.save_custom_fields
|
|
end
|
|
|
|
it "should have true for `has_accepted_answer` field in each serializer" do
|
|
[
|
|
TopicListItemSerializer,
|
|
SearchTopicListItemSerializer,
|
|
SuggestedTopicSerializer,
|
|
UserSummarySerializer::TopicSerializer,
|
|
].each do |serializer|
|
|
json = serializer.new(topic, scope: guardian, root: false).as_json
|
|
expect(json[:has_accepted_answer]).to be_truthy
|
|
end
|
|
end
|
|
end
|