Add RSpec 4 compatibility (#17652)

* Remove outdated option

04078317ba

* Use the non-globally exposed RSpec syntax

https://github.com/rspec/rspec-core/pull/2803

* Use the non-globally exposed RSpec syntax, cont

https://github.com/rspec/rspec-core/pull/2803

* Comply to strict predicate matchers

See:
 - https://github.com/rspec/rspec-expectations/pull/1195
 - https://github.com/rspec/rspec-expectations/pull/1196
 - https://github.com/rspec/rspec-expectations/pull/1277
This commit is contained in:
Phil Pirozhkov 2022-07-28 05:27:38 +03:00 committed by GitHub
parent 72b24f3fb9
commit 493d437e79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
736 changed files with 781 additions and 782 deletions

1
.rspec
View File

@ -1,2 +1 @@
--colour
--require 'rails_helper' --require 'rails_helper'

View File

@ -3,7 +3,7 @@
require 'rails_helper' require 'rails_helper'
require 'pretty_text' require 'pretty_text'
describe PrettyText do RSpec.describe PrettyText do
let(:post) { Fabricate(:post) } let(:post) { Fabricate(:post) }

View File

@ -14,7 +14,7 @@ def generate_html(text, opts = {})
output + "</span></p>" output + "</span></p>"
end end
describe PrettyText do RSpec.describe PrettyText do
before do before do
freeze_time freeze_time
end end

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Post do RSpec.describe Post do
before do before do
Jobs.run_immediately! Jobs.run_immediately!

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe DiscourseNarrativeBot::NewUserNarrative do RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
fab!(:welcome_topic) { Fabricate(:topic, title: 'Welcome to Discourse') } fab!(:welcome_topic) { Fabricate(:topic, title: 'Welcome to Discourse') }
fab!(:narrative_bot) { ::DiscourseNarrativeBot::Base.new } fab!(:narrative_bot) { ::DiscourseNarrativeBot::Base.new }
fab!(:discobot_user) { narrative_bot.discobot_user } fab!(:discobot_user) { narrative_bot.discobot_user }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe DiscourseNarrativeBot::Store do RSpec.describe DiscourseNarrativeBot::Store do
describe '.set' do describe '.set' do
it 'should set the right value in the plugin store' do it 'should set the right value in the plugin store' do
key = 'somekey' key = 'somekey'

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe DiscourseNarrativeBot::TrackSelector do RSpec.describe DiscourseNarrativeBot::TrackSelector do
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }
let(:narrative_bot) { ::DiscourseNarrativeBot::Base.new } let(:narrative_bot) { ::DiscourseNarrativeBot::Base.new }
let(:discobot_user) { narrative_bot.discobot_user } let(:discobot_user) { narrative_bot.discobot_user }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::DiscourseNarrativeBot::RemapOldBotImages do RSpec.describe Jobs::DiscourseNarrativeBot::RemapOldBotImages do
context "when bot's post contains an old link" do context "when bot's post contains an old link" do
let!(:post) do let!(:post) do
Fabricate(:post, Fabricate(:post,

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe "Discobot Certificate" do RSpec.describe "Discobot Certificate" do
let(:user) { Fabricate(:user, name: 'Jeff Atwood') } let(:user) { Fabricate(:user, name: 'Jeff Atwood') }
let(:params) { let(:params) {

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe "Discobot welcome post" do RSpec.describe "Discobot welcome post" do
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }
before do before do

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe User do RSpec.describe User do
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }
let(:profile_page_url) { "#{Discourse.base_url}/users/#{user.username}" } let(:profile_page_url) { "#{Discourse.base_url}/users/#{user.username}" }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe "discourse-presence" do RSpec.describe "discourse-presence" do
describe 'PresenceChannel configuration' do describe 'PresenceChannel configuration' do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
fab!(:user2) { Fabricate(:user) } fab!(:user2) { Fabricate(:user) }

View File

@ -2,7 +2,7 @@
require "rails_helper" require "rails_helper"
describe ::DiscoursePoll::PollsController do RSpec.describe ::DiscoursePoll::PollsController do
routes { ::DiscoursePoll::Engine.routes } routes { ::DiscoursePoll::Engine.routes }
let!(:user) { log_in } let!(:user) { log_in }

View File

@ -2,7 +2,7 @@
require "rails_helper" require "rails_helper"
describe PostsController do RSpec.describe PostsController do
let!(:user) { log_in } let!(:user) { log_in }
let!(:title) { "Testing Poll Plugin" } let!(:title) { "Testing Poll Plugin" }

View File

@ -2,7 +2,7 @@
require "rails_helper" require "rails_helper"
describe "DiscoursePoll endpoints" do RSpec.describe "DiscoursePoll endpoints" do
describe "fetch voters for a poll" do describe "fetch voters for a poll" do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
fab!(:post) { Fabricate(:post, raw: "[poll public=true]\n- A\n- B\n[/poll]") } fab!(:post) { Fabricate(:post, raw: "[poll public=true]\n- A\n- B\n[/poll]") }

View File

@ -2,7 +2,7 @@
require "rails_helper" require "rails_helper"
describe Jobs::ClosePoll do RSpec.describe Jobs::ClosePoll do
let(:post) { Fabricate(:post, raw: "[poll]\n- A\n- B\n[/poll]") } let(:post) { Fabricate(:post, raw: "[poll]\n- A\n- B\n[/poll]") }
describe 'missing arguments' do describe 'missing arguments' do

View File

@ -2,7 +2,7 @@
require "rails_helper" require "rails_helper"
describe NewPostManager do RSpec.describe NewPostManager do
let(:user) { Fabricate(:newuser) } let(:user) { Fabricate(:newuser) }
let(:admin) { Fabricate(:admin) } let(:admin) { Fabricate(:admin) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe DiscoursePoll::Poll do RSpec.describe DiscoursePoll::Poll do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
fab!(:user_2) { Fabricate(:user) } fab!(:user_2) { Fabricate(:user) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe DiscoursePoll::PollsUpdater do RSpec.describe DiscoursePoll::PollsUpdater do
def update(post, polls) def update(post, polls)
DiscoursePoll::PollsUpdater.update(post, polls) DiscoursePoll::PollsUpdater.update(post, polls)

View File

@ -2,7 +2,7 @@
require "rails_helper" require "rails_helper"
describe ::DiscoursePoll::PollsValidator do RSpec.describe ::DiscoursePoll::PollsValidator do
let(:post) { Fabricate(:post) } let(:post) { Fabricate(:post) }
subject { described_class.new(post) } subject { described_class.new(post) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe PrettyText do RSpec.describe PrettyText do
def n(html) def n(html)
html.strip html.strip

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe ::DiscoursePoll::Poll do RSpec.describe ::DiscoursePoll::Poll do
describe ".transform_for_user_field_override" do describe ".transform_for_user_field_override" do
it "Transforms UserField name if a matching CustomUserField is present" do it "Transforms UserField name if a matching CustomUserField is present" do
user_field_name = "Something Cool" user_field_name = "Something Cool"

View File

@ -2,7 +2,7 @@
require "rails_helper" require "rails_helper"
describe Admin::UsersController do RSpec.describe Admin::UsersController do
let(:admin) { Fabricate(:admin) } let(:admin) { Fabricate(:admin) }

View File

@ -8,7 +8,7 @@ def serialize_option(option, user)
) )
end end
describe PollOptionSerializer do RSpec.describe PollOptionSerializer do
let(:voter) { Fabricate(:user) } let(:voter) { Fabricate(:user) }
let(:poll) { post.polls.first } let(:poll) { post.polls.first }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe 'SiteSetting.styleguide_admin_only' do RSpec.describe 'SiteSetting.styleguide_admin_only' do
before do before do
SiteSetting.styleguide_enabled = true SiteSetting.styleguide_enabled = true
end end
@ -34,7 +34,7 @@ describe 'SiteSetting.styleguide_admin_only' do
end end
end end
describe 'SiteSetting.styleguide_enabled' do RSpec.describe 'SiteSetting.styleguide_enabled' do
before do before do
sign_in(Fabricate(:admin)) sign_in(Fabricate(:admin))
end end

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe 'Styleguide assets' do RSpec.describe 'Styleguide assets' do
before do before do
SiteSetting.styleguide_enabled = true SiteSetting.styleguide_enabled = true
sign_in(Fabricate(:admin)) sign_in(Fabricate(:admin))

View File

@ -1,7 +1,7 @@
# coding: utf-8 # coding: utf-8
# frozen_string_literal: true # frozen_string_literal: true
describe ApplicationHelper do RSpec.describe ApplicationHelper do
describe "preload_script" do describe "preload_script" do
def preload_link(url) def preload_link(url)

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe TopicsHelper do RSpec.describe TopicsHelper do
describe "#categories_breadcrumb" do describe "#categories_breadcrumb" do
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe UserNotificationsHelper do RSpec.describe UserNotificationsHelper do
let(:upload_path) { Discourse.store.upload_path } let(:upload_path) { Discourse.store.upload_path }
describe '#email_excerpt' do describe '#email_excerpt' do

View File

@ -2,7 +2,7 @@
require "import_export" require "import_export"
describe ImportExport::CategoryExporter do RSpec.describe ImportExport::CategoryExporter do
fab!(:category) { Fabricate(:category) } fab!(:category) { Fabricate(:category) }
fab!(:group) { Fabricate(:group) } fab!(:group) { Fabricate(:group) }

View File

@ -2,7 +2,7 @@
require "import_export/category_structure_exporter" require "import_export/category_structure_exporter"
describe ImportExport::CategoryStructureExporter do RSpec.describe ImportExport::CategoryStructureExporter do
before do before do
STDOUT.stubs(:write) STDOUT.stubs(:write)

View File

@ -2,7 +2,7 @@
require "import_export/group_exporter" require "import_export/group_exporter"
describe ImportExport::GroupExporter do RSpec.describe ImportExport::GroupExporter do
before do before do
STDOUT.stubs(:write) STDOUT.stubs(:write)

View File

@ -2,7 +2,7 @@
require "import_export" require "import_export"
describe ImportExport::Importer do RSpec.describe ImportExport::Importer do
before do before do
STDOUT.stubs(:write) STDOUT.stubs(:write)

View File

@ -2,7 +2,7 @@
require "import_export" require "import_export"
describe ImportExport::TopicExporter do RSpec.describe ImportExport::TopicExporter do
before do before do
STDOUT.stubs(:write) STDOUT.stubs(:write)

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe 'Setting changes' do RSpec.describe 'Setting changes' do
describe '#must_approve_users' do describe '#must_approve_users' do
before { SiteSetting.must_approve_users = false } before { SiteSetting.must_approve_users = false }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe 'api keys' do RSpec.describe 'api keys' do
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }
let(:api_key) { ApiKey.create!(user_id: user.id, created_by_id: Discourse.system_user) } let(:api_key) { ApiKey.create!(user_id: user.id, created_by_id: Discourse.system_user) }
@ -61,7 +61,7 @@ describe 'api keys' do
end end
end end
describe 'user api keys' do RSpec.describe 'user api keys' do
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }
let(:user_api_key) { Fabricate(:readonly_user_api_key, user: user) } let(:user_api_key) { Fabricate(:readonly_user_api_key, user: user) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe "auto reject reviewable users" do RSpec.describe "auto reject reviewable users" do
context "reviewable users" do context "reviewable users" do
fab!(:old_user) { Fabricate(:reviewable, created_at: 80.days.ago) } fab!(:old_user) { Fabricate(:reviewable, created_at: 80.days.ago) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe "hotlinked media blocking" do RSpec.describe "hotlinked media blocking" do
let(:hotlinked_url) { "http://example.com/images/2/2e/Longcat1.png" } let(:hotlinked_url) { "http://example.com/images/2/2e/Longcat1.png" }
let(:onebox_url) { "http://example.com/onebox" } let(:onebox_url) { "http://example.com/onebox" }
let(:png) { Base64.decode64("R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==") } let(:png) { Base64.decode64("R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==") }

View File

@ -1,7 +1,7 @@
# encoding: UTF-8 # encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
describe "category tag restrictions" do RSpec.describe "category tag restrictions" do
def filter_allowed_tags(opts = {}) def filter_allowed_tags(opts = {})
DiscourseTagging.filter_allowed_tags(Guardian.new(user), opts) DiscourseTagging.filter_allowed_tags(Guardian.new(user), opts)
@ -427,7 +427,7 @@ describe "category tag restrictions" do
end end
end end
describe "tag topic counts per category" do RSpec.describe "tag topic counts per category" do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
fab!(:category) { Fabricate(:category) } fab!(:category) { Fabricate(:category) }
fab!(:category2) { Fabricate(:category) } fab!(:category2) { Fabricate(:category) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe 'content security policy integration' do RSpec.describe 'content security policy integration' do
it "adds the csp headers correctly" do it "adds the csp headers correctly" do
SiteSetting.content_security_policy = false SiteSetting.content_security_policy = false

View File

@ -4,7 +4,7 @@
# with mailer specific mailer specs like UserEmail, but sometimes we need # with mailer specific mailer specs like UserEmail, but sometimes we need
# to test things along the whole outbound flow including the MessageBuilder # to test things along the whole outbound flow including the MessageBuilder
# and the Sender. # and the Sender.
describe "Outbound Email" do RSpec.describe "Outbound Email" do
def send_email(opts = {}) def send_email(opts = {})
message = TestMailer.send_test("test@test.com", opts) message = TestMailer.send_test("test@test.com", opts)
result = Email::Sender.new(message, :test_message).send result = Email::Sender.new(message, :test_message).send

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe EmailStyle do RSpec.describe EmailStyle do
context "ERB evaluation" do context "ERB evaluation" do
it "does not evaluate ERB outside of the email itself" do it "does not evaluate ERB outside of the email itself" do

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe PostAction do RSpec.describe PostAction do
it "triggers the 'flag_reviewed' event when there was at least one flag" do it "triggers the 'flag_reviewed' event when there was at least one flag" do
admin = Fabricate(:admin) admin = Fabricate(:admin)

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Group do RSpec.describe Group do
let(:group) do let(:group) do
Fabricate( Fabricate(
:group, :group,

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe 'invalid requests', type: :request do RSpec.describe 'invalid requests', type: :request do
before do before do
@orig_logger = Rails.logger @orig_logger = Rails.logger
Rails.logger = @fake_logger = FakeLogger.new Rails.logger = @fake_logger = FakeLogger.new

View File

@ -1,7 +1,7 @@
# encoding: UTF-8 # encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
describe 'invite only' do RSpec.describe 'invite only' do
describe '#create invite only' do describe '#create invite only' do
it 'can create user via API' do it 'can create user via API' do

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe 'message bus integration' do RSpec.describe 'message bus integration' do
it "allows anonymous requests to the messagebus" do it "allows anonymous requests to the messagebus" do
post "/message-bus/poll" post "/message-bus/poll"

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe 'multisite', type: [:multisite, :request] do RSpec.describe 'multisite', type: [:multisite, :request] do
it "works" do it "works" do
get "http://test.localhost/session/csrf.json" get "http://test.localhost/session/csrf.json"
expect(response.status).to eq(200) expect(response.status).to eq(200)

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe 'multisite', type: [:multisite, :request] do RSpec.describe 'multisite', type: [:multisite, :request] do
it "should always allow /srv/status through" do it "should always allow /srv/status through" do
get "http://unknown.com/srv/status" get "http://unknown.com/srv/status"
expect(response.status).to eq(200) expect(response.status).to eq(200)

View File

@ -1,7 +1,7 @@
# encoding: UTF-8 # encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
describe 'rate limiter integration' do RSpec.describe 'rate limiter integration' do
before do before do
RateLimiter.enable RateLimiter.enable

View File

@ -1,7 +1,7 @@
# encoding: UTF-8 # encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
describe "spammers on same IP" do RSpec.describe "spammers on same IP" do
let(:ip_address) { '182.189.119.174' } let(:ip_address) { '182.189.119.174' }
let!(:spammer1) { Fabricate(:user, ip_address: ip_address) } let!(:spammer1) { Fabricate(:user, ip_address: ip_address) }

View File

@ -1,7 +1,7 @@
# encoding: UTF-8 # encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
describe "spam rules for users" do RSpec.describe "spam rules for users" do
describe 'auto-silence users based on flagging' do describe 'auto-silence users based on flagging' do
fab!(:admin) { Fabricate(:admin) } # needed to send a system message fab!(:admin) { Fabricate(:admin) } # needed to send a system message

View File

@ -1,7 +1,7 @@
# encoding: UTF-8 # encoding: UTF-8
# frozen_string_literal: true # frozen_string_literal: true
describe Topic do RSpec.describe Topic do
let(:job_klass) { Jobs::CloseTopic } let(:job_klass) { Jobs::CloseTopic }
context 'creating a topic without auto-close' do context 'creating a topic without auto-close' do

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
describe "Topic Thumbnails" do RSpec.describe "Topic Thumbnails" do
before do before do
SiteSetting.create_thumbnails = true SiteSetting.create_thumbnails = true
ImageSizer.stubs(:resize).returns([9, 9]) ImageSizer.stubs(:resize).returns([9, 9])

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe WatchedWord do RSpec.describe WatchedWord do
fab!(:tl2_user) { Fabricate(:user, trust_level: TrustLevel[2]) } fab!(:tl2_user) { Fabricate(:user, trust_level: TrustLevel[2]) }
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
fab!(:moderator) { Fabricate(:moderator) } fab!(:moderator) { Fabricate(:moderator) }

View File

@ -17,7 +17,7 @@ def grep_file(file, regex)
lines.count > 0 ? file : nil lines.count > 0 ? file : nil
end end
describe 'Coding style' do RSpec.describe 'Coding style' do
describe 'Javascript' do describe 'Javascript' do
it 'prevents this.get("foo") pattern' do it 'prevents this.get("foo") pattern' do
js_files = list_js_files('app/assets/javascripts') js_files = list_js_files('app/assets/javascripts')

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
describe "CommonMark" do RSpec.describe "CommonMark" do
it 'passes spec' do it 'passes spec' do
SiteSetting.traditional_markdown_linebreaks = true SiteSetting.traditional_markdown_linebreaks = true

View File

@ -20,7 +20,7 @@ def is_yaml_compatible?(english, translated)
true true
end end
describe "i18n integrity checks" do RSpec.describe "i18n integrity checks" do
it "has an i18n key for each Site Setting" do it "has an i18n key for each Site Setting" do
SiteSetting.all_settings.each do |s| SiteSetting.all_settings.each do |s|
next if s[:setting][/^test_/] next if s[:setting][/^test_/]
@ -97,7 +97,7 @@ describe "i18n integrity checks" do
end end
end end
describe "fallbacks" do RSpec.describe "fallbacks" do
before do before do
I18n.backend = I18n::Backend::DiscourseI18n.new I18n.backend = I18n::Backend::DiscourseI18n.new
I18n.fallbacks = I18n::Backend::FallbackLocaleList.new I18n.fallbacks = I18n::Backend::FallbackLocaleList.new

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe "constants match ruby" do RSpec.describe "constants match ruby" do
let(:ctx) { MiniRacer::Context.new } let(:ctx) { MiniRacer::Context.new }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe 'Oj' do RSpec.describe 'Oj' do
it "is enabled" do it "is enabled" do
classes = Set.new classes = Set.new
tracer = TracePoint.new(:c_call) { |tp| classes << tp.defined_class } tracer = TracePoint.new(:c_call) { |tp| classes << tp.defined_class }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe ::Jobs::Onceoff do RSpec.describe ::Jobs::Onceoff do
it "can run all once off jobs without errors" do it "can run all once off jobs without errors" do
# Load all once offs # Load all once offs
Dir[Rails.root + 'app/jobs/onceoff/*.rb'].each do |f| Dir[Rails.root + 'app/jobs/onceoff/*.rb'].each do |f|

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe "site setting integrity checks" do RSpec.describe "site setting integrity checks" do
let(:site_setting_file) { File.join(Rails.root, 'config', 'site_settings.yml') } let(:site_setting_file) { File.join(Rails.root, 'config', 'site_settings.yml') }
let(:yaml) { YAML.load_file(site_setting_file) } let(:yaml) { YAML.load_file(site_setting_file) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::AboutStats do RSpec.describe Jobs::AboutStats do
it 'caches the stats' do it 'caches the stats' do
begin begin
stats = About.fetch_stats.to_json stats = About.fetch_stats.to_json

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::ActivationReminderEmails do RSpec.describe Jobs::ActivationReminderEmails do
before { Jobs.run_immediately! } before { Jobs.run_immediately! }
# should be between 2 and 3 days # should be between 2 and 3 days

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::AutoQueueHandler do RSpec.describe Jobs::AutoQueueHandler do
subject { Jobs::AutoQueueHandler.new.execute({}) } subject { Jobs::AutoQueueHandler.new.execute({}) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::AutomaticGroupMembership do RSpec.describe Jobs::AutomaticGroupMembership do
it "raises an error when the group id is missing" do it "raises an error when the group id is missing" do
expect { Jobs::AutomaticGroupMembership.new.execute({}) }.to raise_error(Discourse::InvalidParameters) expect { Jobs::AutomaticGroupMembership.new.execute({}) }.to raise_error(Discourse::InvalidParameters)

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::BulkGrantTrustLevel do RSpec.describe Jobs::BulkGrantTrustLevel do
it "raises an error when trust_level is missing" do it "raises an error when trust_level is missing" do
expect { Jobs::BulkGrantTrustLevel.new.execute(user_ids: [1, 2]) }.to raise_error(Discourse::InvalidParameters) expect { Jobs::BulkGrantTrustLevel.new.execute(user_ids: [1, 2]) }.to raise_error(Discourse::InvalidParameters)

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::BulkInvite do RSpec.describe Jobs::BulkInvite do
describe '#execute' do describe '#execute' do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::BumpTopic do RSpec.describe Jobs::BumpTopic do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::CleanDismissedTopicUsers do RSpec.describe Jobs::CleanDismissedTopicUsers do
fab!(:user) { Fabricate(:user, created_at: 1.days.ago, previous_visit_at: 1.days.ago) } fab!(:user) { Fabricate(:user, created_at: 1.days.ago, previous_visit_at: 1.days.ago) }
fab!(:topic) { Fabricate(:topic, created_at: 5.hours.ago) } fab!(:topic) { Fabricate(:topic, created_at: 5.hours.ago) }
fab!(:dismissed_topic_user) { Fabricate(:dismissed_topic_user, user: user, topic: topic) } fab!(:dismissed_topic_user) { Fabricate(:dismissed_topic_user, user: user, topic: topic) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::CleanUpAssociatedAccounts do RSpec.describe Jobs::CleanUpAssociatedAccounts do
subject { Jobs::CleanUpAssociatedAccounts.new.execute({}) } subject { Jobs::CleanUpAssociatedAccounts.new.execute({}) }
it "deletes the correct records" do it "deletes the correct records" do

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::CleanUpCrawlerStats do RSpec.describe Jobs::CleanUpCrawlerStats do
subject { Jobs::CleanUpCrawlerStats.new.execute({}) } subject { Jobs::CleanUpCrawlerStats.new.execute({}) }
it "deletes records older than 30 days old" do it "deletes records older than 30 days old" do

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::CleanUpEmailChangeRequests do RSpec.describe Jobs::CleanUpEmailChangeRequests do
it "deletes records older than 1 month" do it "deletes records older than 1 month" do
very_old = Fabricate(:email_change_request, updated_at: 32.days.ago) very_old = Fabricate(:email_change_request, updated_at: 32.days.ago)
yesterday = Fabricate(:email_change_request, updated_at: 1.day.ago) yesterday = Fabricate(:email_change_request, updated_at: 1.day.ago)

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::CleanUpEmailLogs do RSpec.describe Jobs::CleanUpEmailLogs do
fab!(:email_log) { Fabricate(:email_log, created_at: 2.years.ago) } fab!(:email_log) { Fabricate(:email_log, created_at: 2.years.ago) }
fab!(:email_log2) { Fabricate(:email_log, created_at: 2.weeks.ago) } fab!(:email_log2) { Fabricate(:email_log, created_at: 2.weeks.ago) }
fab!(:email_log3) { Fabricate(:email_log, created_at: 2.days.ago) } fab!(:email_log3) { Fabricate(:email_log, created_at: 2.days.ago) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::CleanUpUploads do RSpec.describe Jobs::CleanUpUploads do
def fabricate_upload(attributes = {}) def fabricate_upload(attributes = {})
Fabricate(:upload, { created_at: 2.hours.ago }.merge(attributes)) Fabricate(:upload, { created_at: 2.hours.ago }.merge(attributes))

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::CleanupImapSyncLog do RSpec.describe Jobs::CleanupImapSyncLog do
let(:job_class) { Jobs::CleanupImapSyncLog.new } let(:job_class) { Jobs::CleanupImapSyncLog.new }
it "deletes logs older than RETAIN_LOGS_DAYS" do it "deletes logs older than RETAIN_LOGS_DAYS" do

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::CloseTopic do RSpec.describe Jobs::CloseTopic do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
fab!(:topic) do fab!(:topic) do

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::CorrectMissingDualstackUrls do RSpec.describe Jobs::CorrectMissingDualstackUrls do
it 'corrects the urls' do it 'corrects the urls' do
setup_s3 setup_s3
SiteSetting.s3_region = "us-east-1" SiteSetting.s3_region = "us-east-1"

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::CrawlTopicLink do RSpec.describe Jobs::CrawlTopicLink do
let(:job) { Jobs::CrawlTopicLink.new } let(:job) { Jobs::CrawlTopicLink.new }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::CreateLinkedTopic do RSpec.describe Jobs::CreateLinkedTopic do
it "returns when the post cannot be found" do it "returns when the post cannot be found" do
expect { Jobs::CreateLinkedTopic.new.perform(post_id: 1, sync_exec: true) }.not_to raise_error expect { Jobs::CreateLinkedTopic.new.perform(post_id: 1, sync_exec: true) }.not_to raise_error
end end

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::CreateMissingAvatars do RSpec.describe Jobs::CreateMissingAvatars do
it "runs correctly without crashing" do it "runs correctly without crashing" do
Jobs::CreateMissingAvatars.new.execute(nil) Jobs::CreateMissingAvatars.new.execute(nil)
end end

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::CreateRecentPostSearchIndexes do RSpec.describe Jobs::CreateRecentPostSearchIndexes do
subject { described_class.new } subject { described_class.new }
fab!(:post) do fab!(:post) do

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::CreateUserReviewable do RSpec.describe Jobs::CreateUserReviewable do
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe ::Jobs::DashboardStats do RSpec.describe ::Jobs::DashboardStats do
let(:group_message) { GroupMessage.new(Group[:admins].name, :dashboard_problems, limit_once_per: 7.days.to_i) } let(:group_message) { GroupMessage.new(Group[:admins].name, :dashboard_problems, limit_once_per: 7.days.to_i) }
def clear_recently_sent! def clear_recently_sent!

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::DeleteReplies do RSpec.describe Jobs::DeleteReplies do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
fab!(:topic) { Fabricate(:topic) } fab!(:topic) { Fabricate(:topic) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::DeleteTopic do RSpec.describe Jobs::DeleteTopic do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
fab!(:topic) do fab!(:topic) do

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::DisableBootstrapMode do RSpec.describe Jobs::DisableBootstrapMode do
describe '.execute' do describe '.execute' do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }

View File

@ -2,7 +2,7 @@
require 'excon' require 'excon'
describe Jobs::EmitWebHookEvent do RSpec.describe Jobs::EmitWebHookEvent do
fab!(:post_hook) { Fabricate(:web_hook) } fab!(:post_hook) { Fabricate(:web_hook) }
fab!(:inactive_hook) { Fabricate(:inactive_web_hook) } fab!(:inactive_hook) { Fabricate(:inactive_web_hook) }
fab!(:post) { Fabricate(:post) } fab!(:post) { Fabricate(:post) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::EnableBootstrapMode do RSpec.describe Jobs::EnableBootstrapMode do
describe '.execute' do describe '.execute' do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::EnqueueDigestEmails do RSpec.describe Jobs::EnqueueDigestEmails do
describe '#target_users' do describe '#target_users' do

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::EnqueueSuspectUsers do RSpec.describe Jobs::EnqueueSuspectUsers do
before { SiteSetting.approve_suspect_users = true } before { SiteSetting.approve_suspect_users = true }
it 'does nothing when there are no suspect users' do it 'does nothing when there are no suspect users' do

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::ExportCsvFile do RSpec.describe Jobs::ExportCsvFile do
describe '#execute' do describe '#execute' do
let(:other_user) { Fabricate(:user) } let(:other_user) { Fabricate(:user) }

View File

@ -2,7 +2,7 @@
require 'csv' require 'csv'
describe Jobs::ExportUserArchive do RSpec.describe Jobs::ExportUserArchive do
fab!(:user) { Fabricate(:user, username: "john_doe") } fab!(:user) { Fabricate(:user, username: "john_doe") }
fab!(:user2) { Fabricate(:user) } fab!(:user2) { Fabricate(:user) }
let(:extra) { {} } let(:extra) { {} }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::FeatureTopicUsers do RSpec.describe Jobs::FeatureTopicUsers do
it "raises an error without a topic_id" do it "raises an error without a topic_id" do
expect { Jobs::FeatureTopicUsers.new.execute({}) }.to raise_error(Discourse::InvalidParameters) expect { Jobs::FeatureTopicUsers.new.execute({}) }.to raise_error(Discourse::InvalidParameters)
end end

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::GrantAnniversaryBadges do RSpec.describe Jobs::GrantAnniversaryBadges do
let(:granter) { described_class.new } let(:granter) { described_class.new }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::GrantNewUserOfTheMonthBadges do RSpec.describe Jobs::GrantNewUserOfTheMonthBadges do
let(:granter) { described_class.new } let(:granter) { described_class.new }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe ::Jobs::Heartbeat do RSpec.describe ::Jobs::Heartbeat do
after do after do
Discourse.disable_readonly_mode Discourse.disable_readonly_mode
end end

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::IgnoredUsersSummary do RSpec.describe Jobs::IgnoredUsersSummary do
before do before do
SiteSetting.ignored_users_count_message_threshold = 1 SiteSetting.ignored_users_count_message_threshold = 1
SiteSetting.ignored_users_message_gap_days = 365 SiteSetting.ignored_users_message_gap_days = 365

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::InvalidateInactiveAdmins do RSpec.describe Jobs::InvalidateInactiveAdmins do
fab!(:active_admin) { Fabricate(:admin, last_seen_at: 1.hour.ago) } fab!(:active_admin) { Fabricate(:admin, last_seen_at: 1.hour.ago) }
before { active_admin.email_tokens.update_all(confirmed: true) } before { active_admin.email_tokens.update_all(confirmed: true) }

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
describe Jobs::InviteEmail do RSpec.describe Jobs::InviteEmail do
describe '.execute' do describe '.execute' do

Some files were not shown because too many files have changed in this diff Show More