aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-06-26 17:46:16 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-06-26 17:46:16 +0200
commitc586b37d98ba39fc888ff37c33a27925969cca2f (patch)
tree4474ea6576e463999d04b5f4dcee9d3c973a8ca6
parentf74c99ea6c3fd2f4290950062e5ed0a4563fa8d2 (diff)
downloadsonarqube-c586b37d98ba39fc888ff37c33a27925969cca2f.tar.gz
sonarqube-c586b37d98ba39fc888ff37c33a27925969cca2f.zip
SONAR-4421 Improve plan action
-rw-r--r--sonar-server/src/main/java/org/sonar/server/issue/PlanAction.java2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/issues/_bulk_change_form.html.erb8
-rw-r--r--sonar-server/src/test/java/org/sonar/server/issue/PlanActionTest.java25
3 files changed, 30 insertions, 5 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/PlanAction.java b/sonar-server/src/main/java/org/sonar/server/issue/PlanAction.java
index a64b8df9814..b43bedbba97 100644
--- a/sonar-server/src/main/java/org/sonar/server/issue/PlanAction.java
+++ b/sonar-server/src/main/java/org/sonar/server/issue/PlanAction.java
@@ -56,8 +56,6 @@ public class PlanAction extends Action implements ServerComponent {
throw new IllegalArgumentException("Unknown action plan: " + actionPlanKey);
}
verifyIssuesAreAllRelatedOnActionPlanProject(issues, actionPlan);
- } else {
- throw new IllegalArgumentException("Unknown action plan: " + actionPlanKey);
}
return true;
}
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_bulk_change_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_bulk_change_form.html.erb
index 391a08bb4fa..d8ae9b2006b 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_bulk_change_form.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_bulk_change_form.html.erb
@@ -24,17 +24,19 @@
<%
if project && !project.blank?
plans = Internal.issues.findOpenActionPlans(project)
- first_plan = plans[0]
plan_options = ""
unless plans.empty?
- plan_options = options_for_select(plans.map { |plan|
+ first_plan = plans[0]
+ options = plans.map { |plan|
if plan.deadLine
label = "#{h plan.name} (#{format_date(plan.deadLine)})"
else
label = h plan.name
end
[label, plan.key]
- }, first_plan.key)
+ }
+ options.unshift([escape_javascript(message('issue.unplan.submit')), ''])
+ plan_options = options_for_select(options, first_plan.key)
end
%>
<div class="modal-field">
diff --git a/sonar-server/src/test/java/org/sonar/server/issue/PlanActionTest.java b/sonar-server/src/test/java/org/sonar/server/issue/PlanActionTest.java
index 5b56097781f..f524b7b12e6 100644
--- a/sonar-server/src/test/java/org/sonar/server/issue/PlanActionTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/issue/PlanActionTest.java
@@ -66,6 +66,31 @@ public class PlanActionTest {
}
@Test
+ public void should_execute_on_null_action_plan(){
+ Map<String, Object> properties = newHashMap();
+ DefaultIssue issue = mock(DefaultIssue.class);
+
+ Action.Context context = mock(Action.Context.class);
+ when(context.issue()).thenReturn(issue);
+
+ action.execute(properties, context);
+ verify(issueUpdater).plan(eq(issue), eq((String) null), any(IssueChangeContext.class));
+ }
+
+ @Test
+ public void should_execute_on_empty_action_plan(){
+ Map<String, Object> properties = newHashMap();
+ properties.put("plan", "");
+ DefaultIssue issue = mock(DefaultIssue.class);
+
+ Action.Context context = mock(Action.Context.class);
+ when(context.issue()).thenReturn(issue);
+
+ action.execute(properties, context);
+ verify(issueUpdater).plan(eq(issue), eq(""), any(IssueChangeContext.class));
+ }
+
+ @Test
public void should_verify(){
String planKey = "ABCD";
Map<String, Object> properties = newHashMap();