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
attachment create service more in line with general layout
ulferts056b6f45af57
diff --git a/app/services/add_attachment_service.rb b/app/services/attachments/create_service.rbsimilarity index 96%rename from app/services/add_attachment_service.rbrename to app/services/attachments/create_service.rbindex 6f7d5b9638b..6f51a82f7bb 100644--- a/app/services/add_attachment_service.rb+++ b/app/services/attachments/create_service.rb@@ -26,7 +26,7 @@# See docs/COPYRIGHT.rdoc for more details.#++-class AddAttachmentService+class Attachments::CreateServiceattr_reader :container, :authordef initialize(container, author:)@@ -39,7 +39,7 @@ class AddAttachmentService# In case the container supports it, a journal will be written.## An ActiveRecord::RecordInvalid error is raised if any record can't be saved.- def add_attachment(uploaded_file:, description:)+ def call(uploaded_file:, description:)attachment = Attachment.new(file: uploaded_file,container: container,description: description,diff --git a/config/initializers/register_renderer.rb b/config/initializers/register_renderer.rbindex 8368b5c6085..03b401fd9df 100644--- a/config/initializers/register_renderer.rb+++ b/config/initializers/register_renderer.rb@@ -1,4 +1,5 @@#-- encoding: UTF-8+#-- copyright# OpenProject is an open source project management software.# Copyright (C) 2012-2020 the OpenProject GmbHdiff --git a/lib/api/v3/attachments/attachments_by_container_api.rb b/lib/api/v3/attachments/attachments_by_container_api.rbindex ff31ef96e32..3f41ee9c868 100644--- a/lib/api/v3/attachments/attachments_by_container_api.rb+++ b/lib/api/v3/attachments/attachments_by_container_api.rb@@ -79,11 +79,11 @@ module APIfile[:type],file_name: metadata.file_name.to_s- service = AddAttachmentService.new(container, author: current_user)+ service = Attachments::CreateService.new(container, author: current_user)with_handled_create_errors do- service.add_attachment uploaded_file: uploaded_file,- description: metadata.description+ service.call uploaded_file: uploaded_file,+ description: metadata.descriptionendenddiff --git a/spec/services/add_attachment_service_spec.rb b/spec/services/attachments/create_service_spec.rbsimilarity index 93%rename from spec/services/add_attachment_service_spec.rbrename to spec/services/attachments/create_service_spec.rbindex 98dec524b2c..9ccc80f74f0 100644--- a/spec/services/add_attachment_service_spec.rb+++ b/spec/services/attachments/create_service_spec.rb@@ -28,7 +28,7 @@require 'spec_helper'-describe AddAttachmentService do+describe Attachments::CreateService dolet(:user) { FactoryBot.create(:user) }let(:work_package) { FactoryBot.create(:work_package) }let(:container) { work_package }@@ -36,10 +36,10 @@ describe AddAttachmentService dosubject { described_class.new(work_package, author: user) }- describe '#add_attachment' do+ describe '#call' dodef call_tested_method- subject.add_attachment uploaded_file: FileHelpers.mock_uploaded_file(name: 'foobar.txt'),- description: description+ subject.call uploaded_file: FileHelpers.mock_uploaded_file(name: 'foobar.txt'),+ description: descriptionendshared_examples 'successful creation' do