mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 17:18:19 +08:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
43 lines
1.2 KiB
Ruby
43 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe TopicViewPostsSerializer do
|
|
|
|
let(:user) { Fabricate(:user) }
|
|
let(:post) { Fabricate(:post) }
|
|
let(:topic) { post.topic }
|
|
let!(:reviewable) { Fabricate(:reviewable_flagged_post,
|
|
created_by: user,
|
|
target: post,
|
|
topic: topic,
|
|
reviewable_scores: [
|
|
Fabricate(:reviewable_score, reviewable_score_type: 0, status: ReviewableScore.statuses[:pending]),
|
|
Fabricate(:reviewable_score, reviewable_score_type: 0, status: ReviewableScore.statuses[:ignored])
|
|
]
|
|
)}
|
|
|
|
it 'should return the right attributes' do
|
|
topic_view = TopicView.new(topic, user, post_ids: [post.id])
|
|
|
|
serializer = TopicViewPostsSerializer.new(
|
|
topic_view,
|
|
scope: Guardian.new(Fabricate(:admin)),
|
|
root: false
|
|
)
|
|
|
|
body = JSON.parse(serializer.to_json)
|
|
|
|
posts = body["post_stream"]["posts"]
|
|
|
|
expect(posts.count).to eq(1)
|
|
expect(posts.first["id"]).to eq(post.id)
|
|
|
|
expect(posts.first["reviewable_score_count"]).to eq(2)
|
|
expect(posts.first["reviewable_score_pending_count"]).to eq(1)
|
|
|
|
expect(body["post_stream"]["stream"]).to eq(nil)
|
|
expect(body["post_stream"]["timeline_lookup"]).to eq(nil)
|
|
expect(body["post_stream"]["gaps"]).to eq(nil)
|
|
|
|
end
|
|
end
|