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

disable sending notifications on project copy by default

ulfertsc750c06d434e
diff --git a/app/services/shared/service_state.rb b/app/services/shared/service_state.rb
index 62febc2d2d2..06ff63a919a 100644
--- a/app/services/shared/service_state.rb
+++ b/app/services/shared/service_state.rb
@@ -25,7 +25,6 @@
#
# See COPYRIGHT and LICENSE files for more details.
#++
-require "ostruct"
##
# Service state object to be passed around services
@@ -34,7 +33,7 @@ require "ostruct"
# Borrows heavily from interactor gem's context class at
# https://github.com/collectiveidea/interactor
module Shared
- class ServiceState < OpenStruct
+ class ServiceState < Hashie::Mash
##
# Builds the context object unless
# it's already an instance of this context.
diff --git a/lib/api/v3/projects/copy/parse_copy_params_service.rb b/lib/api/v3/projects/copy/parse_copy_params_service.rb
index 72af98cf7c0..ec664ba0c66 100644
--- a/lib/api/v3/projects/copy/parse_copy_params_service.rb
+++ b/lib/api/v3/projects/copy/parse_copy_params_service.rb
@@ -41,7 +41,7 @@ module API
target_project_params: attributes,
attributes_only: true,
only: meta[:only],
- send_notifications: meta[:send_notifications] != false
+ send_notifications: meta[:send_notifications] == true
}
end
end
diff --git a/lib/api/v3/projects/copy/project_copy_meta_representer.rb b/lib/api/v3/projects/copy/project_copy_meta_representer.rb
index 6ce8a8ae36a..551beec389d 100644
--- a/lib/api/v3/projects/copy/project_copy_meta_representer.rb
+++ b/lib/api/v3/projects/copy/project_copy_meta_representer.rb
@@ -51,8 +51,8 @@ module API
property :send_notifications,
exec_context: :decorator,
getter: ->(*) do
- # Default to true
- represented.send_notifications != false
+ # Default to false
+ represented.send_notifications || false
end,
setter: ->(fragment:, **) do
represented.send_notifications = fragment
diff --git a/spec/features/projects/copy_spec.rb b/spec/features/projects/copy_spec.rb
index c45824abfeb..ad68ce8aa0f 100644
--- a/spec/features/projects/copy_spec.rb
+++ b/spec/features/projects/copy_spec.rb
@@ -151,10 +151,6 @@ describe 'Projects copy',
editor = Components::WysiwygEditor.new "[data-qa-field-name='customField#{project_custom_field.id}']"
editor.expect_value 'some text cf'
- # Deactivate sending of mails during copying
- click_on 'Copy options'
- uncheck 'Send email notifications during the project copy'
-
click_button 'Save'
expect(page).to have_text 'The job has been queued and will be processed shortly.'
diff --git a/spec/lib/api/v3/projects/copy/project_copy_payload_representer_spec.rb b/spec/lib/api/v3/projects/copy/project_copy_payload_representer_spec.rb
index f376e85e4cd..8d205d399ac 100644
--- a/spec/lib/api/v3/projects/copy/project_copy_payload_representer_spec.rb
+++ b/spec/lib/api/v3/projects/copy/project_copy_payload_representer_spec.rb
@@ -42,18 +42,18 @@ describe API::V3::Projects::Copy::ProjectCopyPayloadRepresenter do
subject { representer.to_json }
- it 'has a _meta property with the copy properties set to true by default' do
+ it 'has a _meta property with the copy properties set to true by default but sendNotifications false by default' do
expect(subject).to have_json_path '_meta'
- expect(subject)
- .to be_json_eql(true.to_json)
- .at_path("_meta/sendNotifications")
-
Projects::CopyService.copyable_dependencies.each do |dep|
expect(subject)
.to be_json_eql(true.to_json)
.at_path("_meta/copy#{dep[:identifier].camelize}")
end
+
+ expect(subject)
+ .to be_json_eql(false.to_json)
+ .at_path("_meta/sendNotifications")
end
context 'with the meta property containing which associations to copy' do
diff --git a/spec/requests/api/v3/projects/copy/copy_form_resource_spec.rb b/spec/requests/api/v3/projects/copy/copy_form_resource_spec.rb
index e8c02131736..d2b3bc35570 100644
--- a/spec/requests/api/v3/projects/copy/copy_form_resource_spec.rb
+++ b/spec/requests/api/v3/projects/copy/copy_form_resource_spec.rb
@@ -197,7 +197,7 @@ describe API::V3::Projects::Copy::CreateFormAPI, content_type: :json do
it 'returns it as false' do
expect(response.body)
- .to be_json_eql(true.to_json)
+ .to be_json_eql(false.to_json)
.at_path("_embedded/payload/_meta/sendNotifications")
end
end