Skip to content

Commit 8389618

Browse files
committed
Rubocop fixes
1 parent 333113a commit 8389618

File tree

7 files changed

+25
-16
lines changed

7 files changed

+25
-16
lines changed

spec/helpers/better_together/hub_helper_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'rails_helper'
44

5+
# rubocop:disable Metrics/ModuleLength
56
module BetterTogether
67
RSpec.describe HubHelper do
78
describe '#activities' do
@@ -217,3 +218,4 @@ module BetterTogether
217218
end
218219
end
219220
end
221+
# rubocop:enable Metrics/ModuleLength

spec/jobs/better_together/platform_invitation_mailer_job_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'rails_helper'
44

5+
# rubocop:disable Metrics/ModuleLength
56
module BetterTogether
67
RSpec.describe PlatformInvitationMailerJob do
78
include ActiveSupport::Testing::TimeHelpers
@@ -228,3 +229,4 @@ module BetterTogether
228229
end
229230
end
230231
end
232+
# rubocop:enable Metrics/ModuleLength

spec/lib/better_together/migration_helpers_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'rails_helper'
44

5+
# rubocop:disable Metrics/ModuleLength, RSpec/StubbedMock, RSpec/VerifiedDoubles, RSpec/RepeatedExample
56
module BetterTogether
67
RSpec.describe MigrationHelpers do
78
# Create a test migration class to include the module
@@ -344,3 +345,4 @@ module BetterTogether
344345
end
345346
end
346347
end
348+
# rubocop:enable Metrics/ModuleLength, RSpec/StubbedMock, RSpec/VerifiedDoubles, RSpec/RepeatedExample

spec/mailers/better_together/platform_invitation_mailer_spec.rb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'rails_helper'
44

5+
# rubocop:disable Metrics/ModuleLength
56
module BetterTogether
67
RSpec.describe PlatformInvitationMailer do
78
describe '#invite' do
@@ -63,11 +64,7 @@ module BetterTogether
6364
locale: 'en')
6465
end
6566

66-
it 'returns nil without sending' do
67-
expect(mail.message).to be_a(ActionMailer::Base::NullMail)
68-
end
69-
70-
it 'does not render the email body' do
67+
it 'returns NullMail without sending' do
7168
expect(mail.message).to be_a(ActionMailer::Base::NullMail)
7269
end
7370
end
@@ -176,11 +173,7 @@ module BetterTogether
176173
expect(mail.body.encoded).to match(platform_invitation.greeting.to_plain_text)
177174
end
178175

179-
it 'assigns @valid_from' do
180-
expect(mail.body.encoded).to be_present
181-
end
182-
183-
it 'assigns @valid_until' do
176+
it 'assigns @valid_from and @valid_until' do
184177
expect(mail.body.encoded).to be_present
185178
end
186179

@@ -191,3 +184,4 @@ module BetterTogether
191184
end
192185
end
193186
end
187+
# rubocop:enable Metrics/ModuleLength

spec/requests/better_together/setup_wizard_steps_controller_spec.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'rails_helper'
44

5+
# rubocop:disable Metrics/ModuleLength
56
module BetterTogether
67
RSpec.describe SetupWizardStepsController, :skip_host_setup do
78
let(:wizard) { Wizard.find_or_create_by!(identifier: 'host_setup') }
@@ -130,9 +131,11 @@ module BetterTogether
130131
invalid_platform = Platform.new
131132
invalid_platform.errors.add(:base, 'Test validation error')
132133

134+
# rubocop:disable RSpec/AnyInstance
133135
allow_any_instance_of(Platform).to receive(:save!).and_raise(
134136
ActiveRecord::RecordInvalid.new(invalid_platform)
135137
)
138+
# rubocop:enable RSpec/AnyInstance
136139

137140
post better_together.setup_wizard_step_create_host_platform_path(locale: I18n.default_locale),
138141
params: { platform: valid_platform_params }
@@ -210,7 +213,8 @@ module BetterTogether
210213
context 'with valid parameters' do
211214
before do
212215
# Wizard should start with ZERO users and create the first one
213-
expect(User.count).to eq(0), "Expected 0 users before wizard creates first admin, found #{User.count}"
216+
raise "Expected 0 users before wizard creates first admin, found #{User.count}" unless User.none?
217+
214218
post better_together.setup_wizard_step_create_admin_path(locale: I18n.default_locale),
215219
params: { user: valid_user_params }
216220
end
@@ -307,9 +311,11 @@ module BetterTogether
307311
invalid_user = User.new
308312
invalid_user.errors.add(:base, 'Test validation error')
309313

314+
# rubocop:disable RSpec/AnyInstance
310315
allow_any_instance_of(User).to receive(:save!).and_raise(
311316
ActiveRecord::RecordInvalid.new(invalid_user)
312317
)
318+
# rubocop:enable RSpec/AnyInstance
313319

314320
post better_together.setup_wizard_step_create_admin_path(locale: I18n.default_locale),
315321
params: { user: valid_user_params }
@@ -372,7 +378,9 @@ module BetterTogether
372378

373379
describe '#base_platform' do
374380
before do
381+
# rubocop:disable RSpec/MessageChain
375382
allow(controller).to receive_message_chain(:helpers, :base_url).and_return('http://test.example.com')
383+
# rubocop:enable RSpec/MessageChain
376384
end
377385

378386
it 'creates a platform with default attributes' do
@@ -387,3 +395,4 @@ module BetterTogether
387395
end
388396
end
389397
end
398+
# rubocop:enable Metrics/ModuleLength

spec/requests/better_together/translations_controller_spec.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'rails_helper'
44

5+
# rubocop:disable Metrics/ModuleLength
56
module BetterTogether
67
RSpec.describe TranslationsController, :as_user do
78
describe 'POST #translate' do
@@ -153,11 +154,7 @@ module BetterTogether
153154
end
154155

155156
context 'when current_person is nil' do
156-
it 'passes nil as initiator' do
157-
skip 'Route requires authentication, so current_person cannot be nil in practice'
158-
end
159-
160-
it 'still returns successful translation' do
157+
it 'handles nil initiator and returns successful translation' do
161158
skip 'Route requires authentication, so current_person cannot be nil in practice'
162159
end
163160
end
@@ -211,3 +208,4 @@ module BetterTogether
211208
end
212209
end
213210
end
211+
# rubocop:enable Metrics/ModuleLength

spec/sanitizers/better_together/sanitizers/external_link_icon_sanitizer_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require 'rails_helper'
44

55
module BetterTogether
6+
# rubocop:disable Metrics/ModuleLength
67
module Sanitizers
78
RSpec.describe ExternalLinkIconSanitizer do
89
let(:sanitizer) { described_class.new }
@@ -294,4 +295,5 @@ module Sanitizers
294295
end
295296
end
296297
end
298+
# rubocop:enable Metrics/ModuleLength
297299
end

0 commit comments

Comments
 (0)