aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2011-06-16 10:20:46 +0200
committerFabrice Bellingard <bellingard@gmail.com>2011-06-16 10:20:46 +0200
commita8df494575bd5108e2090924e2877ef8c43fd348 (patch)
tree534ff80f151800eec6bbd83cd3b04aba40b935b6
parent90ba5ef80d412429322496d8b1bb38452ed10b02 (diff)
downloadsonarqube-a8df494575bd5108e2090924e2877ef8c43fd348.tar.gz
sonarqube-a8df494575bd5108e2090924e2877ef8c43fd348.zip
SONAR-2520 When flagging as flase positive, set status to OPEN
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb25
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/review.rb1
2 files changed, 7 insertions, 19 deletions
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 892dc6f1ba5..07b4bc6ac71 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
@@ -117,20 +117,11 @@ class ReviewsController < ApplicationController
render :text => "<b>Cannot create the comment</b> : access denied."
return
end
-
- false_positive=(params[:false_positive]=='true')
- RuleFailure.find( :all, :conditions => [ "permanent_id = ?", @review.rule_failure_permanent_id ] ).each do |violation|
- violation.switched_off=false_positive
- violation.save!
- end
- @review.false_positive = false_positive
- @review.assignee = nil
- @review.save!
unless params[:comment].blank?
- @review.comments.create(:review_text => params[:comment], :user_id => current_user.id)
+ @review.set_false_positive(params[:false_positive]=='true', :user => current_user, :text => params[:comment])
end
-
+
render :partial => "reviews/view"
end
@@ -215,18 +206,14 @@ class ReviewsController < ApplicationController
return
end
sanitize_violation(violation)
- false_positive=(params[:false_positive]=='true')
- violation.switched_off=false_positive
- violation.save!
-
+
unless params[:comment].blank?
if violation.review.nil?
violation.build_review(:user_id => current_user.id)
end
- violation.review.false_positive=false_positive
- violation.review.assignee=nil
- violation.review.save!
- violation.review.comments.create(:review_text => params[:comment], :user_id => current_user.id)
+ violation.review.set_false_positive(params[:false_positive]=='true', :user => current_user, :text => params[:comment], :violation_id => violation.id)
+ # refresh the violation that has been modified when setting the review to false positive
+ violation=RuleFailure.find(params[:id])
end
render :partial => "resource/violation", :locals => { :violation => violation }
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb
index 74ad759c008..9b886cfbd79 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb
@@ -112,6 +112,7 @@ class Review < ActiveRecord::Base
create_comment(:user => params[:user], :text => params[:text])
self.false_positive = is_false_positive
self.assignee = nil
+ self.status = STATUS_OPEN
self.save!
end
end