DEV: Don't user before(:all)/after(:all) (#13389)

Leaking state and non-obvious order (before :all runs *before* RailsHelper.test_setup) are not worth it.
A replacement PR for #13370. Fixes some flaky specs, e.g.
```
bin/rspec './spec/components/freedom_patches/translate_accelerator_spec.rb[1:3]' './spec/jobs/clean_up_user_export_topics_spec.rb[1:1]' --tag ~type:multisite --seed 35994
```

Also included:
* DEV: No need for locale reset (we do it anyway in rails_helper in `test_setup`)
This commit is contained in:
Jarek Radosz
2021-06-15 17:25:06 +02:00
committed by GitHub
parent bfeaf75cd5
commit e36377d9ab
9 changed files with 17 additions and 35 deletions

View File

@@ -1,12 +1,12 @@
# frozen_string_literal: true
require "s3_helper"
require 'rails_helper'
require "rails_helper"
describe Jobs::VacateLegacyPrefixBackups, type: :multisite do
let(:bucket_name) { "backupbucket" }
before(:all) do
before do
@s3_client = Aws::S3::Client.new(stub_responses: true)
@s3_options = { client: @s3_client }
@objects = []
@@ -15,9 +15,7 @@ describe Jobs::VacateLegacyPrefixBackups, type: :multisite do
@s3_client.stub_responses(:list_objects_v2, -> (context) do
{ contents: objects_with_prefix(context) }
end)
end
before do
setup_s3
SiteSetting.s3_backup_bucket = bucket_name
SiteSetting.backup_location = BackupLocationSiteSetting::S3