diff options
author | 2010-08-03 14:58:20 +0200 | |
---|---|---|
committer | 2010-08-05 18:18:53 +0200 | |
commit | 6131a23d6528133549f2482ab40404bcd5f3c109 (patch) | |
tree | 75f7f07fa63e100cf4864b6486084c220c1c3b2e | |
parent | Put content inside <content-body:> instead of <content:> (diff) | |
download | recruiting-webapp-6131a23d6528133549f2482ab40404bcd5f3c109.tar.gz recruiting-webapp-6131a23d6528133549f2482ab40404bcd5f3c109.tar.bz2 recruiting-webapp-6131a23d6528133549f2482ab40404bcd5f3c109.zip |
Only owner can edit feedback of answer
Previously mentors were allowed to edit feedback but they weren't allowed
to update answer with changed feedback.
-rw-r--r-- | app/models/answer.rb | 4 | ||||
-rw-r--r-- | spec/models/answer_spec.rb | 13 |
2 files changed, 17 insertions, 0 deletions
diff --git a/app/models/answer.rb b/app/models/answer.rb index 948f564..bde4deb 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -61,6 +61,10 @@ class Answer < ActiveRecord::Base (reference && acting_user.signed_up? && acting_user.role.is_recruiter?) end + def feedback_edit_permitted? + owned_soft? + end + def approved_edit_permitted? owner.mentor_is?(acting_user) end diff --git a/spec/models/answer_spec.rb b/spec/models/answer_spec.rb index 4484bc0..27c65d4 100644 --- a/spec/models/answer_spec.rb +++ b/spec/models/answer_spec.rb @@ -202,4 +202,17 @@ describe Answer do Answer.in_category(cat).uniq end end + + it "should allow only owner to change feedback" do + ans = Factory(:answer) + owner = ans.owner + others = fabricate_users(:administrator, :recruit, :mentor, :recruiter) + [Guest.new, ans.owner.mentor] + + ans.should be_editable_by(owner, :feedback) + edit_denied(others, ans, :feedback) + + ans.feedback = 'changed' + ans.should be_updatable_by(owner) + ud_denied(others, ans) + end end |