Refactor source normalization
* Move the source normalization logic out of the post model and into individual sources' strategies. * Rewrite normalization tests to be handled into each source's test, and expand them significantly. Previously we were only testing a very small subset of domains and variants. * Fix up normalization for several sites. * Normalize fav.me urls into normal deviantart urls.
This commit is contained in:
@@ -94,5 +94,23 @@ module Sources
|
||||
assert_equal("evazion", @site.artist_name)
|
||||
end
|
||||
end
|
||||
|
||||
context "normalizing for source" do
|
||||
should "normalize correctly" do
|
||||
source1 = "https://pawoo.net/@evazion/19451018/"
|
||||
source2 = "https://pawoo.net/web/statuses/19451018/favorites"
|
||||
|
||||
assert_equal("https://pawoo.net/@evazion/19451018", Sources::Strategies.normalize_source(source1))
|
||||
assert_equal("https://pawoo.net/web/statuses/19451018", Sources::Strategies.normalize_source(source2))
|
||||
end
|
||||
|
||||
should "avoid normalizing unnormalizable urls" do
|
||||
bad_source1 = "https://img.pawoo.net/media_attachments/files/001/297/997/original/c4272a09570757c2.png"
|
||||
bad_source2 = "https://pawoo.net/@evazion/media"
|
||||
|
||||
assert_equal(bad_source1, Sources::Strategies.normalize_source(bad_source1))
|
||||
assert_equal(bad_source2, Sources::Strategies.normalize_source(bad_source2))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user