artists/edit: refactor editing nested wiki pages.

Refactor to use accepts_nested_attributes_for instead of the notes
attribute to facilitate editing wikis on the artist edit page.

This fixes the notes attribute unintentionally showing up in the API.

This also changes it so that renaming an artist entry doesn't
automatically rename the corresponding wiki page. This had bad behavior
when there was a conflict between wiki pages (the wikis would be
silently merged, which usually isn't what you want). It also didn't warn
about wiki links being broken by renames.
This commit is contained in:
evazion
2020-02-16 18:27:57 -06:00
parent 6f3d0b542c
commit ef3188a7fe
6 changed files with 22 additions and 119 deletions

View File

@@ -104,24 +104,6 @@ class ArtistTest < ActiveSupport::TestCase
end
end
should "create a new wiki page to store any note information" do
artist = nil
assert_difference("WikiPage.count") do
artist = FactoryBot.create(:artist, :name => "aaa", :notes => "testing")
end
assert_equal("testing", artist.notes)
assert_equal("testing", artist.wiki_page.body)
assert_equal(artist.name, artist.wiki_page.title)
end
should "update the wiki page when notes are assigned" do
artist = FactoryBot.create(:artist, :name => "aaa", :notes => "testing")
artist.update_attribute(:notes, "kokoko")
artist.reload
assert_equal("kokoko", artist.notes)
assert_equal("kokoko", artist.wiki_page.body)
end
should "normalize its name" do
artist = FactoryBot.create(:artist, :name => " AAA BBB ")
assert_equal("aaa_bbb", artist.name)