tests: fix various broken tests.
This commit is contained in:
@@ -178,7 +178,7 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "gracefully handle validation errors during approval" do
|
||||
@req.stubs(:update).raises(AliasAndImplicationImporter::Error.new("blah"))
|
||||
@req.stubs(:update!).raises(AliasAndImplicationImporter::Error.new("blah"))
|
||||
assert_difference("ForumPost.count", 1) do
|
||||
@req.approve!(@admin)
|
||||
end
|
||||
|
||||
@@ -3,31 +3,21 @@ require 'webmock/minitest'
|
||||
|
||||
class CloudflareServiceTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
Danbooru.config.stubs(:cloudflare_key).returns("xyz")
|
||||
Danbooru.config.stubs(:cloudflare_email).returns("abc")
|
||||
Danbooru.config.stubs(:cloudflare_zone).returns("123")
|
||||
@cloudflare = CloudflareService.new(zone: "123", api_token: "foo")
|
||||
end
|
||||
|
||||
subject { CloudflareService.new }
|
||||
|
||||
context "#delete" do
|
||||
setup do
|
||||
stub_request(:any, "api.cloudflare.com")
|
||||
end
|
||||
|
||||
context "#purge_cache" do
|
||||
should "make calls to cloudflare's api" do
|
||||
subject.delete("md5", "png")
|
||||
assert_requested(:delete, "https://api.cloudflare.com/client/v4/zones/123/purge_cache", times: 1) do |req|
|
||||
req.body =~ /danbooru\.donmai\.us/ && req.body =~ /safebooru\.donmai\.us/ && req.body =~ /sample/ && req.body =~ /preview/
|
||||
end
|
||||
stub_request(:any, "api.cloudflare.com")
|
||||
@cloudflare.purge_cache(["http://localhost/file.txt"])
|
||||
|
||||
assert_requested(:delete, "https://api.cloudflare.com/client/v4/zones/123/purge_cache", times: 1)
|
||||
end
|
||||
end
|
||||
|
||||
context "#ips" do
|
||||
should "work" do
|
||||
refute_empty(subject.ips)
|
||||
refute_empty(@cloudflare.ips)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,12 +19,8 @@ module PostSets
|
||||
end
|
||||
|
||||
context "a set for page 2" do
|
||||
setup do
|
||||
@set = PostSets::Post.new("", 2)
|
||||
::Post.stubs(:records_per_page).returns(1)
|
||||
end
|
||||
|
||||
should "return the second element" do
|
||||
@set = PostSets::Post.new("", 2, 1)
|
||||
assert_equal(@post_2.id, @set.posts.first.id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
@upload = UploadService.new(FactoryBot.attributes_for(:jpg_upload)).start!
|
||||
@post = @upload.post
|
||||
Favorite.add(post: @post, user: @user)
|
||||
create(:favorite_group).add!(@post.id)
|
||||
create(:favorite_group, post_ids: [@post.id])
|
||||
end
|
||||
|
||||
should "delete the files" do
|
||||
@@ -2737,9 +2737,9 @@ class PostTest < ActiveSupport::TestCase
|
||||
should "generate the correct urls for animated gifs" do
|
||||
@post = FactoryBot.build(:post, md5: "deadbeef", file_ext: "gif", tag_string: "animated_gif")
|
||||
|
||||
assert_equal("https://#{Socket.gethostname}/data/preview/deadbeef.jpg", @post.preview_file_url)
|
||||
assert_equal("https://#{Socket.gethostname}/data/deadbeef.gif", @post.large_file_url)
|
||||
assert_equal("https://#{Socket.gethostname}/data/deadbeef.gif", @post.file_url)
|
||||
assert_equal("https://localhost/data/preview/deadbeef.jpg", @post.preview_file_url)
|
||||
assert_equal("https://localhost/data/deadbeef.gif", @post.large_file_url)
|
||||
assert_equal("https://localhost/data/deadbeef.gif", @post.file_url)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -222,10 +222,9 @@ module Sources
|
||||
|
||||
context "An mp4 post" do
|
||||
should "find the mp4 file" do
|
||||
site = Sources::Strategies.find("https://nijie.info/view.php?id=319485")
|
||||
site = Sources::Strategies.find("http://nijie.info/view.php?id=324604")
|
||||
|
||||
assert_equal(["https://pic.nijie.net/03/nijie_picture/829001_20190620004513_0.mp4"], site.image_urls)
|
||||
assert_equal("https://pic.nijie.net/03/nijie_picture/829001_20190620004513_0.mp4", site.image_url)
|
||||
assert_equal("https://pic.nijie.net/01/nijie_picture/1349569_20190727172205_0.mp4", site.image_urls[0])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user