]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4421 Improve plan action
authorJulien Lancelot <julien.lancelot@gmail.com>
Wed, 26 Jun 2013 15:46:16 +0000 (17:46 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Wed, 26 Jun 2013 15:46:16 +0000 (17:46 +0200)
sonar-server/src/main/java/org/sonar/server/issue/PlanAction.java
sonar-server/src/main/webapp/WEB-INF/app/views/issues/_bulk_change_form.html.erb
sonar-server/src/test/java/org/sonar/server/issue/PlanActionTest.java

index a64b8df98142cee5b24e299250d1574235de0670..b43bedbba97d950ca5f7ebd959dd0276e31d12d9 100644 (file)
@@ -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;
   }
index 391a08bb4fa12dca7b92699148d1dd4c57a0efbd..d8ae9b2006b9742d22c322d7867f574ce1153e80 100644 (file)
       <%
          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">
index 5b56097781fcb85dc260250df0735b12e3282b41..f524b7b12e6ad716a03c1ee45188c3f7b27485fd 100644 (file)
@@ -65,6 +65,31 @@ public class PlanActionTest {
     verify(issueUpdater).plan(eq(issue), eq(planKey), any(IssueChangeContext.class));
   }
 
+  @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";