From 1ba5543d0a6d6fad870c0c81ae1ba3ebe86897c7 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 4 Jun 2013 13:40:42 +0200 Subject: [PATCH] SONAR-3755 Improve action plan rights --- .../server/issue/InternalRubyIssueService.java | 2 +- .../app/controllers/api/action_plans_controller.rb | 6 ++++-- .../src/main/webapp/WEB-INF/app/models/api/utils.rb | 13 ++++++++++++- .../WEB-INF/app/views/action_plans/_new.html.erb | 3 +-- .../server/issue/InternalRubyIssueServiceTest.java | 1 + 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java b/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java index 24e5f67f0f3..53da80c91d9 100644 --- a/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java +++ b/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java @@ -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)); diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/action_plans_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/action_plans_controller.rb index 41ebd88eaa8..6408df9ceef 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/action_plans_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/action_plans_controller.rb @@ -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'. # diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb index c63cd307e1e..4ea55276485 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb @@ -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) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_new.html.erb index 8bd4a17584f..0159c7930b6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_new.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_new.html.erb @@ -17,8 +17,7 @@ <%= message('action_plans.col.due_for') -%>:
- <% deadline = Api::Utils.java_to_ruby_datetime(@action_plan.deadLine()) if @action_plan && @action_plan.deadLine() %> - +
<%= message('action_plans.date_format_help') -%> diff --git a/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java b/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java index 0a82a2335cd..31b7e4d4e11 100644 --- a/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java +++ b/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java @@ -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 actionPlanCaptor = ArgumentCaptor.forClass(ActionPlan.class); Result result = internalRubyIssueService.updateActionPlan("ABCD", parameters); -- 2.39.5