Add user permissions for flagging and for giving user feedback

This commit is contained in:
Albert Yi
2018-12-11 16:41:20 -08:00
parent c34df49f0f
commit 4706cae114
10 changed files with 96 additions and 6 deletions

View File

@@ -37,6 +37,19 @@ class UserFeedbackTest < ActiveSupport::TestCase
assert_equal(["You cannot submit feedback for yourself"], feedback.errors.full_messages)
end
context "with a no_feedback user" do
setup do
@gold_user = FactoryBot.create(:gold_user, no_feedback: true)
CurrentUser.user = @gold_user
end
should "not validate" do
feedback = FactoryBot.build(:user_feedback, :user => @gold_user)
feedback.save
assert_equal(["You cannot submit feedback"], feedback.errors.full_messages.grep(/^You cannot submit feedback$/))
end
end
should "not validate if the creator is not gold" do
user = FactoryBot.create(:user)
gold = FactoryBot.create(:gold_user)