A platform for community discussion. Free, open, simple.
Try fix upload_spec flakys and remove logging from tasks/uploads_spec
Martin Brennan500185dc113e
diff --git a/lib/rake_helpers.rb b/lib/rake_helpers.rbindex 033fdeeb094..adc5adcd32d 100644--- a/lib/rake_helpers.rb+++ b/lib/rake_helpers.rb@@ -2,10 +2,12 @@class RakeHelpersdef 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)]enddef 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)]endenddiff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rbindex b2a19721526..e7d55237ce7 100644--- a/spec/models/upload_spec.rb+++ b/spec/models/upload_spec.rb@@ -426,26 +426,22 @@ describe Upload doSiteSetting.login_required = trueupload.update!(secure: false)CustomEmoji.create(name: 'meme', upload: upload)- expect { upload.update_secure_status }- .not_to change { upload.secure }-+ upload.update_secure_statusexpect(upload.reload.secure).to eq(false)endit 'does not mark an upload whose origin matches a regular emoji as secure (sometimes emojis are downloaded in pull_hotlinked_images)' doSiteSetting.login_required = true- grinning = Emoji.all.last- upload.update!(secure: false, origin: "http://localhost:3000#{grinning.url}")- expect { upload.update_secure_status }- .not_to change { upload.secure }+ falafel = Emoji.all.find { |e| e.url == '/images/emoji/twitter/falafel.png?v=9' }+ upload.update!(secure: false, origin: "http://localhost:3000#{falafel.url}")+ upload.update_secure_statusexpect(upload.reload.secure).to eq(false)endit 'does not mark any upload with origin containing images/emoji in the URL' doSiteSetting.login_required = trueupload.update!(secure: false, origin: "http://localhost:3000/images/emoji/test.png")- expect { upload.update_secure_status }- .not_to change { upload.secure }+ upload.update_secure_statusexpect(upload.reload.secure).to eq(false)endenddiff --git a/spec/support/helpers.rb b/spec/support/helpers.rbindex e2e278bb91e..23f6e830faf 100644--- a/spec/support/helpers.rb+++ b/spec/support/helpers.rb@@ -138,6 +138,10 @@ module Helpers$stdout = old_stdoutend+ def disable_puts_stdout+ IO.any_instance.stubs(:puts)+ end+def set_subfolder(f)global_setting :relative_url_root, fold_root = ActionController::Base.config.relative_url_rootdiff --git a/spec/tasks/uploads_spec.rb b/spec/tasks/uploads_spec.rbindex c239213f0b1..65de71e1b33 100644--- a/spec/tasks/uploads_spec.rb+++ b/spec/tasks/uploads_spec.rb@@ -6,6 +6,7 @@ RSpec.describe "tasks/uploads" dobefore doRake::Task.clearDiscourse::Application.load_tasks+ disable_puts_stdoutenddescribe "uploads:ensure_correct_acl" do