mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
FIX: hitting '/t/:id/posts.json' should return the first page of posts
This commit is contained in:
parent
a1add415e5
commit
d402a45781
3 changed files with 12 additions and 2 deletions
|
@ -154,7 +154,7 @@ class TopicsController < ApplicationController
|
|||
|
||||
def posts
|
||||
params.require(:topic_id)
|
||||
params.require(:post_ids)
|
||||
params.permit(:post_ids)
|
||||
|
||||
@topic_view = TopicView.new(params[:topic_id], current_user, post_ids: params[:post_ids])
|
||||
render_json_dump(TopicViewPostsSerializer.new(@topic_view, scope: guardian, root: false, include_raw: !!params[:include_raw]))
|
||||
|
|
|
@ -544,7 +544,7 @@ Discourse::Application.routes.draw do
|
|||
get "t/:slug/:topic_id" => "topics#show", constraints: {topic_id: /\d+/}
|
||||
get "t/:slug/:topic_id/:post_number" => "topics#show", constraints: {topic_id: /\d+/, post_number: /\d+/}
|
||||
get "t/:slug/:topic_id/last" => "topics#show", post_number: 99999999, constraints: {topic_id: /\d+/}
|
||||
get "t/:topic_id/posts" => "topics#posts", constraints: {topic_id: /\d+/}
|
||||
get "t/:topic_id/posts" => "topics#posts", constraints: {topic_id: /\d+/}, format: :json
|
||||
post "t/:topic_id/timings" => "topics#timings", constraints: {topic_id: /\d+/}
|
||||
post "t/:topic_id/invite" => "topics#invite", constraints: {topic_id: /\d+/}
|
||||
post "t/:topic_id/move-posts" => "topics#move_posts", constraints: {topic_id: /\d+/}
|
||||
|
|
|
@ -813,6 +813,16 @@ describe TopicsController do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#posts' do
|
||||
let(:topic) { Fabricate(:post).topic }
|
||||
|
||||
it 'returns first posts of the topic' do
|
||||
get :posts, topic_id: topic.id, format: :json
|
||||
expect(response).to be_success
|
||||
expect(response.content_type).to eq('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#feed' do
|
||||
let(:topic) { Fabricate(:post).topic }
|
||||
|
||||
|
|
Loading…
Reference in a new issue