pundit: convert user feedbacks to pundit.

Allow users to delete feedbacks they've given to other users, not just
mods.
This commit is contained in:
evazion
2020-03-17 05:52:38 -05:00
parent 565a6572a7
commit 4cd0b2cbfe
9 changed files with 95 additions and 87 deletions

View File

@@ -17,25 +17,5 @@ class UserFeedbackTest < ActiveSupport::TestCase
assert_equal(dmail, user.dmails.last.body)
end
end
should "not validate if the creator is the user" do
user = FactoryBot.create(:gold_user)
feedback = build(:user_feedback, creator: user, user: user)
feedback.save
assert_equal(["You cannot submit feedback for yourself"], feedback.errors.full_messages)
end
should "not validate if the creator is not gold" do
user = FactoryBot.create(:user)
gold = FactoryBot.create(:gold_user)
member = FactoryBot.create(:user)
feedback = FactoryBot.create(:user_feedback, creator: gold, user: user)
assert(feedback.errors.empty?)
feedback = build(:user_feedback, creator: member, user: user)
feedback.save
assert_equal(["You must be gold"], feedback.errors.full_messages)
end
end
end