diff options
-rw-r--r-- | app/models/answer.rb | 4 | ||||
-rw-r--r-- | spec/models/answer_spec.rb | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/app/models/answer.rb b/app/models/answer.rb index da3a508..76fc37d 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -18,6 +18,10 @@ class Answer < ActiveRecord::Base owned_model owner_class = "User" + before_validation do |record| + record.approved = false if record.content_changed? + end + multi_permission :update, :destroy do (owned? && !reference && !approved) || (reference && acting_user.role.is_recruiter?) || diff --git a/spec/models/answer_spec.rb b/spec/models/answer_spec.rb index bb11112..0e37f17 100644 --- a/spec/models/answer_spec.rb +++ b/spec/models/answer_spec.rb @@ -127,4 +127,11 @@ describe Answer do @ans.approved_changed?.should be_true @ans.should be_updatable_by(@ans.owner) end + + it "should mark questions with changed content as unapproved" do + @ans.approved.should be_true + @ans.content = "changed" + @ans.save + @ans.approved.should be_false + end end |