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

Skip rendering Status Badge if status not set

Alexander Brandon Coles6f2885e03651
diff --git a/app/components/projects/status_badge_component.rb b/app/components/projects/status_badge_component.rb
index 3229b623f21..ed9b74f4adc 100644
--- a/app/components/projects/status_badge_component.rb
+++ b/app/components/projects/status_badge_component.rb
@@ -41,6 +41,8 @@ class Projects::StatusBadgeComponent < ApplicationComponent
end
def before_render
+ return unless @status
+
@system_arguments[:classes] = class_names(
@system_arguments[:classes],
helpers.hl_background_class(:project_status, @status.id)
@@ -56,6 +58,6 @@ class Projects::StatusBadgeComponent < ApplicationComponent
end
def find_status(code)
- Projects::Statuses::AVAILABLE.find(-> { Projects::Statuses::NOT_SET }) { it.code&.to_s == code }
+ Projects::Statuses::VALID.find { it.code&.to_s == code }
end
end
diff --git a/spec/components/projects/status_badge_component_spec.rb b/spec/components/projects/status_badge_component_spec.rb
index 0dfc8190a17..ca0778a3980 100644
--- a/spec/components/projects/status_badge_component_spec.rb
+++ b/spec/components/projects/status_badge_component_spec.rb
@@ -43,8 +43,8 @@ RSpec.describe Projects::StatusBadgeComponent, type: :component do
end
context "when status code is not set" do
- it "renders a label" do
- expect(rendered_component).to have_primer_label "Not set"
+ it "renders nothing" do
+ expect(rendered_component.to_s).to be_empty
end
end