Actions
Defect #44361
openPreview returns a 404 error on the cross-project news form
Status:
New
Priority:
Normal
Assignee:
-
Category:
News
Target version:
-
Resolution:
Affected version:
Description
On the cross-project news form, clicking Preview returns a 404 instead of the preview.
The toolbar builds preview URL with preview_news_path(:project_id => @project, :id => @news). Outside a project @project is nil, so the URL is /news/preview with no project_id, and PreviewsController#find_project runs Project.find(nil), which raises ActiveRecord::RecordNotFound and renders a 404.
Steps to reproduce¶
- open
/news/new - type something in the description
- click Preview
The preview is blank.
You can see a 404 error in the browser console.
Patch¶
The attached patch looks the project up only when an id is given:
def find_project project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id] @project = Project.find(project_id) if project_id.present? rescue ActiveRecord::RecordNotFound render_404 end
A nil project is already a supported state of this controller. A preview can be rendered without project context
Files
No data to display
Actions