]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4535 Use Java service when loading form to rename a profile
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 17 Dec 2013 15:54:14 +0000 (16:54 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 17 Dec 2013 15:54:14 +0000 (16:54 +0100)
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfiles.java
sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfilesTest.java

index edb178eb17b79b6d0d28f2976100076a22f65c19..cd6294d481f703fc83cff57c22bc8ebbffc2a7b5 100644 (file)
@@ -92,6 +92,11 @@ public class QProfiles implements ServerComponent {
   // edit template rule
   // delete template rule
 
+  public QProfile profile(int id) {
+    QualityProfileDto dto = findNotNull(id);
+    return QProfile.from(dto);
+  }
+
   public List<QProfile> allProfiles() {
     return search.allProfiles();
   }
index cafa245112c86f4f0998bade1aa849c2403f8f31..84208d29d494fd9952df3cf1bcc37fea77b5ccd7 100644 (file)
@@ -35,7 +35,6 @@ class ProfilesController < ApplicationController
 
   # GET /profiles/create_form?language=<language>
   def create_form
-    access_denied unless has_role?(:profileadmin)
     require_parameters 'language'
     render :partial => 'profiles/create_form', :locals => {:language_key => params[:language]}
   end
@@ -325,9 +324,10 @@ class ProfilesController < ApplicationController
 
   # GET /profiles/rename_form?id=<id>
   def rename_form
-    access_denied unless has_role?(:profileadmin)
     require_parameters 'id'
-    @profile = Profile.find(params[:id])
+    call_backend do
+      @profile = Internal.quality_profiles.profile(params[:id].to_i)
+    end
     render :partial => 'profiles/rename_form'
   end
 
index 460e8baf902c04871f5587ae89009bc3d03e443d..e54c445768dbde568f34f49c03fd70c1d9175544 100644 (file)
@@ -73,6 +73,15 @@ public class QProfilesTest {
     qProfiles = new QProfiles(qualityProfileDao, resourceDao, projectService, search, service, rules);
   }
 
+  @Test
+  public void search_profile() throws Exception {
+    QualityProfileDto qualityProfile = new QualityProfileDto().setId(1).setName("Default").setLanguage("java");
+    when(qualityProfileDao.selectById(1)).thenReturn(qualityProfile);
+
+    qProfiles.profile(1);
+    verify(qualityProfileDao).selectById(1);
+  }
+
   @Test
   public void search_profiles() throws Exception {
     qProfiles.allProfiles();