mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 16:42:46 +08:00
FIX: Generate correct prev and next topics page URL (#11431)
It did not work well for category + tags pages.
This commit is contained in:
parent
f62ea77666
commit
9df2bce538
|
@ -409,8 +409,6 @@ class TagsController < ::ApplicationController
|
|||
end
|
||||
|
||||
def construct_url_with(action, opts)
|
||||
method = url_method(opts)
|
||||
|
||||
page_params =
|
||||
case action
|
||||
when :prev
|
||||
|
@ -421,13 +419,13 @@ class TagsController < ::ApplicationController
|
|||
raise "unreachable"
|
||||
end
|
||||
|
||||
if page_params.include?(:category_slug_path_with_id)
|
||||
opts = opts.dup
|
||||
opts.delete(:category)
|
||||
end
|
||||
opts = opts.merge(page_params)
|
||||
opts.delete(:category) if opts.include?(:category_slug_path_with_id)
|
||||
|
||||
method = url_method(opts)
|
||||
|
||||
begin
|
||||
url = public_send(method, opts.merge(page_params))
|
||||
url = public_send(method, opts)
|
||||
rescue ActionController::UrlGenerationError
|
||||
raise Discourse::NotFound
|
||||
end
|
||||
|
@ -451,6 +449,7 @@ class TagsController < ::ApplicationController
|
|||
q: params[:q]
|
||||
)
|
||||
options[:no_subcategories] = true if params[:no_subcategories] == 'true'
|
||||
options[:per_page] = params[:per_page].to_i.clamp(1, 30) if params[:per_page].present?
|
||||
|
||||
if params[:tag_id] == 'none'
|
||||
options.delete(:tags)
|
||||
|
|
|
@ -204,6 +204,13 @@ describe TagsController do
|
|||
expect(topic_ids).to_not include(topic_out_of_category.id)
|
||||
expect(topic_ids).to_not include(topic_in_category_without_tag.id)
|
||||
end
|
||||
|
||||
it "should produce the right next topic URL" do
|
||||
get "/tags/c/#{category.slug_path.join("/")}/#{category.id}/#{tag.name}.json?per_page=1"
|
||||
|
||||
expect(response.parsed_body['topic_list']['more_topics_url'])
|
||||
.to start_with("/tags/c/#{category.slug_path.join('/')}/#{category.id}/#{tag.name}")
|
||||
end
|
||||
end
|
||||
|
||||
context "with a subcategory in the path" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user