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