Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RSpec 4 compatibility #17652

Merged
merged 7 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
--colour
--require 'rails_helper'
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'rails_helper'
require 'pretty_text'

describe PrettyText do
RSpec.describe PrettyText do

let(:post) { Fabricate(:post) }

Expand Down
2 changes: 1 addition & 1 deletion plugins/discourse-local-dates/spec/lib/pretty_text_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def generate_html(text, opts = {})
output + "</span></p>"
end

describe PrettyText do
RSpec.describe PrettyText do
before do
freeze_time
end
Expand Down
2 changes: 1 addition & 1 deletion plugins/discourse-local-dates/spec/models/post_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Post do
RSpec.describe Post do

before do
Jobs.run_immediately!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

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

describe DiscourseNarrativeBot::Store do
RSpec.describe DiscourseNarrativeBot::Store do
describe '.set' do
it 'should set the right value in the plugin store' do
key = 'somekey'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe DiscourseNarrativeBot::TrackSelector do
RSpec.describe DiscourseNarrativeBot::TrackSelector do
let(:user) { Fabricate(:user) }
let(:narrative_bot) { ::DiscourseNarrativeBot::Base.new }
let(:discobot_user) { narrative_bot.discobot_user }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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
let!(:post) do
Fabricate(:post,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe "Discobot Certificate" do
RSpec.describe "Discobot Certificate" do
let(:user) { Fabricate(:user, name: 'Jeff Atwood') }

let(:params) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe "Discobot welcome post" do
RSpec.describe "Discobot welcome post" do
let(:user) { Fabricate(:user) }

before do
Expand Down
2 changes: 1 addition & 1 deletion plugins/discourse-narrative-bot/spec/user_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe User do
RSpec.describe User do
let(:user) { Fabricate(:user) }
let(:profile_page_url) { "#{Discourse.base_url}/users/#{user.username}" }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe "discourse-presence" do
RSpec.describe "discourse-presence" do
describe 'PresenceChannel configuration' do
fab!(:user) { Fabricate(:user) }
fab!(:user2) { Fabricate(:user) }
Expand Down
2 changes: 1 addition & 1 deletion plugins/poll/spec/controllers/polls_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "rails_helper"

describe ::DiscoursePoll::PollsController do
RSpec.describe ::DiscoursePoll::PollsController do
routes { ::DiscoursePoll::Engine.routes }

let!(:user) { log_in }
Expand Down
2 changes: 1 addition & 1 deletion plugins/poll/spec/controllers/posts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "rails_helper"

describe PostsController do
RSpec.describe PostsController do
let!(:user) { log_in }
let!(:title) { "Testing Poll Plugin" }

Expand Down
2 changes: 1 addition & 1 deletion plugins/poll/spec/integration/poll_endpoints_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "rails_helper"

describe "DiscoursePoll endpoints" do
RSpec.describe "DiscoursePoll endpoints" do
describe "fetch voters for a poll" do
fab!(:user) { Fabricate(:user) }
fab!(:post) { Fabricate(:post, raw: "[poll public=true]\n- A\n- B\n[/poll]") }
Expand Down
2 changes: 1 addition & 1 deletion plugins/poll/spec/jobs/regular/close_poll_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "rails_helper"

describe Jobs::ClosePoll do
RSpec.describe Jobs::ClosePoll do
let(:post) { Fabricate(:post, raw: "[poll]\n- A\n- B\n[/poll]") }

describe 'missing arguments' do
Expand Down
2 changes: 1 addition & 1 deletion plugins/poll/spec/lib/new_post_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "rails_helper"

describe NewPostManager do
RSpec.describe NewPostManager do
let(:user) { Fabricate(:newuser) }
let(:admin) { Fabricate(:admin) }

Expand Down
2 changes: 1 addition & 1 deletion plugins/poll/spec/lib/poll_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe DiscoursePoll::Poll do
RSpec.describe DiscoursePoll::Poll do
fab!(:user) { Fabricate(:user) }
fab!(:user_2) { Fabricate(:user) }

Expand Down
2 changes: 1 addition & 1 deletion plugins/poll/spec/lib/polls_updater_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe DiscoursePoll::PollsUpdater do
RSpec.describe DiscoursePoll::PollsUpdater do

def update(post, polls)
DiscoursePoll::PollsUpdater.update(post, polls)
Expand Down
2 changes: 1 addition & 1 deletion plugins/poll/spec/lib/polls_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "rails_helper"

describe ::DiscoursePoll::PollsValidator do
RSpec.describe ::DiscoursePoll::PollsValidator do
let(:post) { Fabricate(:post) }
subject { described_class.new(post) }

Expand Down
2 changes: 1 addition & 1 deletion plugins/poll/spec/lib/pretty_text_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe PrettyText do
RSpec.describe PrettyText do

def n(html)
html.strip
Expand Down
2 changes: 1 addition & 1 deletion plugins/poll/spec/models/poll_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe ::DiscoursePoll::Poll do
RSpec.describe ::DiscoursePoll::Poll do
describe ".transform_for_user_field_override" do
it "Transforms UserField name if a matching CustomUserField is present" do
user_field_name = "Something Cool"
Expand Down
2 changes: 1 addition & 1 deletion plugins/poll/spec/requests/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "rails_helper"

describe Admin::UsersController do
RSpec.describe Admin::UsersController do

let(:admin) { Fabricate(:admin) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def serialize_option(option, user)
)
end

describe PollOptionSerializer do
RSpec.describe PollOptionSerializer do
let(:voter) { Fabricate(:user) }
let(:poll) { post.polls.first }

Expand Down
4 changes: 2 additions & 2 deletions plugins/styleguide/spec/integration/access_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe 'SiteSetting.styleguide_admin_only' do
RSpec.describe 'SiteSetting.styleguide_admin_only' do
before do
SiteSetting.styleguide_enabled = true
end
Expand Down Expand Up @@ -34,7 +34,7 @@
end
end

describe 'SiteSetting.styleguide_enabled' do
RSpec.describe 'SiteSetting.styleguide_enabled' do
before do
sign_in(Fabricate(:admin))
end
Expand Down
2 changes: 1 addition & 1 deletion plugins/styleguide/spec/integration/assets_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe 'Styleguide assets' do
RSpec.describe 'Styleguide assets' do
before do
SiteSetting.styleguide_enabled = true
sign_in(Fabricate(:admin))
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding: utf-8
# frozen_string_literal: true

describe ApplicationHelper do
RSpec.describe ApplicationHelper do

describe "preload_script" do
def preload_link(url)
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/topics_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe TopicsHelper do
RSpec.describe TopicsHelper do

describe "#categories_breadcrumb" do
let(:user) { Fabricate(:user) }
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/user_notifications_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe UserNotificationsHelper do
RSpec.describe UserNotificationsHelper do
let(:upload_path) { Discourse.store.upload_path }

describe '#email_excerpt' do
Expand Down
2 changes: 1 addition & 1 deletion spec/import_export/category_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "import_export"

describe ImportExport::CategoryExporter do
RSpec.describe ImportExport::CategoryExporter do

fab!(:category) { Fabricate(:category) }
fab!(:group) { Fabricate(:group) }
Expand Down
2 changes: 1 addition & 1 deletion spec/import_export/category_structure_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "import_export/category_structure_exporter"

describe ImportExport::CategoryStructureExporter do
RSpec.describe ImportExport::CategoryStructureExporter do

before do
STDOUT.stubs(:write)
Expand Down
2 changes: 1 addition & 1 deletion spec/import_export/group_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "import_export/group_exporter"

describe ImportExport::GroupExporter do
RSpec.describe ImportExport::GroupExporter do

before do
STDOUT.stubs(:write)
Expand Down
2 changes: 1 addition & 1 deletion spec/import_export/importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "import_export"

describe ImportExport::Importer do
RSpec.describe ImportExport::Importer do

before do
STDOUT.stubs(:write)
Expand Down
2 changes: 1 addition & 1 deletion spec/import_export/topic_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "import_export"

describe ImportExport::TopicExporter do
RSpec.describe ImportExport::TopicExporter do

before do
STDOUT.stubs(:write)
Expand Down
2 changes: 1 addition & 1 deletion spec/initializers/track_setting_changes_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe 'Setting changes' do
RSpec.describe 'Setting changes' do
describe '#must_approve_users' do
before { SiteSetting.must_approve_users = false }

Expand Down
4 changes: 2 additions & 2 deletions spec/integration/api_keys_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe 'api keys' do
RSpec.describe 'api keys' do
let(:user) { Fabricate(:user) }
let(:api_key) { ApiKey.create!(user_id: user.id, created_by_id: Discourse.system_user) }

Expand Down Expand Up @@ -61,7 +61,7 @@
end
end

describe 'user api keys' do
RSpec.describe 'user api keys' do
let(:user) { Fabricate(:user) }
let(:user_api_key) { Fabricate(:readonly_user_api_key, user: user) }

Expand Down
2 changes: 1 addition & 1 deletion spec/integration/auto_reject_reviewable_users_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe "auto reject reviewable users" do
RSpec.describe "auto reject reviewable users" do
context "reviewable users" do
fab!(:old_user) { Fabricate(:reviewable, created_at: 80.days.ago) }

Expand Down
2 changes: 1 addition & 1 deletion spec/integration/blocked_hotlinked_media_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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(:onebox_url) { "http://example.com/onebox" }
let(:png) { Base64.decode64("R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==") }
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/category_tag_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: UTF-8
# frozen_string_literal: true

describe "category tag restrictions" do
RSpec.describe "category tag restrictions" do

def filter_allowed_tags(opts = {})
DiscourseTagging.filter_allowed_tags(Guardian.new(user), opts)
Expand Down Expand Up @@ -427,7 +427,7 @@ def filter_allowed_tags(opts = {})
end
end

describe "tag topic counts per category" do
RSpec.describe "tag topic counts per category" do
fab!(:admin) { Fabricate(:admin) }
fab!(:category) { Fabricate(:category) }
fab!(:category2) { Fabricate(:category) }
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/content_security_policy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe 'content security policy integration' do
RSpec.describe 'content security policy integration' do

it "adds the csp headers correctly" do
SiteSetting.content_security_policy = false
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/email_outbound_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# with mailer specific mailer specs like UserEmail, but sometimes we need
# to test things along the whole outbound flow including the MessageBuilder
# and the Sender.
describe "Outbound Email" do
RSpec.describe "Outbound Email" do
def send_email(opts = {})
message = TestMailer.send_test("test@test.com", opts)
result = Email::Sender.new(message, :test_message).send
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/email_style_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe EmailStyle do
RSpec.describe EmailStyle do

context "ERB evaluation" do
it "does not evaluate ERB outside of the email itself" do
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/flags_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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
admin = Fabricate(:admin)
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Group do
RSpec.describe Group do
let(:group) do
Fabricate(
:group,
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/invalid_request_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe 'invalid requests', type: :request do
RSpec.describe 'invalid requests', type: :request do
before do
@orig_logger = Rails.logger
Rails.logger = @fake_logger = FakeLogger.new
Expand Down