Merge pull request #3989 from evazion/fix-3987
Wiki pages: convert other_names column to array (#3987)
This commit is contained in:
@@ -407,8 +407,8 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "normalize its other names" do
|
||||
artist = FactoryBot.create(:artist, :name => "a1", :other_names_comma => "aaa, bbb, ccc ddd")
|
||||
assert_equal("aaa, bbb, ccc_ddd", artist.other_names_comma)
|
||||
artist = FactoryBot.create(:artist, :name => "a1", :other_names => "aaa bbb ccc_ddd")
|
||||
assert_equal("aaa bbb ccc_ddd", artist.other_names_string)
|
||||
end
|
||||
|
||||
should "search on its name should return results" do
|
||||
@@ -421,11 +421,11 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "search on other names should return matches" do
|
||||
artist = FactoryBot.create(:artist, :name => "artist", :other_names_comma => "aaa, ccc ddd")
|
||||
artist = FactoryBot.create(:artist, :name => "artist", :other_names_string => "aaa ccc_ddd")
|
||||
|
||||
assert_nil(Artist.search(other_names_like: "*artist*").first)
|
||||
assert_not_nil(Artist.search(other_names_like: "*aaa*").first)
|
||||
assert_not_nil(Artist.search(other_names_like: "*ccc_ddd*").first)
|
||||
assert_nil(Artist.search(any_other_name_like: "*artist*").first)
|
||||
assert_not_nil(Artist.search(any_other_name_like: "*aaa*").first)
|
||||
assert_not_nil(Artist.search(any_other_name_like: "*ccc_ddd*").first)
|
||||
assert_not_nil(Artist.search(name: "artist").first)
|
||||
assert_not_nil(Artist.search(:any_name_matches => "aaa").first)
|
||||
assert_not_nil(Artist.search(:any_name_matches => "/a/").first)
|
||||
@@ -475,10 +475,10 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
first_version = ArtistVersion.first
|
||||
assert_equal("yyy", first_version.other_names)
|
||||
assert_equal(%w[yyy], first_version.other_names)
|
||||
artist.revert_to!(first_version)
|
||||
artist.reload
|
||||
assert_equal("yyy", artist.other_names)
|
||||
assert_equal(%w[yyy], artist.other_names)
|
||||
end
|
||||
|
||||
should "update the category of the tag when created" do
|
||||
@@ -506,35 +506,35 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
should "create a new version when an url is added" do
|
||||
assert_difference("ArtistVersion.count") do
|
||||
@artist.update(:url_string => "http://foo.com http://bar.com")
|
||||
assert_equal(%w[http://bar.com http://foo.com], @artist.versions.last.url_array)
|
||||
assert_equal(%w[http://bar.com http://foo.com], @artist.versions.last.urls)
|
||||
end
|
||||
end
|
||||
|
||||
should "create a new version when an url is removed" do
|
||||
assert_difference("ArtistVersion.count") do
|
||||
@artist.update(:url_string => "")
|
||||
assert_equal(%w[], @artist.versions.last.url_array)
|
||||
assert_equal(%w[], @artist.versions.last.urls)
|
||||
end
|
||||
end
|
||||
|
||||
should "create a new version when an url is marked inactive" do
|
||||
assert_difference("ArtistVersion.count") do
|
||||
@artist.update(:url_string => "-http://foo.com")
|
||||
assert_equal(%w[-http://foo.com], @artist.versions.last.url_array)
|
||||
assert_equal(%w[-http://foo.com], @artist.versions.last.urls)
|
||||
end
|
||||
end
|
||||
|
||||
should "not create a new version when nothing has changed" do
|
||||
assert_no_difference("ArtistVersion.count") do
|
||||
@artist.save
|
||||
assert_equal(%w[http://foo.com], @artist.versions.last.url_array)
|
||||
assert_equal(%w[http://foo.com], @artist.versions.last.urls)
|
||||
end
|
||||
end
|
||||
|
||||
should "not save invalid urls" do
|
||||
assert_no_difference("ArtistVersion.count") do
|
||||
@artist.update(:url_string => "http://foo.com www.example.com")
|
||||
assert_equal(%w[http://foo.com], @artist.versions.last.url_array)
|
||||
assert_equal(%w[http://foo.com], @artist.versions.last.urls)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -46,7 +46,7 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
ti2 = FactoryBot.build(:tag_implication, :antecedent_name => "b", :consequent_name => "c", :status => "pending")
|
||||
ti2.save
|
||||
ti1 = FactoryBot.create(:tag_implication, :antecedent_name => "a", :consequent_name => "b")
|
||||
assert_equal("b", ti1.descendant_names)
|
||||
assert_equal(%w[b], ti1.descendant_names)
|
||||
end
|
||||
|
||||
should "populate the creator information" do
|
||||
@@ -89,14 +89,11 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
|
||||
should "calculate all its descendants" do
|
||||
ti1 = FactoryBot.create(:tag_implication, :antecedent_name => "bbb", :consequent_name => "ccc")
|
||||
assert_equal("ccc", ti1.descendant_names)
|
||||
assert_equal(["ccc"], ti1.descendant_names_array)
|
||||
assert_equal(%w[ccc], ti1.descendant_names)
|
||||
ti2 = FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb")
|
||||
assert_equal("bbb ccc", ti2.descendant_names)
|
||||
assert_equal(["bbb", "ccc"], ti2.descendant_names_array)
|
||||
assert_equal(%w[bbb ccc], ti2.descendant_names)
|
||||
ti1.reload
|
||||
assert_equal("ccc", ti1.descendant_names)
|
||||
assert_equal(["ccc"], ti1.descendant_names_array)
|
||||
assert_equal(%w[ccc], ti1.descendant_names)
|
||||
end
|
||||
|
||||
should "update its descendants on save" do
|
||||
@@ -109,8 +106,8 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
)
|
||||
ti1.reload
|
||||
ti2.reload
|
||||
assert_equal("bbb ddd", ti1.descendant_names)
|
||||
assert_equal("ddd", ti2.descendant_names)
|
||||
assert_equal(%w[bbb ddd], ti1.descendant_names)
|
||||
assert_equal(%w[ddd], ti2.descendant_names)
|
||||
end
|
||||
|
||||
should "update the descendants for all of its parents on destroy" do
|
||||
@@ -122,49 +119,49 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
ti2.reload
|
||||
ti3.reload
|
||||
ti4.reload
|
||||
assert_equal("bbb ccc ddd", ti1.descendant_names)
|
||||
assert_equal("bbb ccc ddd", ti2.descendant_names)
|
||||
assert_equal("ccc ddd", ti3.descendant_names)
|
||||
assert_equal("ddd", ti4.descendant_names)
|
||||
assert_equal(%w[bbb ccc ddd], ti1.descendant_names)
|
||||
assert_equal(%w[bbb ccc ddd], ti2.descendant_names)
|
||||
assert_equal(%w[ccc ddd], ti3.descendant_names)
|
||||
assert_equal(%w[ddd], ti4.descendant_names)
|
||||
ti3.destroy
|
||||
ti1.reload
|
||||
ti2.reload
|
||||
ti4.reload
|
||||
assert_equal("bbb", ti1.descendant_names)
|
||||
assert_equal("bbb", ti2.descendant_names)
|
||||
assert_equal("ddd", ti4.descendant_names)
|
||||
assert_equal(%w[bbb], ti1.descendant_names)
|
||||
assert_equal(%w[bbb], ti2.descendant_names)
|
||||
assert_equal(%w[ddd], ti4.descendant_names)
|
||||
end
|
||||
|
||||
should "update the descendants for all of its parents on create" do
|
||||
ti1 = FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb")
|
||||
ti1.reload
|
||||
assert_equal("active", ti1.status)
|
||||
assert_equal("bbb", ti1.descendant_names)
|
||||
assert_equal(%w[bbb], ti1.descendant_names)
|
||||
|
||||
ti2 = FactoryBot.create(:tag_implication, :antecedent_name => "bbb", :consequent_name => "ccc")
|
||||
ti1.reload
|
||||
ti2.reload
|
||||
assert_equal("active", ti1.status)
|
||||
assert_equal("active", ti2.status)
|
||||
assert_equal("bbb ccc", ti1.descendant_names)
|
||||
assert_equal("ccc", ti2.descendant_names)
|
||||
assert_equal(%w[bbb ccc], ti1.descendant_names)
|
||||
assert_equal(%w[ccc], ti2.descendant_names)
|
||||
|
||||
ti3 = FactoryBot.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd")
|
||||
ti1.reload
|
||||
ti2.reload
|
||||
ti3.reload
|
||||
assert_equal("bbb ccc ddd", ti1.descendant_names)
|
||||
assert_equal("ccc ddd", ti2.descendant_names)
|
||||
assert_equal(%w[bbb ccc ddd], ti1.descendant_names)
|
||||
assert_equal(%w[ccc ddd], ti2.descendant_names)
|
||||
|
||||
ti4 = FactoryBot.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "eee")
|
||||
ti1.reload
|
||||
ti2.reload
|
||||
ti3.reload
|
||||
ti4.reload
|
||||
assert_equal("bbb ccc ddd eee", ti1.descendant_names)
|
||||
assert_equal("ccc ddd eee", ti2.descendant_names)
|
||||
assert_equal("ddd", ti3.descendant_names)
|
||||
assert_equal("eee", ti4.descendant_names)
|
||||
assert_equal(%w[bbb ccc ddd eee], ti1.descendant_names)
|
||||
assert_equal(%w[ccc ddd eee], ti2.descendant_names)
|
||||
assert_equal(%w[ddd], ti3.descendant_names)
|
||||
assert_equal(%w[eee], ti4.descendant_names)
|
||||
|
||||
ti5 = FactoryBot.create(:tag_implication, :antecedent_name => "xxx", :consequent_name => "bbb")
|
||||
ti1.reload
|
||||
@@ -172,11 +169,11 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
ti3.reload
|
||||
ti4.reload
|
||||
ti5.reload
|
||||
assert_equal("bbb ccc ddd eee", ti1.descendant_names)
|
||||
assert_equal("ccc ddd eee", ti2.descendant_names)
|
||||
assert_equal("ddd", ti3.descendant_names)
|
||||
assert_equal("eee", ti4.descendant_names)
|
||||
assert_equal("bbb ccc ddd eee", ti5.descendant_names)
|
||||
assert_equal(%w[bbb ccc ddd eee], ti1.descendant_names)
|
||||
assert_equal(%w[ccc ddd eee], ti2.descendant_names)
|
||||
assert_equal(%w[ddd], ti3.descendant_names)
|
||||
assert_equal(%w[eee], ti4.descendant_names)
|
||||
assert_equal(%w[bbb ccc ddd eee], ti5.descendant_names)
|
||||
end
|
||||
|
||||
should "update any affected post upon save" do
|
||||
|
||||
@@ -63,7 +63,7 @@ class WikiPageTest < ActiveSupport::TestCase
|
||||
|
||||
should "normalize its other names" do
|
||||
@wiki_page.update(:other_names => "foo*bar baz baz 加賀(艦これ)")
|
||||
assert(%w[foo*bar baz 加賀(艦これ)], @wiki_page.other_names_array)
|
||||
assert_equal(%w[foo*bar baz 加賀(艦これ)], @wiki_page.other_names)
|
||||
end
|
||||
|
||||
should "search by title" do
|
||||
|
||||
Reference in New Issue
Block a user