]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2520 When flagging as flase positive, set status to OPEN
authorFabrice Bellingard <bellingard@gmail.com>
Thu, 16 Jun 2011 08:20:46 +0000 (10:20 +0200)
committerFabrice Bellingard <bellingard@gmail.com>
Thu, 16 Jun 2011 08:20:46 +0000 (10:20 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/review.rb

index 892dc6f1ba55909ed21c3dcb4f729aa1cbacf387..07b4bc6ac714aad22a0d620146b41e9048196997 100644 (file)
@@ -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 }
index 74ad759c008c51c493ca5e2e4486ad10a01b6a37..9b886cfbd79cbd4216712a4e73a2cf4ab10b03b2 100644 (file)
@@ -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