Commit e82c02dc authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'remove_redirect_on_non_html_requests' into 'master'

Remove attempted redirection on non-HTML requests.

See merge request gitlab-org/gitlab!83742
parents c4220804 9e629d47
......@@ -10,7 +10,7 @@ class Projects::IssuesController < Projects::ApplicationController
include RecordUserLastActivity
ISSUES_EXCEPT_ACTIONS = %i[index calendar new create bulk_update import_csv export_csv service_desk].freeze
SET_ISSUABLES_INDEX_ONLY_ACTIONS = %i[calendar service_desk].freeze
SET_ISSUABLES_INDEX_ONLY_ACTIONS = %i[index calendar service_desk].freeze
prepend_before_action(only: [:index]) { authenticate_sessionless_user!(:rss) }
prepend_before_action(only: [:calendar]) { authenticate_sessionless_user!(:ics) }
......@@ -22,7 +22,9 @@ class Projects::IssuesController < Projects::ApplicationController
before_action :issue, unless: ->(c) { ISSUES_EXCEPT_ACTIONS.include?(c.action_name.to_sym) }
after_action :log_issue_show, unless: ->(c) { ISSUES_EXCEPT_ACTIONS.include?(c.action_name.to_sym) }
before_action :set_issuables_index, if: ->(c) { SET_ISSUABLES_INDEX_ONLY_ACTIONS.include?(c.action_name.to_sym) }
before_action :set_issuables_index, if: ->(c) {
SET_ISSUABLES_INDEX_ONLY_ACTIONS.include?(c.action_name.to_sym) && !vue_issues_list?
}
# Allow write(create) issue
before_action :authorize_create_issue!, only: [:new, :create]
......@@ -71,10 +73,9 @@ class Projects::IssuesController < Projects::ApplicationController
attr_accessor :vulnerability_id
def index
if html_request? && Feature.enabled?(:vue_issues_list, project&.group, default_enabled: :yaml)
if vue_issues_list?
set_sort_order
else
set_issuables_index
@issues = @issuables
end
......@@ -248,6 +249,12 @@ class Projects::IssuesController < Projects::ApplicationController
protected
def vue_issues_list?
action_name.to_sym == :index &&
html_request? &&
Feature.enabled?(:vue_issues_list, project&.group, default_enabled: :yaml)
end
def sorting_field
Issue::SORTING_PREFERENCE_FIELD
end
......
......@@ -148,6 +148,13 @@ RSpec.describe Projects::IssuesController do
allow(Kaminari.config).to receive(:default_per_page).and_return(1)
end
it 'redirects to last page when out of bounds on non-html requests' do
get :index, params: params.merge(page: last_page + 1), format: 'atom'
expect(response).to have_gitlab_http_status(:redirect)
expect(response).to redirect_to(action: 'index', format: 'atom', page: last_page, state: 'opened')
end
it 'does not use pagination if disabled' do
allow(controller).to receive(:pagination_disabled?).and_return(true)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment