]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3755 Improve action plan rights
authorJulien Lancelot <julien.lancelot@gmail.com>
Tue, 4 Jun 2013 11:40:42 +0000 (13:40 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Tue, 4 Jun 2013 11:40:42 +0000 (13:40 +0200)
sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/action_plans_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb
sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_new.html.erb
sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java

index 24e5f67f0f33d1026d03f0df7dbe0c9712332f13..53da80c91d953f2cc7ff3c5567767415e02a20f0 100644 (file)
@@ -290,7 +290,7 @@ public class InternalRubyIssueService implements ServerComponent {
       result.addError(Result.Message.ofL10n("errors.is_too_long", "description", 1000));
     }
 
-    if (Strings.isNullOrEmpty(projectParam) && oldName == null) {
+    if (Strings.isNullOrEmpty(projectParam)) {
       result.addError(Result.Message.ofL10n("errors.cant_be_empty", "project"));
     } else {
       ResourceDto project = resourceDao.getResource(ResourceQuery.create().setKey(projectParam));
index 41ebd88eaa842af1d482c211880b0e03e0731bcb..6408df9ceef3cf5f268162eb097b8121ed404e4a 100644 (file)
@@ -91,9 +91,11 @@ class Api::ActionPlansController < Api::ApiController
   #
   # POST /api/action_plans/update
   #
+  # -- Mandatory parameters
+  # 'name' is the name of the action plan
+  # 'project' is the key of the project to link the action plan to
+  #
   # -- Optional parameters
-  # 'name' is the action plan name
-  # 'project' is the project key to link the action plan to
   # 'description' is the plain-text description
   # 'deadLine' is the due date of the action plan. Format is 'day/month/year', for instance, '31/12/2013'.
   #
index c63cd307e1e6231c1d782ca7d0184fb4724eb849..4ea55276485de2f4eba4ddb7c19826d227dbe86f 100644 (file)
@@ -21,7 +21,7 @@ require 'time'
 
 class Api::Utils
 
-  # Format dateTime to ISO format
+  # Format dateTime to ISO format (yyyy-MM-dd'T'HH:mm:ssZ)
   #
   # -- Revisions
   # Added in 2.8
@@ -33,6 +33,17 @@ class Api::Utils
     dt.strftime("%Y-%m-%dT%H:%M:%S%z")
   end
 
+  # Format dateTime to ISO format (yyyy-MM-dd)
+  #
+  # Added in 3.6
+  # Support java.util.Date
+  #
+  def self.format_date(datetime)
+    return nil unless datetime
+    dt = datetime.is_a?(Java::JavaUtil::Date) ? java_to_ruby_datetime(datetime) : datetime
+    dt.strftime("%Y-%m-%d")
+  end
+
   def self.parse_datetime(datetime_string, default_is_now=true)
     if datetime_string.blank?
       return (default_is_now ? Time.now : nil)
index 8bd4a17584f70458013d00e364cbba58ee8fc7fe..0159c7930b68e64548640511aa7dd8061c435cff 100644 (file)
@@ -17,8 +17,7 @@
       <td class="left" valign="top">
         <%= message('action_plans.col.due_for') -%>:
         <br/>
-        <% deadline = Api::Utils.java_to_ruby_datetime(@action_plan.deadLine()) if @action_plan && @action_plan.deadLine() %>
-        <input type="text" name="deadline" id="deadline" value="<%= @action_plan && deadline ? deadline.strftime('%d/%m/%Y') : params[:deadline] -%>"/>
+        <input type="text" name="deadline" id="deadline" value="<%= @action_plan && @action_plan.deadLine() ? Api::Utils.format_date(@action_plan.deadLine()) : params[:deadline] -%>"/>
         <br/>
         <span class="note"><%= message('action_plans.date_format_help') -%></span>
       </td>
index 0a82a2335cd7af85d61116bafa20eaa07aab1db4..31b7e4d4e11e6a528e70152f3447cd8cad8fe4de 100644 (file)
@@ -84,6 +84,7 @@ public class InternalRubyIssueServiceTest {
     parameters.put("name", "New Long term");
     parameters.put("description", "New Long term issues");
     parameters.put("deadLine", "2113-05-13");
+    parameters.put("project", "org.sonar.MultiSample");
 
     ArgumentCaptor<ActionPlan> actionPlanCaptor = ArgumentCaptor.forClass(ActionPlan.class);
     Result result = internalRubyIssueService.updateActionPlan("ABCD", parameters);