2019-04-29 19:27:42 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-21 21:38:31 -05:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe TopicViewPostsSerializer do
|
2019-05-06 22:12:20 -05:00
|
|
|
fab!(:user) { Fabricate(:user) }
|
|
|
|
fab!(:post) { Fabricate(:post) }
|
2018-06-21 21:38:31 -05:00
|
|
|
let(:topic) { post.topic }
|
|
|
|
let(:topic_view) { TopicView.new(topic, user, post_ids: [post.id]) }
|
|
|
|
|
|
|
|
subject do
|
|
|
|
described_class.new(topic_view,
|
|
|
|
scope: Guardian.new(Fabricate(:admin)),
|
|
|
|
root: false
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return the right attributes' do
|
|
|
|
body = JSON.parse(subject.to_json)
|
|
|
|
|
|
|
|
posts = body["post_stream"]["posts"]
|
|
|
|
|
|
|
|
expect(posts.count).to eq(1)
|
|
|
|
expect(posts.first["id"]).to eq(post.id)
|
|
|
|
expect(body["post_stream"]["stream"]).to eq(nil)
|
|
|
|
expect(body["post_stream"]["timeline_lookup"]).to eq(nil)
|
2018-07-02 00:58:02 -05:00
|
|
|
expect(body["post_stream"]["gaps"]).to eq(nil)
|
2018-06-21 21:38:31 -05:00
|
|
|
end
|
|
|
|
end
|