#1383: Remove banned_artist tag
This commit is contained in:
@@ -205,16 +205,19 @@ class Artist < ActiveRecord::Base
|
|||||||
def unban!
|
def unban!
|
||||||
Post.transaction do
|
Post.transaction do
|
||||||
CurrentUser.without_safe_mode do
|
CurrentUser.without_safe_mode do
|
||||||
|
ti = TagImplication.where(:antecedent_name => name, :consequent_name => "banned_artist").first
|
||||||
|
ti.destroy if ti
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Post.tag_match(name).each do |post|
|
Post.tag_match(name).each do |post|
|
||||||
post.unban!
|
post.unban!
|
||||||
|
fixed_tags = post.tag_string.sub(/(?:\A| )banned_artist(?:\Z| )/, " ").strip
|
||||||
|
post.update_attributes(:tag_string => fixed_tags)
|
||||||
end
|
end
|
||||||
rescue Post::SearchError
|
rescue Post::SearchError
|
||||||
# swallow
|
# swallow
|
||||||
end
|
end
|
||||||
|
|
||||||
ti = TagImplication.where(:antecedent_name => name, :consequent_name => "banned_artist").first
|
|
||||||
ti.destroy if ti
|
|
||||||
update_column(:is_banned, false)
|
update_column(:is_banned, false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% if CurrentUser.is_admin? %>
|
<% if CurrentUser.is_admin? %>
|
||||||
<% if @artist.is_banned? %>
|
<% if @artist.is_banned? %>
|
||||||
<li><%= link_to "unban", unban_artist_path(@artist), :method => :put, :confirm => "Are you sure you want to unban this artist?" %></li>
|
<li><%= link_to "Unban", unban_artist_path(@artist), :method => :put, :confirm => "Are you sure you want to unban this artist?" %></li>
|
||||||
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<li><%= link_to "Ban", ban_artist_path(@artist), :method => :put, :confirm => "Are you sure you want to ban this artist?" %></li>
|
<li><%= link_to "Ban", ban_artist_path(@artist), :method => :put, :confirm => "Are you sure you want to ban this artist?" %></li>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
CurrentUser.user = user
|
CurrentUser.user = user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
|
Delayed::Worker.delay_jobs = false
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
@@ -45,6 +46,7 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
@artist.reload
|
@artist.reload
|
||||||
assert(!@artist.is_banned?, "artist should not be banned")
|
assert(!@artist.is_banned?, "artist should not be banned")
|
||||||
assert(!@post.is_banned?, "post should not be banned")
|
assert(!@post.is_banned?, "post should not be banned")
|
||||||
|
assert_equal("aaa", @post.tag_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "ban the post" do
|
should "ban the post" do
|
||||||
@@ -57,6 +59,7 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
should "create a new tag implication" do
|
should "create a new tag implication" do
|
||||||
assert_equal(1, TagImplication.where(:antecedent_name => "aaa", :consequent_name => "banned_artist").count)
|
assert_equal(1, TagImplication.where(:antecedent_name => "aaa", :consequent_name => "banned_artist").count)
|
||||||
|
assert_equal("aaa banned_artist", @post.tag_string)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user