diff options
author | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2010-06-05 22:10:07 +0200 |
---|---|---|
committer | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2010-06-08 21:57:19 +0200 |
commit | 9813d1b03a62d3ccf42ee1d0584b8a923215c98e (patch) | |
tree | ce19a81f33240d5d467265506b5889c7453f22c2 | |
parent | Make sure user isn't assigned to one category many times. (diff) | |
download | recruiting-webapp-9813d1b03a62d3ccf42ee1d0584b8a923215c98e.tar.gz recruiting-webapp-9813d1b03a62d3ccf42ee1d0584b8a923215c98e.tar.bz2 recruiting-webapp-9813d1b03a62d3ccf42ee1d0584b8a923215c98e.zip |
Mark answer as unapproved if content was changed
-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 |