summaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2011-12-19 17:36:37 +0100
committerFabrice Bellingard <bellingard@gmail.com>2011-12-19 17:55:26 +0100
commita6572b36de5b37fcae5492a45573df86cf555896 (patch)
tree68c9124e2c30b185dd66b8df8c488fde4eefc25b /sonar-server
parentf63223a280328fab1147c4c048966e5e1792dd74 (diff)
downloadsonarqube-a6572b36de5b37fcae5492a45573df86cf555896.tar.gz
sonarqube-a6572b36de5b37fcae5492a45573df86cf555896.zip
SONAR-2662 Adapt validation of dead_line
It should not be done at every save, but only when creating/editing the action plan (=> it must be possible to close an action plan when its dead-line is reached).
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb16
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb1
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb11
3 files changed, 14 insertions, 14 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb
index 5a1466a3d93..b27456c767b 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb
@@ -43,12 +43,20 @@ class ActionPlansController < ApplicationController
:project_id => @resource.id,
:status => ActionPlan::STATUS_OPEN)
end
+
@action_plan.name = params[:name]
@action_plan.description = params[:description]
- begin
- @action_plan.dead_line = Date.strptime(params[:dead_line], '%d/%m/%Y') unless params[:dead_line].blank?
- rescue
- date_not_valid = message('action_plans.date_not_valid')
+ unless params[:dead_line].blank?
+ begin
+ dead_line = Date.strptime(params[:dead_line], '%d/%m/%Y')
+ if dead_line.past?
+ date_not_valid = message('action_plans.date_cant_be_in_past')
+ else
+ @action_plan.dead_line = dead_line
+ end
+ rescue
+ date_not_valid = message('action_plans.date_not_valid')
+ end
end
if date_not_valid || !@action_plan.valid?
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
index f0c1c446bb7..21295789a0c 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
@@ -24,6 +24,7 @@ class ReviewsController < ApplicationController
verify :method => :post,
:only => [:assign, :flag_as_false_positive, :save_comment, :delete_comment, :change_status,
+ :link_to_action_plan,
:violation_assign, :violation_flag_as_false_positive, :violation_change_severity,
:violation_save_comment, :violation_delete_comment, :violation_change_status,
:violation_link_to_action_plan],
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb
index 48a72017e24..73562567163 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb
@@ -28,7 +28,6 @@ class ActionPlan < ActiveRecord::Base
validates_presence_of :user_login, :message => "can't be empty"
validates_presence_of :status, :message => "can't be empty"
validates_presence_of :project, :message => "can't be empty"
- validate :dead_line_cannot_be_in_the_past
STATUS_OPEN = 'OPEN'
STATUS_CLOSED = 'CLOSED'
@@ -63,15 +62,7 @@ class ActionPlan < ActiveRecord::Base
end
def over_due?
- dead_line ? dead_line.past? : false
- end
-
- private
-
- def dead_line_cannot_be_in_the_past
- if !dead_line.blank? and dead_line < Date.today
- errors.add(:dead_line, Api::Utils.message('action_plans.date_cant_be_in_past'))
- end
+ dead_line ? status==STATUS_OPEN && dead_line.past? : false
end
end