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

Uncheck workflow status checkbox by default

Oliver Güntherad339e14a0d3
diff --git a/app/controllers/workflows_controller.rb b/app/controllers/workflows_controller.rb
index aec51ef4790..bf78196c288 100644
--- a/app/controllers/workflows_controller.rb
+++ b/app/controllers/workflows_controller.rb
@@ -45,7 +45,7 @@ class WorkflowsController < ApplicationController
end
def edit
- @used_statuses_only = params[:used_statuses_only] != "0"
+ @used_statuses_only = params[:used_statuses_only] == "1"
statuses_for_form
diff --git a/spec/controllers/workflows_controller_spec.rb b/spec/controllers/workflows_controller_spec.rb
index 74e6d004584..36db16147ce 100644
--- a/spec/controllers/workflows_controller_spec.rb
+++ b/spec/controllers/workflows_controller_spec.rb
@@ -156,44 +156,49 @@ RSpec.describe WorkflowsController do
end
end
- context "with role and type params" do
+ context "with role and type params, and only used statuses" do
before do
- get :edit, params: { role_id: role.id.to_s, type_id: type.id.to_s }
+ get :edit, params: { role_id: role.id.to_s, type_id: type.id.to_s, used_statuses_only: "1" }
end
- it "is successful" do
+ it "is responds with the statuses", :aggregate_failures do
expect(response)
.to have_http_status(:ok)
- end
-
- it "renders the edit template" do
expect(response)
.to render_template :edit
- end
-
- it "assigns role" do
expect(assigns[:role])
.to eq role
- end
-
- it "assign type" do
expect(assigns[:type])
.to eq type
- end
-
- it "assigns roles" do
expect(assigns[:roles])
.to eq [role]
- end
-
- it "assigns types" do
expect(assigns[:types])
.to eq [type]
+ expect(assigns[:statuses])
+ .to eq type.statuses
end
+ end
- it "assigns statuses" do
+ context "with role and type params, and no statuses filter" do
+ before do
+ get :edit, params: { role_id: role.id.to_s, type_id: type.id.to_s }
+ end
+
+ it "is responds with the statuses", :aggregate_failures do
+ expect(response)
+ .to have_http_status(:ok)
+ expect(response)
+ .to render_template :edit
+ expect(assigns[:role])
+ .to eq role
+ expect(assigns[:type])
+ .to eq type
+ expect(assigns[:roles])
+ .to eq [role]
+ expect(assigns[:types])
+ .to eq [type]
expect(assigns[:statuses])
- .to eq type.statuses
+ .to eq Status.all
end
end