Merge pull request #2986 from evazion/fix-ss-migrations

Fix broken tag subscription migrations.
This commit is contained in:
Albert Yi
2017-04-22 01:03:30 -07:00
committed by GitHub
4 changed files with 25 additions and 7 deletions

View File

@@ -95,6 +95,14 @@ class SavedSearchTest < ActiveSupport::TestCase
should "normalize whitespace" do
assert_equal("xxx", @saved_search.query)
end
should "normalize the label string" do
@saved_search.label_string = "Foo Bar"
assert_equal(%w[foo bar], @saved_search.labels)
@saved_search.labels = ["Artist 1", "Artist 2"]
assert_equal(%w[artist_1 artist_2], @saved_search.labels)
end
end
context "Destroying a saved search" do

View File

@@ -72,6 +72,16 @@ class TagSubscriptionTest < ActiveSupport::TestCase
assert_equal([posts[1].id], TagSubscription.find_posts(user.id, "yyy").map(&:id))
end
end
should "migrate to saved searches" do
sub = FactoryGirl.create(:tag_subscription, tag_query: "foo bar\r\nbar\nbaz", :name => "Artist 1")
sub.migrate_to_saved_searches
assert_equal(1, CurrentUser.user.subscriptions.size)
assert_equal(3, CurrentUser.user.saved_searches.size)
assert_equal(["bar foo", "bar", "baz"], CurrentUser.user.saved_searches.pluck(:query))
assert_equal([%w[artist_1]]*3, CurrentUser.user.saved_searches.pluck(:labels))
end
end
context "A tag subscription manager" do