mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Try fix upload_spec flakys and remove logging from tasks/uploads_spec
This commit is contained in:
parent
64b3512084
commit
500185dc11
@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
class RakeHelpers
|
class RakeHelpers
|
||||||
def self.print_status_with_label(label, current, max)
|
def self.print_status_with_label(label, current, max)
|
||||||
|
return if Rails.env.test? && !ENV['RAILS_ENABLE_TEST_LOG']
|
||||||
print "\r\033[K%s%9d / %d (%5.1f%%)" % [label, current, max, ((current.to_f / max.to_f) * 100).round(1)]
|
print "\r\033[K%s%9d / %d (%5.1f%%)" % [label, current, max, ((current.to_f / max.to_f) * 100).round(1)]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.print_status(current, max)
|
def self.print_status(current, max)
|
||||||
|
return if Rails.env.test? && !ENV['RAILS_ENABLE_TEST_LOG']
|
||||||
print "\r\033[K%9d / %d (%5.1f%%)" % [current, max, ((current.to_f / max.to_f) * 100).round(1)]
|
print "\r\033[K%9d / %d (%5.1f%%)" % [current, max, ((current.to_f / max.to_f) * 100).round(1)]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -426,26 +426,22 @@ describe Upload do
|
|||||||
SiteSetting.login_required = true
|
SiteSetting.login_required = true
|
||||||
upload.update!(secure: false)
|
upload.update!(secure: false)
|
||||||
CustomEmoji.create(name: 'meme', upload: upload)
|
CustomEmoji.create(name: 'meme', upload: upload)
|
||||||
expect { upload.update_secure_status }
|
upload.update_secure_status
|
||||||
.not_to change { upload.secure }
|
|
||||||
|
|
||||||
expect(upload.reload.secure).to eq(false)
|
expect(upload.reload.secure).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not mark an upload whose origin matches a regular emoji as secure (sometimes emojis are downloaded in pull_hotlinked_images)' do
|
it 'does not mark an upload whose origin matches a regular emoji as secure (sometimes emojis are downloaded in pull_hotlinked_images)' do
|
||||||
SiteSetting.login_required = true
|
SiteSetting.login_required = true
|
||||||
grinning = Emoji.all.last
|
falafel = Emoji.all.find { |e| e.url == '/images/emoji/twitter/falafel.png?v=9' }
|
||||||
upload.update!(secure: false, origin: "http://localhost:3000#{grinning.url}")
|
upload.update!(secure: false, origin: "http://localhost:3000#{falafel.url}")
|
||||||
expect { upload.update_secure_status }
|
upload.update_secure_status
|
||||||
.not_to change { upload.secure }
|
|
||||||
expect(upload.reload.secure).to eq(false)
|
expect(upload.reload.secure).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not mark any upload with origin containing images/emoji in the URL' do
|
it 'does not mark any upload with origin containing images/emoji in the URL' do
|
||||||
SiteSetting.login_required = true
|
SiteSetting.login_required = true
|
||||||
upload.update!(secure: false, origin: "http://localhost:3000/images/emoji/test.png")
|
upload.update!(secure: false, origin: "http://localhost:3000/images/emoji/test.png")
|
||||||
expect { upload.update_secure_status }
|
upload.update_secure_status
|
||||||
.not_to change { upload.secure }
|
|
||||||
expect(upload.reload.secure).to eq(false)
|
expect(upload.reload.secure).to eq(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -138,6 +138,10 @@ module Helpers
|
|||||||
$stdout = old_stdout
|
$stdout = old_stdout
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def disable_puts_stdout
|
||||||
|
IO.any_instance.stubs(:puts)
|
||||||
|
end
|
||||||
|
|
||||||
def set_subfolder(f)
|
def set_subfolder(f)
|
||||||
global_setting :relative_url_root, f
|
global_setting :relative_url_root, f
|
||||||
old_root = ActionController::Base.config.relative_url_root
|
old_root = ActionController::Base.config.relative_url_root
|
||||||
|
@ -6,6 +6,7 @@ RSpec.describe "tasks/uploads" do
|
|||||||
before do
|
before do
|
||||||
Rake::Task.clear
|
Rake::Task.clear
|
||||||
Discourse::Application.load_tasks
|
Discourse::Application.load_tasks
|
||||||
|
disable_puts_stdout
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "uploads:ensure_correct_acl" do
|
describe "uploads:ensure_correct_acl" do
|
||||||
|
Loading…
Reference in New Issue
Block a user