Don't allow new users to remove tags

fixes #2427
This commit is contained in:
Toks
2015-12-05 16:16:19 -05:00
parent 9bcbb48c6c
commit cd8bc87fa4
2 changed files with 10 additions and 3 deletions

View File

@@ -488,7 +488,8 @@ class Post < ActiveRecord::Base
def update_tag_post_counts
decrement_tags = tag_array_was - tag_array
if decrement_tags.size > 1 && !CurrentUser.is_builder? && CurrentUser.created_at > 1.week.ago
decrement_tags_except_requests = decrement_tags.reject {|tag| tag == "tagme" || tag.end_with?("_request")}
if decrement_tags_except_requests.size > 0 && !CurrentUser.is_builder? && CurrentUser.created_at > 1.week.ago
self.errors.add(:updater_id, "must have an account at least 1 week old to remove tags")
return false
end

View File

@@ -463,14 +463,20 @@ class PostTest < ActiveSupport::TestCase
context "as a new user" do
setup do
@post.update_attribute(:tag_string, "aaa bbb ccc ddd")
@post.update_attribute(:tag_string, "aaa bbb ccc ddd tagme")
CurrentUser.user = FactoryGirl.create(:user)
end
should "not allow you to remove more than 2 tags" do
should "not allow you to remove tags" do
@post.update_attributes(:tag_string => "aaa")
assert_equal(["You must have an account at least 1 week old to remove tags"], @post.errors.full_messages)
end
should "allow you to remove request tags" do
@post.update_attributes(:tag_string => "aaa bbb ccc ddd")
@post.reload
assert_equal("aaa bbb ccc ddd", @post.tag_string)
end
end
context "with a banned artist" do