]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4963 Return description in /permission_templates/search_groups
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 26 Aug 2014 13:28:51 +0000 (15:28 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 26 Aug 2014 13:50:39 +0000 (15:50 +0200)
server/sonar-web/src/main/webapp/WEB-INF/app/controllers/permission_templates_controller.rb
sonar-core/src/main/resources/org/sonar/core/permission/PermissionTemplateMapper.xml
sonar-core/src/test/java/org/sonar/core/permission/GroupWithPermissionTemplateDaoTest.java
sonar-core/src/test/resources/org/sonar/core/permission/GroupWithPermissionTemplateDaoTest/groups_with_permissions.xml

index fc073ec0ddb3b709f95ddc499d164a96e309349b..4babd23a90f7bd765a42c4127d5ec25cc960ba3b 100644 (file)
@@ -102,10 +102,14 @@ class PermissionTemplatesController < ApplicationController
       format.json {
         render :json => {
             :more => more,
-            :results => groups.map { |group| {
-                :name => group.name(),
-                :selected => group.hasPermission()
-            }}
+            :results => groups.map { |group|
+              hash = {
+                  :name => group.name(),
+                  :selected => group.hasPermission()
+              }
+              hash[:description] = group.description() if group.description() && !group.description().blank?
+              hash
+            }
         }
       }
     end
index 2ec027daa8908b68345da5b6be81c8965d71d314..64fb208e8e9668175188452a450d83a89b5bcc30 100644 (file)
   </select>
 
   <select id="selectGroups" parameterType="map" resultType="GroupWithPermission">
-    SELECT name, permission FROM
-    (SELECT g.name as name, ptg.permission_reference as permission
+    SELECT name, description, permission FROM
+    (SELECT g.name as name, g.description as description, ptg.permission_reference as permission
     FROM groups g
     LEFT JOIN perm_templates_groups ptg ON ptg.group_id=g.id
       AND ptg.permission_reference=#{query.permission}
       AND ptg.template_id=#{templateId}
     UNION
     -- Add Anyone group permission
-    SELECT #{anyoneGroup} as name, ptg.permission_reference as permission
+    SELECT #{anyoneGroup} as name, NULL as description, ptg.permission_reference as permission
     FROM perm_templates_groups ptg
     <where>
       AND ptg.permission_reference=#{query.permission}
index f91e616233a1207be5c182fb41b520dcde90d44d..8f3ee7d8ae23357d34868da3e706574df24b38ee 100644 (file)
@@ -51,18 +51,22 @@ public class GroupWithPermissionTemplateDaoTest extends AbstractDaoTestCase {
 
     GroupWithPermissionDto anyone = result.get(0);
     assertThat(anyone.getName()).isEqualTo("Anyone");
+    assertThat(anyone.getDescription()).isNull();
     assertThat(anyone.getPermission()).isNotNull();
 
     GroupWithPermissionDto group1 = result.get(1);
     assertThat(group1.getName()).isEqualTo("sonar-administrators");
+    assertThat(group1.getDescription()).isEqualTo("System administrators");
     assertThat(group1.getPermission()).isNotNull();
 
     GroupWithPermissionDto group2 = result.get(2);
     assertThat(group2.getName()).isEqualTo("sonar-reviewers");
+    assertThat(group2.getDescription()).isEqualTo("Reviewers");
     assertThat(group2.getPermission()).isNull();
 
     GroupWithPermissionDto group3 = result.get(3);
     assertThat(group3.getName()).isEqualTo("sonar-users");
+    assertThat(group3.getDescription()).isEqualTo("Any new users created will automatically join this group");
     assertThat(group3.getPermission()).isNotNull();
   }
 
index 38240ab42557c0add911b9935daa486fbdc5b080..8d6592cbc110248b9686ae199d3f46d6cb8fe214 100644 (file)
@@ -1,8 +1,8 @@
 <dataset>
 
-  <groups id="200" name="sonar-administrators"/>
-  <groups id="201" name="sonar-users" />
-  <groups id="202" name="sonar-reviewers" />
+  <groups id="200" name="sonar-administrators" description="System administrators"/>
+  <groups id="201" name="sonar-users" description="Any new users created will automatically join this group"/>
+  <groups id="202" name="sonar-reviewers" description="Reviewers"/>
 
   <perm_templates_groups id="1" group_id="200" permission_reference="user" template_id="50"/>
   <perm_templates_groups id="2" group_id="200" permission_reference="admin" template_id="50"/>