]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3825 prevent from sharing a measure filter if a system filter has the same...
authorSimon Brandhof <simon.brandhof@gmail.com>
Wed, 5 Dec 2012 16:28:23 +0000 (17:28 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Wed, 5 Dec 2012 16:29:02 +0000 (17:29 +0100)
sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter.rb

index b4deac5762547693b16a78019fd47e526423ecfe..edb7241669b91ba2305aa3cce9efb20ae859be1b 100644 (file)
@@ -281,10 +281,10 @@ class MeasureFilter < ActiveRecord::Base
     errors.add_to_base('Name already exists') if count>0
 
     if shared
-      count = MeasureFilter.count('id', :conditions => ['name=? and shared=? and user_id!=?', name, true, user_id])
-      errors.add_to_base('Other users already shared filters with the same name') if count>0
+      count = MeasureFilter.count('id', :conditions => ['name=? and shared=? and (user_id is null or user_id<>?)', name, true, user_id])
+      errors.add_to_base('Other users already share filters with the same name') if count>0
     elsif system?
-      errors.add_to_base("System filters can't be unshared.")
+      errors.add_to_base("System filters can't be unshared")
     end
   end
 end
\ No newline at end of file