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

[#50219] Custom export cover background overlay color won't return to the default one after deleting

as-opc2d009fc80fa
diff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rb
index 2132070279f..3fdf20f015b 100644
--- a/app/controllers/custom_styles_controller.rb
+++ b/app/controllers/custom_styles_controller.rb
@@ -74,7 +74,8 @@ class CustomStylesController < ApplicationController
end
color_hexcode_regex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/
- if !color.nil? && color.match(color_hexcode_regex)
+ color = nil if color.blank?
+ if color.nil? || color.match(color_hexcode_regex)
@custom_style.export_cover_text_color = color
@custom_style.save
end
diff --git a/spec/controllers/custom_styles_controller_spec.rb b/spec/controllers/custom_styles_controller_spec.rb
index 163344da61e..180f7f4f30c 100644
--- a/spec/controllers/custom_styles_controller_spec.rb
+++ b/spec/controllers/custom_styles_controller_spec.rb
@@ -489,6 +489,23 @@ RSpec.describe CustomStylesController do
end
end
+ context 'with valid empty parameter' do
+ let(:params) do
+ { export_cover_text_color: '' }
+ end
+
+ before do
+ custom_style.export_cover_text_color = "#990000"
+ custom_style.save
+ post :update_export_cover_text_color, params:
+ end
+
+ it "removes the color" do
+ expect(custom_style.export_cover_text_color).to be_nil
+ expect(response).to redirect_to action: :show
+ end
+ end
+
context 'with invalid parameter' do
let(:params) do
{ export_cover_text_color: "red" } # we only accept hexcodes