From afa80816370b0d9fa4e4f4272242330f3a2bba6b Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 5 Dec 2012 17:28:23 +0100 Subject: [PATCH] SONAR-3825 prevent from sharing a measure filter if a system filter has the same name --- .../src/main/webapp/WEB-INF/app/models/measure_filter.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter.rb index b4deac57625..edb7241669b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter.rb @@ -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 -- 2.39.5