Add locked:{notes,status,rating} editing metatags (fix #1716).
This commit is contained in:
@@ -679,7 +679,7 @@ class Post < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def filter_metatags(tags)
|
||||
@pre_metatags, tags = tags.partition {|x| x =~ /\A(?:rating|parent|-parent|source):/i}
|
||||
@pre_metatags, tags = tags.partition {|x| x =~ /\A(?:rating|parent|-parent|source|-?locked):/i}
|
||||
@post_metatags, tags = tags.partition {|x| x =~ /\A(?:-pool|pool|newpool|fav|-fav|child|-favgroup|favgroup):/i}
|
||||
apply_pre_metatags
|
||||
return tags
|
||||
@@ -773,6 +773,15 @@ class Post < ActiveRecord::Base
|
||||
|
||||
when /^rating:([qse])/i
|
||||
self.rating = $1.downcase
|
||||
|
||||
when /^(-?)locked:notes?$/i
|
||||
assign_attributes({ is_note_locked: $1 != "-" }, as: CurrentUser.role)
|
||||
|
||||
when /^(-?)locked:rating$/i
|
||||
assign_attributes({ is_rating_locked: $1 != "-" }, as: CurrentUser.role)
|
||||
|
||||
when /^(-?)locked:status$/i
|
||||
assign_attributes({ is_status_locked: $1 != "-" }, as: CurrentUser.role)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -731,6 +731,75 @@ class PostTest < ActiveSupport::TestCase
|
||||
assert_equal(14901720, @post.pixiv_id)
|
||||
end
|
||||
end
|
||||
|
||||
context "of" do
|
||||
setup do
|
||||
@builder = FactoryGirl.build(:builder_user)
|
||||
end
|
||||
|
||||
context "locked:notes" do
|
||||
context "by a member" do
|
||||
should "not lock the notes" do
|
||||
@post.update(:tag_string => "locked:notes")
|
||||
assert_equal(false, @post.is_note_locked)
|
||||
end
|
||||
end
|
||||
|
||||
context "by a builder" do
|
||||
should "lock/unlock the notes" do
|
||||
CurrentUser.scoped(@builder) do
|
||||
@post.update(:tag_string => "locked:notes")
|
||||
assert_equal(true, @post.is_note_locked)
|
||||
|
||||
@post.update(:tag_string => "-locked:notes")
|
||||
assert_equal(false, @post.is_note_locked)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "locked:rating" do
|
||||
context "by a member" do
|
||||
should "not lock the rating" do
|
||||
@post.update(:tag_string => "locked:rating")
|
||||
assert_equal(false, @post.is_rating_locked)
|
||||
end
|
||||
end
|
||||
|
||||
context "by a builder" do
|
||||
should "lock/unlock the rating" do
|
||||
CurrentUser.scoped(@builder) do
|
||||
@post.update(:tag_string => "locked:rating")
|
||||
assert_equal(true, @post.is_rating_locked)
|
||||
|
||||
@post.update(:tag_string => "-locked:rating")
|
||||
assert_equal(false, @post.is_rating_locked)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "locked:status" do
|
||||
context "by a member" do
|
||||
should "not lock the status" do
|
||||
@post.update(:tag_string => "locked:status")
|
||||
assert_equal(false, @post.is_status_locked)
|
||||
end
|
||||
end
|
||||
|
||||
context "by an admin" do
|
||||
should "lock/unlock the status" do
|
||||
CurrentUser.scoped(FactoryGirl.build(:admin_user)) do
|
||||
@post.update(:tag_string => "locked:status")
|
||||
assert_equal(true, @post.is_status_locked)
|
||||
|
||||
@post.update(:tag_string => "-locked:status")
|
||||
assert_equal(false, @post.is_status_locked)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "tagged with a negated tag" do
|
||||
|
||||
Reference in New Issue
Block a user