Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Update more actions to respond with 303 See Other

Alexander Brandon Colesac84c7fc58cc
diff --git a/app/controllers/colors_controller.rb b/app/controllers/colors_controller.rb
index e147051d5af..f6f2a648e11 100644
--- a/app/controllers/colors_controller.rb
+++ b/app/controllers/colors_controller.rb
@@ -99,7 +99,7 @@ class ColorsController < ApplicationController
@color.destroy
flash[:notice] = I18n.t(:notice_successful_delete)
- redirect_to colors_path
+ redirect_to colors_path, status: :see_other
end
protected
diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb
index 7dab67e53c5..3d70f09fccf 100644
--- a/app/controllers/forums_controller.rb
+++ b/app/controllers/forums_controller.rb
@@ -120,7 +120,7 @@ class ForumsController < ApplicationController
def destroy
@forum.destroy
flash[:notice] = I18n.t(:notice_successful_delete)
- redirect_to action: "index"
+ redirect_to action: "index", status: :see_other
end
private
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index e061d7bcb1d..f88309d064b 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -113,7 +113,7 @@ class NewsController < ApplicationController
call.apply_flash_message!(flash)
end
- redirect_to action: "index", project_id: @project
+ redirect_to action: "index", project_id: @project, status: :see_other
end
private
diff --git a/modules/documents/app/controllers/documents_controller.rb b/modules/documents/app/controllers/documents_controller.rb
index 0e6e30e9340..86c27fc7b33 100644
--- a/modules/documents/app/controllers/documents_controller.rb
+++ b/modules/documents/app/controllers/documents_controller.rb
@@ -97,7 +97,7 @@ class DocumentsController < ApplicationController
def destroy
@document.destroy
- redirect_to controller: "/documents", action: "index", project_id: @project
+ redirect_to controller: "/documents", action: "index", project_id: @project, status: :see_other
end
private
diff --git a/modules/documents/spec/controllers/documents_controller_spec.rb b/modules/documents/spec/controllers/documents_controller_spec.rb
index 1b9bd1578ef..69e9ae29ffc 100644
--- a/modules/documents/spec/controllers/documents_controller_spec.rb
+++ b/modules/documents/spec/controllers/documents_controller_spec.rb
@@ -157,12 +157,13 @@ RSpec.describe DocumentsController do
document
end
- it "deletes the document and redirect back to documents-page of the project" do
+ it "deletes the document and redirects with 303 See Other" do
expect do
delete :destroy, params: { id: document.id }
end.to change(Document, :count).by -1
- expect(response).to redirect_to "/projects/#{project.identifier}/documents"
+ expect(response).to have_http_status(:see_other)
+ expect(response).to redirect_to project_documents_path(project)
expect { Document.find(document.id) }.to raise_error ActiveRecord::RecordNotFound
end
end
diff --git a/spec/controllers/colors_controller_spec.rb b/spec/controllers/colors_controller_spec.rb
index 6f6386763b1..8c9fcf8c7ec 100644
--- a/spec/controllers/colors_controller_spec.rb
+++ b/spec/controllers/colors_controller_spec.rb
@@ -100,5 +100,10 @@ RSpec.describe ColorsController do
colors_path
end
it_behaves_like "a controller action with require_admin"
+
+ it "redirects with 303 See Other" do
+ expect(fetch).to have_http_status(:see_other)
+ expect(fetch).to redirect_to(colors_path)
+ end
end
end
diff --git a/spec/controllers/forums_controller_spec.rb b/spec/controllers/forums_controller_spec.rb
index e866ed7249e..6fdb1caf1e2 100644
--- a/spec/controllers/forums_controller_spec.rb
+++ b/spec/controllers/forums_controller_spec.rb
@@ -170,10 +170,11 @@ RSpec.describe ForumsController do
end
end
- it "requests destruction and redirect" do
+ it "deletes the forum and redirects with 303 See Other" do
expect(forum).to receive(:destroy)
- delete :destroy, params: { project_id: project.id, id: 1 }
- expect(response).to be_redirect
+ delete :destroy, params: { project_id: project.identifier, id: 1 }
+ expect(response).to have_http_status(:see_other)
+ expect(response).to redirect_to(project_forums_path(project))
end
end
diff --git a/spec/controllers/news_controller_spec.rb b/spec/controllers/news_controller_spec.rb
index c4fe28496af..dd35a60bb1f 100644
--- a/spec/controllers/news_controller_spec.rb
+++ b/spec/controllers/news_controller_spec.rb
@@ -160,9 +160,10 @@ RSpec.describe NewsController do
end
describe "#destroy" do
- it "deletes the news element and redirects to the news overview page" do
+ it "deletes the news item and redirects with 303 See Other" do
delete :destroy, params: { id: news.id }
+ expect(response).to have_http_status(:see_other)
expect(response).to redirect_to project_news_index_path(news.project)
expect { news.reload }.to raise_error ActiveRecord::RecordNotFound
end