Update rubocop and rubocop-rspec (#26329)

This commit is contained in:
Nick Schonning 2023-08-22 03:31:40 -04:00 committed by GitHub
parent fe31571965
commit b970ed6098
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 48 additions and 74 deletions

View file

@ -16,8 +16,7 @@ describe Api::V1::Instances::TranslationLanguagesController do
context 'when a translation service is configured' do
before do
service = instance_double(TranslationService::DeepL, languages: { nil => %w(en de), 'en' => ['de'] })
allow(TranslationService).to receive(:configured?).and_return(true)
allow(TranslationService).to receive(:configured).and_return(service)
allow(TranslationService).to receive_messages(configured?: true, configured: service)
end
it 'returns language matrix' do

View file

@ -20,8 +20,7 @@ describe Api::V1::Statuses::TranslationsController do
before do
translation = TranslationService::Translation.new(text: 'Hello')
service = instance_double(TranslationService::DeepL, translate: [translation])
allow(TranslationService).to receive(:configured?).and_return(true)
allow(TranslationService).to receive(:configured).and_return(service)
allow(TranslationService).to receive_messages(configured?: true, configured: service)
Rails.cache.write('translation_service/languages', { 'es' => ['en'] })
post :create, params: { status_id: status.id }
end

View file

@ -7,8 +7,7 @@ describe Admin::FilterHelper do
params = ActionController::Parameters.new(
{ test: 'test' }
)
allow(helper).to receive(:params).and_return(params)
allow(helper).to receive(:url_for).and_return('/test')
allow(helper).to receive_messages(params: params, url_for: '/test')
result = helper.filter_link_to('text', { resolved: true })
expect(result).to match(/text/)

View file

@ -31,9 +31,7 @@ describe ApplicationHelper do
context 'with a body class string from a controller' do
before do
without_partial_double_verification do
allow(helper).to receive(:body_class_string).and_return('modal-layout compose-standalone')
allow(helper).to receive(:current_theme).and_return('default')
allow(helper).to receive(:current_account).and_return(Fabricate(:account))
allow(helper).to receive_messages(body_class_string: 'modal-layout compose-standalone', current_theme: 'default', current_account: Fabricate(:account))
end
end

View file

@ -25,8 +25,7 @@ RSpec.describe HomeHelper do
it 'returns a link to the account' do
without_partial_double_verification do
allow(helper).to receive(:current_account).and_return(account)
allow(helper).to receive(:prefers_autoplay?).and_return(false)
allow(helper).to receive_messages(current_account: account, prefers_autoplay?: false)
result = helper.account_link_to(account)
expect(result).to match "@#{account.acct}"
@ -101,8 +100,7 @@ RSpec.describe HomeHelper do
context 'with open registrations' do
it 'returns correct sign up message' do
allow(helper).to receive(:closed_registrations?).and_return(false)
allow(helper).to receive(:open_registrations?).and_return(true)
allow(helper).to receive_messages(closed_registrations?: false, open_registrations?: true)
result = helper.sign_up_message
expect(result).to eq t('auth.register')
@ -111,9 +109,7 @@ RSpec.describe HomeHelper do
context 'with approved registrations' do
it 'returns correct sign up message' do
allow(helper).to receive(:closed_registrations?).and_return(false)
allow(helper).to receive(:open_registrations?).and_return(false)
allow(helper).to receive(:approved_registrations?).and_return(true)
allow(helper).to receive_messages(closed_registrations?: false, open_registrations?: false, approved_registrations?: true)
result = helper.sign_up_message
expect(result).to eq t('auth.apply_for_account')

View file

@ -14,13 +14,12 @@ describe Admin::SystemCheck::ElasticsearchCheck do
before do
allow(Chewy).to receive(:enabled?).and_return(true)
allow(Chewy.client.cluster).to receive(:health).and_return({ 'status' => 'green', 'number_of_nodes' => 1 })
allow(Chewy.client.indices).to receive(:get_mapping).and_return({
allow(Chewy.client.indices).to receive_messages(get_mapping: {
AccountsIndex.index_name => AccountsIndex.mappings_hash.deep_stringify_keys,
StatusesIndex.index_name => StatusesIndex.mappings_hash.deep_stringify_keys,
InstancesIndex.index_name => InstancesIndex.mappings_hash.deep_stringify_keys,
TagsIndex.index_name => TagsIndex.mappings_hash.deep_stringify_keys,
})
allow(Chewy.client.indices).to receive(:get_settings).and_return({
}, get_settings: {
'chewy_specifications' => {
'settings' => {
'index' => {

View file

@ -23,8 +23,7 @@ describe ReportFilter do
it 'combines filters on Report' do
filter = described_class.new(account_id: '123', resolved: true, target_account_id: '456')
allow(Report).to receive(:where).and_return(Report.none)
allow(Report).to receive(:resolved).and_return(Report.none)
allow(Report).to receive_messages(where: Report.none, resolved: Report.none)
filter.results
expect(Report).to have_received(:where).with(account_id: '123')
expect(Report).to have_received(:where).with(target_account_id: '456')

View file

@ -10,8 +10,7 @@ RSpec.describe SuspendAccountService, type: :service do
let!(:list) { Fabricate(:list, account: local_follower) }
before do
allow(FeedManager.instance).to receive(:unmerge_from_home).and_return(nil)
allow(FeedManager.instance).to receive(:unmerge_from_list).and_return(nil)
allow(FeedManager.instance).to receive_messages(unmerge_from_home: nil, unmerge_from_list: nil)
local_follower.follow!(account)
list.accounts << account

View file

@ -29,8 +29,7 @@ RSpec.describe TranslateStatusService, type: :service do
end
end
allow(TranslationService).to receive(:configured?).and_return(true)
allow(TranslationService).to receive(:configured).and_return(translation_service)
allow(TranslationService).to receive_messages(configured?: true, configured: translation_service)
end
it 'returns translated status content' do

View file

@ -10,8 +10,7 @@ RSpec.describe UnsuspendAccountService, type: :service do
let!(:list) { Fabricate(:list, account: local_follower) }
before do
allow(FeedManager.instance).to receive(:merge_into_home).and_return(nil)
allow(FeedManager.instance).to receive(:merge_into_list).and_return(nil)
allow(FeedManager.instance).to receive_messages(merge_into_home: nil, merge_into_list: nil)
local_follower.follow!(account)
list.accounts << account

View file

@ -4,15 +4,9 @@ require 'rails_helper'
describe 'statuses/show.html.haml', without_verify_partial_doubles: true do
before do
allow(view).to receive(:api_oembed_url).and_return('')
allow(view).to receive(:show_landing_strip?).and_return(true)
allow(view).to receive(:site_title).and_return('example site')
allow(view).to receive(:site_hostname).and_return('example.com')
allow(view).to receive(:full_asset_url).and_return('//asset.host/image.svg')
allow(view).to receive_messages(api_oembed_url: '', show_landing_strip?: true, site_title: 'example site', site_hostname: 'example.com', full_asset_url: '//asset.host/image.svg', current_account: nil, single_user_mode?: false)
allow(view).to receive(:local_time)
allow(view).to receive(:local_time_ago)
allow(view).to receive(:current_account).and_return(nil)
allow(view).to receive(:single_user_mode?).and_return(false)
assign(:instance_presenter, InstancePresenter.new)
end