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
Use a single journal to avoid validity issues
Kabiru Mwenja05d582f46b43
diff --git a/spec/services/work_packages/activities_tab/comment_attachments_claims/claims_service_spec.rb b/spec/services/work_packages/activities_tab/comment_attachments_claims/claims_service_spec.rbindex 1d00a5a50d5..c18571dbdde 100644--- a/spec/services/work_packages/activities_tab/comment_attachments_claims/claims_service_spec.rb+++ b/spec/services/work_packages/activities_tab/comment_attachments_claims/claims_service_spec.rb@@ -34,6 +34,7 @@ require "services/base_services/behaves_like_update_service"RSpec.describe WorkPackages::ActivitiesTab::CommentAttachmentsClaims::ClaimsService doshared_let(:user) { create(:user) }shared_let(:work_package) { create(:work_package, author: user) }+ shared_let(:journal) { create(:work_package_journal, journable: work_package, version: 2, notes: "") }it_behaves_like "BaseServices update service" dolet(:model_instance) { build_stubbed(:work_package_journal, journable: work_package, version: 2, notes: "") }@@ -43,20 +44,22 @@ RSpec.describe WorkPackages::ActivitiesTab::CommentAttachmentsClaims::ClaimsServdescribe "#call" docontext "when the journal has no notes" do- let(:journal_without_notes) { create(:work_package_journal, journable: work_package, version: 2, notes: "") }-subject(:attachment_claims_service) dodescribed_class.new(user:,- model: journal_without_notes+ model: journal)end+ before do+ journal.update!(notes: "")+ end+it "does not claim any attachments" doclaim_result = attachment_claims_service.callexpect(claim_result).to be_success- expect(journal_without_notes.reload.attachments).to be_empty+ expect(journal.reload.attachments).to be_emptyendend@@ -65,8 +68,6 @@ RSpec.describe WorkPackages::ActivitiesTab::CommentAttachmentsClaims::ClaimsServshared_let(:attachment2) { create(:attachment, author: user, container: nil) }shared_let(:attachment3) { create(:attachment, author: user, container: nil) }- let(:journal_with_attachments) { create(:work_package_journal, journable: work_package, version: 3, notes:) }-let(:notes) do<<~HTML<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/#{attachment1.id}/content">@@ -88,15 +89,19 @@ RSpec.describe WorkPackages::ActivitiesTab::CommentAttachmentsClaims::ClaimsServsubject(:attachment_claims_service) dodescribed_class.new(user:,- model: journal_with_attachments+ model: journal)end+ before do+ journal.update!(notes:)+ end+it "claims the attachments" doclaim_result = attachment_claims_service.callexpect(claim_result).to be_success- expect(journal_with_attachments.reload.attachments).to contain_exactly(attachment1, attachment2, attachment3)+ expect(journal.reload.attachments).to contain_exactly(attachment1, attachment2, attachment3)endendend