From 42c733568534132daed7c185905a8f428f058dde Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Mon, 16 May 2011 15:50:59 +0200 Subject: [PATCH] SONAR-1973 Fix review not linked to the project but to the module Reviews should reference the top project that contains the violation they reference, and not the module. It was not the case, and as a consequence, the search engine did not work as expected. --- .../src/main/webapp/WEB-INF/app/models/project.rb | 12 ++++++++++++ .../src/main/webapp/WEB-INF/app/models/review.rb | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb index 8489caea88b..9658c9dfcb3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb @@ -43,6 +43,13 @@ class Project < ActiveRecord::Base root||self end + def root_project + @root_project ||= + begin + parent_module(self) + end + end + def last_snapshot @last_snapshot ||= begin @@ -153,4 +160,9 @@ class Project < ActiveRecord::Base end chart_measures end + + def parent_module(current_module) + current_module.root ? parent_module(current_module.root) : current_module + end + end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb index 46e97ba9c95..1f91e4abe79 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb @@ -205,7 +205,7 @@ class Review < ActiveRecord::Base def assign_project if self.project.nil? && self.resource - self.project=self.resource.project + self.project=self.resource.root_project end end -- 2.39.5