Fix RSpec/ContextWording cop (#24739)

pull/59/head^2^2
Matt Jankowski 2023-05-03 23:49:08 -04:00 committed by GitHub
parent cf18cc2891
commit 710745e16b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
105 changed files with 559 additions and 668 deletions

View File

@ -328,115 +328,6 @@ RSpec/AnyInstance:
- 'spec/workers/activitypub/delivery_worker_spec.rb'
- 'spec/workers/web/push_notification_worker_spec.rb'
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/config/initializers/rack_attack_spec.rb'
- 'spec/controllers/accounts_controller_spec.rb'
- 'spec/controllers/activitypub/collections_controller_spec.rb'
- 'spec/controllers/activitypub/inboxes_controller_spec.rb'
- 'spec/controllers/admin/domain_blocks_controller_spec.rb'
- 'spec/controllers/admin/reports/actions_controller_spec.rb'
- 'spec/controllers/admin/statuses_controller_spec.rb'
- 'spec/controllers/api/v1/accounts/relationships_controller_spec.rb'
- 'spec/controllers/api/v1/accounts_controller_spec.rb'
- 'spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb'
- 'spec/controllers/api/v1/emails/confirmations_controller_spec.rb'
- 'spec/controllers/api/v1/instances/activity_controller_spec.rb'
- 'spec/controllers/api/v1/instances/peers_controller_spec.rb'
- 'spec/controllers/api/v1/media_controller_spec.rb'
- 'spec/controllers/api/v2/filters_controller_spec.rb'
- 'spec/controllers/application_controller_spec.rb'
- 'spec/controllers/auth/registrations_controller_spec.rb'
- 'spec/controllers/auth/sessions_controller_spec.rb'
- 'spec/controllers/concerns/cache_concern_spec.rb'
- 'spec/controllers/concerns/challengable_concern_spec.rb'
- 'spec/controllers/concerns/localized_spec.rb'
- 'spec/controllers/concerns/rate_limit_headers_spec.rb'
- 'spec/controllers/instance_actors_controller_spec.rb'
- 'spec/controllers/settings/applications_controller_spec.rb'
- 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb'
- 'spec/controllers/statuses_controller_spec.rb'
- 'spec/helpers/admin/account_moderation_notes_helper_spec.rb'
- 'spec/helpers/jsonld_helper_spec.rb'
- 'spec/helpers/routing_helper_spec.rb'
- 'spec/lib/activitypub/activity/accept_spec.rb'
- 'spec/lib/activitypub/activity/announce_spec.rb'
- 'spec/lib/activitypub/activity/create_spec.rb'
- 'spec/lib/activitypub/activity/follow_spec.rb'
- 'spec/lib/activitypub/activity/reject_spec.rb'
- 'spec/lib/emoji_formatter_spec.rb'
- 'spec/lib/entity_cache_spec.rb'
- 'spec/lib/feed_manager_spec.rb'
- 'spec/lib/html_aware_formatter_spec.rb'
- 'spec/lib/link_details_extractor_spec.rb'
- 'spec/lib/ostatus/tag_manager_spec.rb'
- 'spec/lib/scope_transformer_spec.rb'
- 'spec/lib/status_cache_hydrator_spec.rb'
- 'spec/lib/status_reach_finder_spec.rb'
- 'spec/lib/text_formatter_spec.rb'
- 'spec/models/account/field_spec.rb'
- 'spec/models/account_spec.rb'
- 'spec/models/admin/account_action_spec.rb'
- 'spec/models/concerns/account_interactions_spec.rb'
- 'spec/models/concerns/remotable_spec.rb'
- 'spec/models/custom_emoji_filter_spec.rb'
- 'spec/models/custom_emoji_spec.rb'
- 'spec/models/email_domain_block_spec.rb'
- 'spec/models/media_attachment_spec.rb'
- 'spec/models/notification_spec.rb'
- 'spec/models/remote_follow_spec.rb'
- 'spec/models/report_spec.rb'
- 'spec/models/session_activation_spec.rb'
- 'spec/models/setting_spec.rb'
- 'spec/models/status_spec.rb'
- 'spec/models/web/push_subscription_spec.rb'
- 'spec/policies/account_moderation_note_policy_spec.rb'
- 'spec/policies/account_policy_spec.rb'
- 'spec/policies/backup_policy_spec.rb'
- 'spec/policies/custom_emoji_policy_spec.rb'
- 'spec/policies/domain_block_policy_spec.rb'
- 'spec/policies/email_domain_block_policy_spec.rb'
- 'spec/policies/instance_policy_spec.rb'
- 'spec/policies/invite_policy_spec.rb'
- 'spec/policies/relay_policy_spec.rb'
- 'spec/policies/report_note_policy_spec.rb'
- 'spec/policies/report_policy_spec.rb'
- 'spec/policies/settings_policy_spec.rb'
- 'spec/policies/tag_policy_spec.rb'
- 'spec/policies/user_policy_spec.rb'
- 'spec/presenters/account_relationships_presenter_spec.rb'
- 'spec/presenters/status_relationships_presenter_spec.rb'
- 'spec/services/account_search_service_spec.rb'
- 'spec/services/account_statuses_cleanup_service_spec.rb'
- 'spec/services/activitypub/fetch_remote_status_service_spec.rb'
- 'spec/services/activitypub/process_account_service_spec.rb'
- 'spec/services/activitypub/process_status_update_service_spec.rb'
- 'spec/services/fetch_link_card_service_spec.rb'
- 'spec/services/fetch_oembed_service_spec.rb'
- 'spec/services/fetch_remote_status_service_spec.rb'
- 'spec/services/follow_service_spec.rb'
- 'spec/services/import_service_spec.rb'
- 'spec/services/notify_service_spec.rb'
- 'spec/services/process_mentions_service_spec.rb'
- 'spec/services/reblog_service_spec.rb'
- 'spec/services/report_service_spec.rb'
- 'spec/services/resolve_account_service_spec.rb'
- 'spec/services/resolve_url_service_spec.rb'
- 'spec/services/search_service_spec.rb'
- 'spec/services/unallow_domain_service_spec.rb'
- 'spec/services/verify_link_service_spec.rb'
- 'spec/validators/disallowed_hashtags_validator_spec.rb'
- 'spec/validators/email_mx_validator_spec.rb'
- 'spec/validators/follow_limit_validator_spec.rb'
- 'spec/validators/poll_validator_spec.rb'
- 'spec/validators/status_pin_validator_spec.rb'
- 'spec/validators/unreserved_username_validator_spec.rb'
- 'spec/validators/url_validator_spec.rb'
- 'spec/workers/move_worker_spec.rb'
- 'spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb'
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SkipBlocks, EnforcedStyle.
# SupportedStyles: described_class, explicit

View File

@ -46,36 +46,36 @@ describe Rack::Attack, type: :request do
let(:remote_ip) { '1.2.3.5' }
describe 'throttle excessive sign-up requests by IP address' do
context 'through the website' do
context 'when accessed through the website' do
let(:limit) { 25 }
let(:period) { 5.minutes }
let(:request) { -> { post path, headers: { 'REMOTE_ADDR' => remote_ip } } }
context 'for exact path' do
context 'with exact path' do
let(:path) { '/auth' }
it_behaves_like 'throttled endpoint'
end
context 'for path with format' do
context 'with path with format' do
let(:path) { '/auth.html' }
it_behaves_like 'throttled endpoint'
end
end
context 'through the API' do
context 'when accessed through the API' do
let(:limit) { 5 }
let(:period) { 30.minutes }
let(:request) { -> { post path, headers: { 'REMOTE_ADDR' => remote_ip } } }
context 'for exact path' do
context 'with exact path' do
let(:path) { '/api/v1/accounts' }
it_behaves_like 'throttled endpoint'
end
context 'for path with format' do
context 'with path with format' do
let(:path) { '/api/v1/accounts.json' }
it 'returns http not found' do
@ -91,13 +91,13 @@ describe Rack::Attack, type: :request do
let(:period) { 5.minutes }
let(:request) { -> { post path, headers: { 'REMOTE_ADDR' => remote_ip } } }
context 'for exact path' do
context 'with exact path' do
let(:path) { '/auth/sign_in' }
it_behaves_like 'throttled endpoint'
end
context 'for path with format' do
context 'with path with format' do
let(:path) { '/auth/sign_in.html' }
it_behaves_like 'throttled endpoint'

View File

@ -57,7 +57,7 @@ RSpec.describe AccountsController, type: :controller do
end
end
context 'as HTML' do
context 'with HTML' do
let(:format) { 'html' }
it_behaves_like 'preliminary checks'
@ -140,7 +140,7 @@ RSpec.describe AccountsController, type: :controller do
end
end
context 'as JSON' do
context 'with JSON' do
let(:authorized_fetch_mode) { false }
let(:format) { 'json' }
@ -193,7 +193,7 @@ RSpec.describe AccountsController, type: :controller do
expect(json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
end
context 'in authorized fetch mode' do
context 'with authorized fetch mode' do
let(:authorized_fetch_mode) { true }
it 'returns http unauthorized' do
@ -251,7 +251,7 @@ RSpec.describe AccountsController, type: :controller do
expect(json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
end
context 'in authorized fetch mode' do
context 'with authorized fetch mode' do
let(:authorized_fetch_mode) { true }
it 'returns http success' do
@ -278,7 +278,7 @@ RSpec.describe AccountsController, type: :controller do
end
end
context 'as RSS' do
context 'with RSS' do
let(:format) { 'rss' }
it_behaves_like 'preliminary checks'

View File

@ -119,7 +119,7 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do
end
end
context 'in authorized fetch mode' do
context 'with authorized fetch mode' do
before do
allow(controller).to receive(:authorized_fetch_mode?).and_return(true)
end

View File

@ -21,7 +21,7 @@ RSpec.describe ActivityPub::InboxesController, type: :controller do
expect(response).to have_http_status(202)
end
context 'for a specific account' do
context 'with a specific account' do
subject(:response) { post :create, params: { account_username: account.username }, body: '{}' }
let(:account) { Fabricate(:account) }

View File

@ -83,7 +83,7 @@ RSpec.describe Admin::DomainBlocksController, type: :controller do
BlockDomainService.new.call(domain_block)
end
context 'downgrading a domain suspension to silence' do
context 'when downgrading a domain suspension to silence' do
let(:original_severity) { 'suspend' }
let(:new_severity) { 'silence' }
@ -100,7 +100,7 @@ RSpec.describe Admin::DomainBlocksController, type: :controller do
end
end
context 'upgrading a domain silence to suspend' do
context 'when upgrading a domain silence to suspend' do
let(:original_severity) { 'silence' }
let(:new_severity) { 'suspend' }

View File

@ -146,13 +146,13 @@ describe Admin::Reports::ActionsController do
end
end
context 'action as submit button' do
context 'with Action as submit button' do
subject { post :create, params: common_params.merge({ action => '' }) }
it_behaves_like 'all action types'
end
context 'action as submit button' do
context 'with Action as submit button' do
subject { post :create, params: common_params.merge({ moderation_action: action }) }
it_behaves_like 'all action types'

View File

@ -30,7 +30,7 @@ describe Admin::StatusesController do
end
end
context 'filtering by media' do
context 'when filtering by media' do
before do
get :index, params: { account_id: account.id, media: '1' }
end

View File

@ -21,7 +21,7 @@ describe Api::V1::Accounts::RelationshipsController do
lewis.follow!(user.account)
end
context 'provided only one ID' do
context 'when provided only one ID' do
before do
get :index, params: { id: simon.id }
end
@ -39,7 +39,7 @@ describe Api::V1::Accounts::RelationshipsController do
end
end
context 'provided multiple IDs' do
context 'when provided multiple IDs' do
before do
get :index, params: { id: [simon.id, lewis.id] }
end

View File

@ -30,7 +30,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
post :create, params: { username: 'test', password: '12345678', email: 'hello@world.tld', agreement: agreement }
end
context 'given truthy agreement' do
context 'when given truthy agreement' do
let(:agreement) { 'true' }
it 'returns http success' do
@ -48,7 +48,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
end
end
context 'given no agreement' do
context 'when given no agreement' do
it 'returns http unprocessable entity' do
expect(response).to have_http_status(422)
end
@ -121,7 +121,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
end
end
context 'modifying follow options' do
context 'when modifying follow options' do
let(:locked) { false }
before do

View File

@ -84,7 +84,7 @@ RSpec.describe Api::V1::Admin::DomainBlocksController, type: :controller do
BlockDomainService.new.call(domain_block)
end
context 'downgrading a domain suspension to silence' do
context 'when downgrading a domain suspension to silence' do
let(:original_severity) { 'suspend' }
let(:new_severity) { 'silence' }
@ -101,7 +101,7 @@ RSpec.describe Api::V1::Admin::DomainBlocksController, type: :controller do
end
end
context 'upgrading a domain silence to suspend' do
context 'when upgrading a domain silence to suspend' do
let(:original_severity) { 'silence' }
let(:new_severity) { 'suspend' }

View File

@ -15,14 +15,14 @@ RSpec.describe Api::V1::Emails::ConfirmationsController, type: :controller do
allow(controller).to receive(:doorkeeper_token) { token }
end
context 'from a random app' do
context 'when from a random app' do
it 'returns http forbidden' do
post :create
expect(response).to have_http_status(403)
end
end
context 'from an app that created the account' do
context 'when from an app that created the account' do
before do
user.update(created_by_application: token.application)
end
@ -35,7 +35,7 @@ RSpec.describe Api::V1::Emails::ConfirmationsController, type: :controller do
expect(response).to have_http_status(403)
end
context 'but user changed e-mail and has not confirmed it' do
context 'with user changed e-mail and has not confirmed it' do
before do
user.update(email: 'foo@bar.com')
end

View File

@ -9,7 +9,7 @@ RSpec.describe Api::V1::Instances::ActivityController, type: :controller do
expect(response).to have_http_status(200)
end
context '!Setting.activity_api_enabled' do
context 'with !Setting.activity_api_enabled' do
it 'returns 404' do
Setting.activity_api_enabled = false

View File

@ -9,7 +9,7 @@ RSpec.describe Api::V1::Instances::PeersController, type: :controller do
expect(response).to have_http_status(200)
end
context '!Setting.peers_api_enabled' do
context 'with !Setting.peers_api_enabled' do
it 'returns 404' do
Setting.peers_api_enabled = false

View File

@ -37,7 +37,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do
end
end
context 'image/jpeg' do
context 'with image/jpeg' do
before do
post :create, params: { file: fixture_file_upload('attachment.jpg', 'image/jpeg') }
end
@ -59,7 +59,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do
end
end
context 'image/gif' do
context 'with image/gif' do
before do
post :create, params: { file: fixture_file_upload('attachment.gif', 'image/gif') }
end
@ -81,7 +81,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do
end
end
context 'video/webm' do
context 'with video/webm' do
before do
post :create, params: { file: fixture_file_upload('attachment.webm', 'video/webm') }
end

View File

@ -66,7 +66,7 @@ RSpec.describe Api::V2::FiltersController, type: :controller do
let!(:filter) { Fabricate(:custom_filter, account: user.account) }
let!(:keyword) { Fabricate(:custom_filter_keyword, custom_filter: filter) }
context 'updating filter parameters' do
context 'when updating filter parameters' do
before do
put :update, params: { id: filter.id, title: 'updated', context: %w(home public) }
end
@ -84,7 +84,7 @@ RSpec.describe Api::V2::FiltersController, type: :controller do
end
end
context 'updating keywords in bulk' do
context 'when updating keywords in bulk' do
before do
allow(redis).to receive_messages(publish: nil)
put :update, params: { id: filter.id, keywords_attributes: [{ id: keyword.id, keyword: 'updated' }] }

View File

@ -32,7 +32,7 @@ describe ApplicationController, type: :controller do
end
end
context 'forgery' do
context 'with a forgery' do
subject do
ActionController::Base.allow_forgery_protection = true
routes.draw { post 'success' => 'anonymous#success' }
@ -105,7 +105,7 @@ describe ApplicationController, type: :controller do
end
end
context 'ActionController::RoutingError' do
context 'with ActionController::RoutingError' do
subject do
routes.draw { get 'routing_error' => 'anonymous#routing_error' }
get 'routing_error'
@ -114,7 +114,7 @@ describe ApplicationController, type: :controller do
include_examples 'respond_with_error', 404
end
context 'ActiveRecord::RecordNotFound' do
context 'with ActiveRecord::RecordNotFound' do
subject do
routes.draw { get 'record_not_found' => 'anonymous#record_not_found' }
get 'record_not_found'
@ -123,7 +123,7 @@ describe ApplicationController, type: :controller do
include_examples 'respond_with_error', 404
end
context 'ActionController::InvalidAuthenticityToken' do
context 'with ActionController::InvalidAuthenticityToken' do
subject do
routes.draw { get 'invalid_authenticity_token' => 'anonymous#invalid_authenticity_token' }
get 'invalid_authenticity_token'
@ -252,7 +252,7 @@ describe ApplicationController, type: :controller do
expect(subject.new.cache_collection(raw, Object)).to eq raw
end
context 'Status' do
context 'with a Status' do
include_examples 'cacheable', :status, Status
end
end

View File

@ -157,7 +157,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
end
end
context 'approval-based registrations without invite' do
context 'with Approval-based registrations without invite' do
subject do
Setting.registrations_mode = 'approved'
request.headers['Accept-Language'] = accept_language
@ -184,7 +184,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
end
end
context 'approval-based registrations with expired invite' do
context 'with Approval-based registrations with expired invite' do
subject do
Setting.registrations_mode = 'approved'
request.headers['Accept-Language'] = accept_language
@ -212,7 +212,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
end
end
context 'approval-based registrations with valid invite and required invite text' do
context 'with Approval-based registrations with valid invite and required invite text' do
subject do
inviter = Fabricate(:user, confirmed_at: 2.days.ago)
Setting.registrations_mode = 'approved'

View File

@ -51,8 +51,8 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
describe 'POST #create' do
context 'using PAM authentication', if: ENV['PAM_ENABLED'] == 'true' do
context 'using a valid password' do
context 'when using PAM authentication', if: ENV['PAM_ENABLED'] == 'true' do
context 'when using a valid password' do
before do
post :create, params: { user: { email: 'pam_user1', password: '123456' } }
end
@ -66,7 +66,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using an invalid password' do
context 'when using an invalid password' do
before do
post :create, params: { user: { email: 'pam_user1', password: 'WRONGPW' } }
end
@ -80,7 +80,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using a valid email and existing user' do
context 'when using a valid email and existing user' do
let!(:user) do
account = Fabricate.build(:account, username: 'pam_user1', user: nil)
account.save!(validate: false)
@ -102,10 +102,10 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using password authentication' do
context 'when using password authentication' do
let(:user) { Fabricate(:user, email: 'foo@bar.com', password: 'abcdefgh') }
context 'using a valid password' do
context 'when using a valid password' do
before do
post :create, params: { user: { email: user.email, password: user.password } }
end
@ -119,7 +119,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using a valid password on a previously-used account with a new IP address' do
context 'when using a valid password on a previously-used account with a new IP address' do
let(:previous_ip) { '1.2.3.4' }
let(:current_ip) { '4.3.2.1' }
@ -145,7 +145,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using email with uppercase letters' do
context 'when using email with uppercase letters' do
before do
post :create, params: { user: { email: user.email.upcase, password: user.password } }
end
@ -159,7 +159,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using an invalid password' do
context 'when using an invalid password' do
before do
post :create, params: { user: { email: user.email, password: 'wrongpw' } }
end
@ -173,7 +173,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using an unconfirmed password' do
context 'when using an unconfirmed password' do
before do
request.headers['Accept-Language'] = accept_language
post :create, params: { user: { email: unconfirmed_user.email, password: unconfirmed_user.password } }
@ -187,14 +187,14 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context "logging in from the user's page" do
context "when logging in from the user's page" do
before do
allow(controller).to receive(:single_user_mode?).and_return(single_user_mode)
allow(controller).to receive(:stored_location_for).with(:user).and_return("/@#{user.account.username}")
post :create, params: { user: { email: user.email, password: user.password } }
end
context 'in single user mode' do
context 'with single user mode' do
let(:single_user_mode) { true }
it 'redirects to home' do
@ -202,7 +202,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'in non-single user mode' do
context 'with non-single user mode' do
let(:single_user_mode) { false }
it "redirects back to the user's page" do
@ -212,7 +212,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using two-factor authentication' do
context 'when using two-factor authentication' do
context 'with OTP enabled as second factor' do
let!(:user) do
Fabricate(:user, email: 'x@y.com', password: 'abcdefgh', otp_required_for_login: true, otp_secret: User.generate_otp_secret(32))
@ -224,7 +224,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
return codes
end
context 'using email and password' do
context 'when using email and password' do
before do
post :create, params: { user: { email: user.email, password: user.password } }
end
@ -235,7 +235,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using email and password after an unfinished log-in attempt to a 2FA-protected account' do
context 'when using email and password after an unfinished log-in attempt to a 2FA-protected account' do
let!(:other_user) do
Fabricate(:user, email: 'z@y.com', password: 'abcdefgh', otp_required_for_login: true, otp_secret: User.generate_otp_secret(32))
end
@ -251,7 +251,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using upcase email and password' do
context 'when using upcase email and password' do
before do
post :create, params: { user: { email: user.email.upcase, password: user.password } }
end
@ -262,7 +262,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using a valid OTP' do
context 'when using a valid OTP' do
before do
post :create, params: { user: { otp_attempt: user.current_otp } }, session: { attempt_user_id: user.id, attempt_user_updated_at: user.updated_at.to_s }
end
@ -291,7 +291,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using a valid recovery code' do
context 'when using a valid recovery code' do
before do
post :create, params: { user: { otp_attempt: recovery_codes.first } }, session: { attempt_user_id: user.id, attempt_user_updated_at: user.updated_at.to_s }
end
@ -305,7 +305,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using an invalid OTP' do
context 'when using an invalid OTP' do
before do
post :create, params: { user: { otp_attempt: 'wrongotp' } }, session: { attempt_user_id: user.id, attempt_user_updated_at: user.updated_at.to_s }
end
@ -353,7 +353,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
let(:fake_credential) { fake_client.get(challenge: challenge, sign_count: sign_count) }
context 'using email and password' do
context 'when using email and password' do
before do
post :create, params: { user: { email: user.email, password: user.password } }
end
@ -364,7 +364,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using upcase email and password' do
context 'when using upcase email and password' do
before do
post :create, params: { user: { email: user.email.upcase, password: user.password } }
end
@ -375,7 +375,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
end
context 'using a valid webauthn credential' do
context 'when using a valid webauthn credential' do
before do
@controller.session[:webauthn_challenge] = challenge

View File

@ -23,14 +23,14 @@ RSpec.describe CacheConcern, type: :controller do
end
describe '#cache_collection' do
context 'given an empty array' do
context 'when given an empty array' do
it 'returns an empty array' do
get :empty_array
expect(response.body).to eq '0'
end
end
context 'given an empty relation' do
context 'when given an empty relation' do
it 'returns an empty array' do
get :empty_relation
expect(response.body).to eq '0'

View File

@ -31,7 +31,7 @@ RSpec.describe ChallengableConcern, type: :controller do
sign_in user
end
context 'for GET requests' do
context 'with GET requests' do
before { get :foo }
it 'does not ask for password' do
@ -39,7 +39,7 @@ RSpec.describe ChallengableConcern, type: :controller do
end
end
context 'for POST requests' do
context 'with POST requests' do
before { post :bar }
it 'does not ask for password' do
@ -56,7 +56,7 @@ RSpec.describe ChallengableConcern, type: :controller do
sign_in user
end
context 'for GET requests' do
context 'with GET requests' do
before { get :foo, session: { challenge_passed_at: Time.now.utc } }
it 'does not ask for password' do
@ -64,7 +64,7 @@ RSpec.describe ChallengableConcern, type: :controller do
end
end
context 'for POST requests' do
context 'with POST requests' do
before { post :bar, session: { challenge_passed_at: Time.now.utc } }
it 'does not ask for password' do
@ -81,7 +81,7 @@ RSpec.describe ChallengableConcern, type: :controller do
sign_in user
end
context 'for GET requests' do
context 'with GET requests' do
before { get :foo }
it 'renders challenge' do
@ -91,7 +91,7 @@ RSpec.describe ChallengableConcern, type: :controller do
# See Auth::ChallengesControllerSpec
end
context 'for POST requests' do
context 'with POST requests' do
before { post :bar }
it 'renders challenge' do

View File

@ -41,7 +41,7 @@ describe ApplicationController, type: :controller do
end
end
context 'user with valid locale has signed in' do
context 'with a user with valid locale has signed in' do
it "sets user's locale" do
user = Fabricate(:user, locale: :ca)
@ -52,7 +52,7 @@ describe ApplicationController, type: :controller do
end
end
context 'user with invalid locale has signed in' do
context 'with a user with invalid locale has signed in' do
before do
user = Fabricate.build(:user, locale: :invalid)
user.save!(validate: false)
@ -62,7 +62,7 @@ describe ApplicationController, type: :controller do
include_examples 'default locale'
end
context 'user has not signed in' do
context 'with a user who has not signed in' do
include_examples 'default locale'
end
end

View File

@ -16,7 +16,7 @@ describe ApplicationController do
end
describe 'rate limiting' do
context 'throttling is off' do
context 'when throttling is off' do
before do
request.env['rack.attack.throttle_data'] = nil
end
@ -30,7 +30,7 @@ describe ApplicationController do
end
end
context 'throttling is on' do
context 'when throttling is on' do
let(:start_time) { DateTime.new(2017, 1, 1, 12, 0, 0).utc }
before do

View File

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe InstanceActorsController, type: :controller do
describe 'GET #show' do
context 'as JSON' do
context 'with JSON' do
let(:format) { 'json' }
shared_examples 'shared behavior' do

View File

@ -50,7 +50,7 @@ describe Settings::ApplicationsController do
end
describe 'POST #create' do
context 'success (passed scopes as a String)' do
context 'when success (passed scopes as a String)' do
def call_create
post :create, params: {
doorkeeper_application: {
@ -72,7 +72,7 @@ describe Settings::ApplicationsController do
end
end
context 'success (passed scopes as an Array)' do
context 'when success (passed scopes as an Array)' do
def call_create
post :create, params: {
doorkeeper_application: {
@ -94,7 +94,7 @@ describe Settings::ApplicationsController do
end
end
context 'failure' do
context 'with failure request' do
before do
post :create, params: {
doorkeeper_application: {
@ -117,7 +117,7 @@ describe Settings::ApplicationsController do
end
describe 'PATCH #update' do
context 'success' do
context 'when success' do
let(:opts) do
{
website: 'https://foo.bar/',
@ -142,7 +142,7 @@ describe Settings::ApplicationsController do
end
end
context 'failure' do
context 'with failure request' do
before do
patch :update, params: {
id: app.id,

View File

@ -275,7 +275,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
end
context 'when user have not enabled webauthn' do
context 'creation succeeds' do
context 'when creation succeeds' do
it 'creates a webauthn credential' do
@controller.session[:webauthn_challenge] = challenge

View File

@ -72,7 +72,7 @@ describe StatusesController do
get :show, params: { account_username: status.account.username, id: status.id, format: format }
end
context 'as HTML' do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http success' do
@ -97,7 +97,7 @@ describe StatusesController do
end
end
context 'as JSON' do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http success' do
@ -132,7 +132,7 @@ describe StatusesController do
get :show, params: { account_username: status.account.username, id: status.id, format: format }
end
context 'as JSON' do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http not found' do
@ -140,7 +140,7 @@ describe StatusesController do
end
end
context 'as HTML' do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http not found' do
@ -156,7 +156,7 @@ describe StatusesController do
get :show, params: { account_username: status.account.username, id: status.id, format: format }
end
context 'as JSON' do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http not found' do
@ -164,7 +164,7 @@ describe StatusesController do
end
end
context 'as HTML' do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http not found' do
@ -196,7 +196,7 @@ describe StatusesController do
get :show, params: { account_username: status.account.username, id: status.id, format: format }
end
context 'as HTML' do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http success' do
@ -221,7 +221,7 @@ describe StatusesController do
end
end
context 'as JSON' do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http success' do
@ -260,7 +260,7 @@ describe StatusesController do
get :show, params: { account_username: status.account.username, id: status.id, format: format }
end
context 'as HTML' do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http success' do
@ -285,7 +285,7 @@ describe StatusesController do
end
end
context 'as JSON' do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http success' do
@ -320,7 +320,7 @@ describe StatusesController do
get :show, params: { account_username: status.account.username, id: status.id, format: format }
end
context 'as JSON' do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http not found' do
@ -328,7 +328,7 @@ describe StatusesController do
end
end
context 'as HTML' do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http not found' do
@ -347,7 +347,7 @@ describe StatusesController do
get :show, params: { account_username: status.account.username, id: status.id, format: format }
end
context 'as HTML' do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http success' do
@ -372,7 +372,7 @@ describe StatusesController do
end
end
context 'as JSON' do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http success' do
@ -407,7 +407,7 @@ describe StatusesController do
get :show, params: { account_username: status.account.username, id: status.id, format: format }
end
context 'as JSON' do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http not found' do
@ -415,7 +415,7 @@ describe StatusesController do
end
end
context 'as HTML' do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http not found' do
@ -460,7 +460,7 @@ describe StatusesController do
get :show, params: { account_username: status.account.username, id: status.id, format: format }
end
context 'as HTML' do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http success' do
@ -485,7 +485,7 @@ describe StatusesController do
end
end
context 'as JSON' do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http success' do
@ -522,7 +522,7 @@ describe StatusesController do
get :show, params: { account_username: status.account.username, id: status.id, format: format }
end
context 'as HTML' do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http success' do
@ -547,7 +547,7 @@ describe StatusesController do
end
end
context 'as JSON' do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http success' do
@ -582,7 +582,7 @@ describe StatusesController do
get :show, params: { account_username: status.account.username, id: status.id, format: format }
end
context 'as JSON' do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http not found' do
@ -590,7 +590,7 @@ describe StatusesController do
end
end
context 'as HTML' do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http not found' do
@ -609,7 +609,7 @@ describe StatusesController do
get :show, params: { account_username: status.account.username, id: status.id, format: format }
end
context 'as HTML' do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http success' do
@ -634,7 +634,7 @@ describe StatusesController do
end
end
context 'as JSON' do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http success' do
@ -669,7 +669,7 @@ describe StatusesController do
get :show, params: { account_username: status.account.username, id: status.id, format: format }
end
context 'as JSON' do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http not found' do
@ -677,7 +677,7 @@ describe StatusesController do
end
end
context 'as HTML' do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http not found' do

View File

@ -6,7 +6,7 @@ RSpec.describe Admin::AccountModerationNotesHelper, type: :helper do
include AccountsHelper
describe '#admin_account_link_to' do
context 'account is nil' do
context 'when Account is nil' do
let(:account) { nil }
it 'returns nil' do
@ -30,7 +30,7 @@ RSpec.describe Admin::AccountModerationNotesHelper, type: :helper do
end
describe '#admin_account_inline_link_to' do
context 'account is nil' do
context 'when Account is nil' do
let(:account) { nil }
it 'returns nil' do

View File

@ -22,14 +22,14 @@ describe JsonLdHelper do
end
describe '#first_of_value' do
context 'value.is_a?(Array)' do
context 'when value.is_a?(Array)' do
it 'returns value.first' do
value = ['a']
expect(helper.first_of_value(value)).to be 'a'
end
end
context '!value.is_a?(Array)' do
context 'with !value.is_a?(Array)' do
it 'returns value' do
value = 'a'
expect(helper.first_of_value(value)).to be 'a'
@ -38,14 +38,14 @@ describe JsonLdHelper do
end