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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix removal of custom_style
Oliver Günther4b902510f054
diff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rbindex 721ef41c90d..7077bca4de4 100644--- a/app/controllers/custom_styles_controller.rb+++ b/app/controllers/custom_styles_controller.rb@@ -75,15 +75,15 @@ class CustomStylesController < ApplicationControllerenddef logo_delete- file_delete(:remove_logo!)+ file_delete(:remove_logo)enddef favicon_delete- file_delete(:remove_favicon!)+ file_delete(:remove_favicon)enddef touch_icon_delete- file_delete(:remove_touch_icon!)+ file_delete(:remove_touch_icon)enddef update_colorsdiff --git a/app/models/custom_style.rb b/app/models/custom_style.rbindex e9b480c6154..0d6de9230a0 100644--- a/app/models/custom_style.rb+++ b/app/models/custom_style.rb@@ -28,5 +28,10 @@ class CustomStyle < ApplicationRecordimage.local_file.pathendend++ define_method "remove_#{name}" do+ image = send(name)+ image&.remove!+ endendenddiff --git a/spec/controllers/custom_styles_controller_spec.rb b/spec/controllers/custom_styles_controller_spec.rbindex 01786b38dd0..6d19e0ed3ff 100644--- a/spec/controllers/custom_styles_controller_spec.rb+++ b/spec/controllers/custom_styles_controller_spec.rb@@ -211,7 +211,7 @@ describe CustomStylesController, type: :controller doenddescribe "#logo_delete" do- let(:custom_style) { build(:custom_style_with_logo) }+ let(:custom_style) { create(:custom_style_with_logo) }before dowith_enterprise_token(:define_custom_style)@@ -220,7 +220,7 @@ describe CustomStylesController, type: :controller docontext 'if it exists' dobefore doexpect(CustomStyle).to receive(:current).and_return(custom_style)- expect(custom_style).to receive(:remove_logo!).and_return(custom_style)+ expect(custom_style).to receive(:remove_logo).and_call_originaldelete :logo_deleteend@@ -278,7 +278,7 @@ describe CustomStylesController, type: :controller doenddescribe "#favicon_delete" do- let(:custom_style) { build(:custom_style_with_favicon) }+ let(:custom_style) { create(:custom_style_with_favicon) }before dowith_enterprise_token(:define_custom_style)@@ -287,7 +287,7 @@ describe CustomStylesController, type: :controller docontext 'if it exists' dobefore doexpect(CustomStyle).to receive(:current).and_return(custom_style)- expect(custom_style).to receive(:remove_favicon!).and_return(custom_style)+ expect(custom_style).to receive(:remove_favicon).and_call_originaldelete :favicon_deleteend@@ -345,7 +345,7 @@ describe CustomStylesController, type: :controller doenddescribe "#touch_icon_delete" do- let(:custom_style) { build(:custom_style_with_touch_icon) }+ let(:custom_style) { create(:custom_style_with_touch_icon) }before dowith_enterprise_token(:define_custom_style)@@ -354,7 +354,7 @@ describe CustomStylesController, type: :controller docontext 'if it exists' dobefore doexpect(CustomStyle).to receive(:current).and_return(custom_style)- expect(custom_style).to receive(:remove_touch_icon!).and_return(custom_style)+ expect(custom_style).to receive(:remove_touch_icon).and_call_originaldelete :touch_icon_deleteend