posts: add "general" rating; rename "safe" rating to "sensitive".
* Add "general" rating. * Rename "safe" rating to "sensitive". * Change safe mode to include both rating:s and rating:g. * Treat rating:safe as a synonym for rating:sensitive. * Link "howto:rate" in the post edit form.
This commit is contained in:
@@ -31,8 +31,8 @@ class AutocompleteControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_autocomplete_equals(["azur_lane"], "~azur", "tag_query")
|
||||
assert_autocomplete_equals(["azur_lane"], "AZUR", "tag_query")
|
||||
|
||||
assert_autocomplete_equals(["rating:safe"], "rating:s", "tag_query")
|
||||
assert_autocomplete_equals(["rating:safe"], "-rating:s", "tag_query")
|
||||
assert_autocomplete_equals(["rating:sensitive"], "rating:s", "tag_query")
|
||||
assert_autocomplete_equals(["rating:sensitive"], "-rating:s", "tag_query")
|
||||
end
|
||||
|
||||
should "work for a missing type" do
|
||||
|
||||
@@ -162,7 +162,8 @@ class AutocompleteServiceTest < ActiveSupport::TestCase
|
||||
assert_autocomplete_equals(["parent:active"], "parent:act", :tag_query)
|
||||
assert_autocomplete_equals(["child:active"], "child:act", :tag_query)
|
||||
|
||||
assert_autocomplete_equals(["rating:safe"], "rating:s", :tag_query)
|
||||
assert_autocomplete_equals(["rating:general"], "rating:g", :tag_query)
|
||||
assert_autocomplete_equals(["rating:sensitive"], "rating:s", :tag_query)
|
||||
assert_autocomplete_equals(["rating:questionable"], "rating:q", :tag_query)
|
||||
assert_autocomplete_equals(["rating:explicit"], "rating:e", :tag_query)
|
||||
|
||||
@@ -190,7 +191,8 @@ class AutocompleteServiceTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "match static metatags case-insensitively" do
|
||||
assert_autocomplete_equals(["rating:safe"], "rating:S", :tag_query)
|
||||
assert_autocomplete_equals(["rating:general"], "rating:G", :tag_query)
|
||||
assert_autocomplete_equals(["rating:sensitive"], "rating:S", :tag_query)
|
||||
assert_autocomplete_equals(["rating:questionable"], "rating:Q", :tag_query)
|
||||
assert_autocomplete_equals(["rating:explicit"], "rating:E", :tag_query)
|
||||
end
|
||||
|
||||
@@ -753,15 +753,18 @@ class PostQueryBuilderTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "return posts for the is:<rating> metatag" do
|
||||
g = create(:post, rating: "g")
|
||||
s = create(:post, rating: "s")
|
||||
q = create(:post, rating: "q")
|
||||
e = create(:post, rating: "e")
|
||||
all = [e, q, s]
|
||||
all = [e, q, s, g]
|
||||
|
||||
assert_tag_match([g], "is:general")
|
||||
assert_tag_match([s], "is:safe")
|
||||
assert_tag_match([s], "is:sensitive")
|
||||
assert_tag_match([q], "is:questionable")
|
||||
assert_tag_match([e], "is:explicit")
|
||||
assert_tag_match([s], "is:sfw")
|
||||
assert_tag_match([s, g], "is:sfw")
|
||||
assert_tag_match([e, q], "is:nsfw")
|
||||
end
|
||||
|
||||
|
||||
@@ -733,8 +733,35 @@ class PostTest < ActiveSupport::TestCase
|
||||
context "that is valid" do
|
||||
should "update the rating" do
|
||||
@post.update(tag_string: "aaa rating:e")
|
||||
@post.reload
|
||||
assert_equal("e", @post.rating)
|
||||
assert_equal("e", @post.reload.rating)
|
||||
|
||||
@post.update(tag_string: "aaa rating:q")
|
||||
assert_equal("q", @post.reload.rating)
|
||||
|
||||
@post.update(tag_string: "aaa rating:s")
|
||||
assert_equal("s", @post.reload.rating)
|
||||
|
||||
@post.update(tag_string: "aaa rating:g")
|
||||
assert_equal("g", @post.reload.rating)
|
||||
end
|
||||
|
||||
should "update the rating for a long name" do
|
||||
@post.update(tag_string: "aaa rating:explicit")
|
||||
assert_equal("e", @post.reload.rating)
|
||||
|
||||
@post.update(tag_string: "aaa rating:questionable")
|
||||
assert_equal("q", @post.reload.rating)
|
||||
|
||||
@post.update(tag_string: "aaa rating:sensitive")
|
||||
assert_equal("s", @post.reload.rating)
|
||||
|
||||
@post.update(tag_string: "aaa rating:general")
|
||||
assert_equal("g", @post.reload.rating)
|
||||
end
|
||||
|
||||
should "update the rating for rating:safe" do
|
||||
@post.update(tag_string: "aaa rating:safe")
|
||||
assert_equal("s", @post.reload.rating)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1623,8 +1650,8 @@ class PostTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
should "allow values s, q, e" do
|
||||
["s", "q", "e"].each do |rating|
|
||||
should "allow values g, s, q, e" do
|
||||
["g", "s", "q", "e"].each do |rating|
|
||||
subject.rating = rating
|
||||
assert(subject.valid?)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user