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

allow fetching activities by an id referencing a subsumed journal

ulferts7f39a3b08fb3
diff --git a/app/models/journal/aggregated_journal.rb b/app/models/journal/aggregated_journal.rb
index 796363c9be9..0761d368498 100644
--- a/app/models/journal/aggregated_journal.rb
+++ b/app/models/journal/aggregated_journal.rb
@@ -62,11 +62,7 @@ class Journal::AggregatedJournal
# We need to limit the journal aggregation as soon as possible for performance reasons.
# Therefore we have to provide the notes_id to the aggregation on top of it being used
# in the where clause to pick the desired AggregatedJournal.
- raw_journal = Journal::Scopes::AggregatedJournal.fetch
- .where(id: notes_id)
- .first
-
- raw_journal ? Journal::AggregatedJournal.new(raw_journal) : nil
+ containing_journal(Journal.find(notes_id))
end
##
diff --git a/spec/requests/api/v3/activities_api_spec.rb b/spec/requests/api/v3/activities_api_spec.rb
index 4f1dabe9935..5ca219c1fca 100644
--- a/spec/requests/api/v3/activities_api_spec.rb
+++ b/spec/requests/api/v3/activities_api_spec.rb
@@ -121,7 +121,32 @@ describe API::V3::Activities::ActivitiesAPI, type: :request, content_type: :json
get get_path
end
- it_behaves_like 'valid activity request', 'Activity'
+ context 'for a journal without a comment' do
+ it_behaves_like 'valid activity request', 'Activity'
+ end
+
+ context 'for a journal with a comment' do
+ let(:activity) do
+ work_package.journals.first.tap do |journal|
+ journal.update_column(:notes, comment)
+ end
+ end
+
+ it_behaves_like 'valid activity request', 'Activity::Comment'
+ end
+
+ context 'for an aggregated journal when requesting by the notes_id (which is not the aggregated journal`s id)`' do
+ let(:activity) do
+ work_package.journals.first.tap do |journal|
+ journal.update_column(:notes, comment)
+
+ work_package.subject = 'A new subject'
+ work_package.save!
+ end
+ end
+
+ it_behaves_like 'valid activity request', 'Activity::Comment'
+ end
context 'requesting nonexistent activity' do
let(:get_path) { api_v3_paths.activity 9999 }