0
0
Fork 0

Fix RSpec/ContextWording cop (#24739)

This commit is contained in:
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

@ -49,10 +49,10 @@ RSpec.describe Account::Field, type: :model do
let(:account) { double('Account', local?: local) }
context 'for local accounts' do
context 'with local accounts' do
let(:local) { true }
context 'for a URL with misleading authentication' do
context 'with a URL with misleading authentication' do
let(:value) { 'https://spacex.com @h.43z.one' }
it 'returns false' do
@ -60,7 +60,7 @@ RSpec.describe Account::Field, type: :model do
end
end
context 'for a URL' do
context 'with a URL' do
let(:value) { 'https://example.com' }
it 'returns true' do
@ -68,7 +68,7 @@ RSpec.describe Account::Field, type: :model do
end
end
context 'for an IDN URL' do
context 'with an IDN URL' do
let(:value) { 'https://twitter.comdougalljstatus1590357240443437057.ê.cc/twitter.html' }
it 'returns false' do
@ -76,7 +76,7 @@ RSpec.describe Account::Field, type: :model do
end
end
context 'for a URL with a non-normalized path' do
context 'with a URL with a non-normalized path' do
let(:value) { 'https://github.com/octocatxxxxxxxx/../mastodon' }
it 'returns false' do
@ -84,7 +84,7 @@ RSpec.describe Account::Field, type: :model do
end
end
context 'for text that is not a URL' do
context 'with text that is not a URL' do
let(:value) { 'Hello world' }
it 'returns false' do
@ -92,7 +92,7 @@ RSpec.describe Account::Field, type: :model do
end
end
context 'for text that contains a URL' do
context 'with text that contains a URL' do
let(:value) { 'Hello https://example.com world' }
it 'returns false' do
@ -100,7 +100,7 @@ RSpec.describe Account::Field, type: :model do
end
end
context 'for text which is blank' do
context 'with text which is blank' do
let(:value) { '' }
it 'returns false' do
@ -109,10 +109,10 @@ RSpec.describe Account::Field, type: :model do
end
end
context 'for remote accounts' do
context 'with remote accounts' do
let(:local) { false }
context 'for a link' do
context 'with a link' do
let(:value) { '<a href="https://www.patreon.com/mastodon" target="_blank" rel="nofollow noopener noreferrer me"><span class="invisible">https://www.</span><span class="">patreon.com/mastodon</span><span class="invisible"></span></a>' }
it 'returns true' do
@ -120,7 +120,7 @@ RSpec.describe Account::Field, type: :model do
end
end
context 'for a link with misleading authentication' do
context 'with a link with misleading authentication' do
let(:value) { '<a href="https://google.com @h.43z.one" target="_blank" rel="nofollow noopener noreferrer me"><span class="invisible">https://</span><span class="">google.com</span><span class="invisible"> @h.43z.one</span></a>' }
it 'returns false' do
@ -128,7 +128,7 @@ RSpec.describe Account::Field, type: :model do
end
end
context 'for HTML that has more than just a link' do
context 'with HTML that has more than just a link' do
let(:value) { '<a href="https://google.com" target="_blank" rel="nofollow noopener noreferrer me"><span class="invisible">https://</span><span class="">google.com</span><span class="invisible"></span></a> @h.43z.one' }
it 'returns false' do
@ -136,7 +136,7 @@ RSpec.describe Account::Field, type: :model do
end
end
context 'for a link with different visible text' do
context 'with a link with different visible text' do
let(:value) { '<a href="https://google.com/bar">https://example.com/foo</a>' }
it 'returns false' do
@ -144,7 +144,7 @@ RSpec.describe Account::Field, type: :model do
end
end
context 'for text that is a URL but is not linked' do
context 'with text that is a URL but is not linked' do
let(:value) { 'https://example.com/foo' }
it 'returns false' do
@ -152,7 +152,7 @@ RSpec.describe Account::Field, type: :model do
end
end
context 'for text which is blank' do
context 'with text which is blank' do
let(:value) { '' }
it 'returns false' do

View file

@ -171,7 +171,7 @@ RSpec.describe Account, type: :model do
describe '#possibly_stale?' do
let(:account) { Fabricate(:account, last_webfingered_at: last_webfingered_at) }
context 'last_webfingered_at is nil' do
context 'when last_webfingered_at is nil' do
let(:last_webfingered_at) { nil }
it 'returns true' do
@ -179,7 +179,7 @@ RSpec.describe Account, type: :model do
end
end
context 'last_webfingered_at is more than 24 hours before' do
context 'when last_webfingered_at is more than 24 hours before' do
let(:last_webfingered_at) { 25.hours.ago }
it 'returns true' do
@ -187,7 +187,7 @@ RSpec.describe Account, type: :model do
end
end
context 'last_webfingered_at is less than 24 hours before' do
context 'when last_webfingered_at is less than 24 hours before' do
let(:last_webfingered_at) { 23.hours.ago }
it 'returns false' do
@ -200,7 +200,7 @@ RSpec.describe Account, type: :model do
let(:account) { Fabricate(:account, domain: domain) }
let(:acct) { account.acct }
context 'domain is nil' do
context 'when domain is nil' do
let(:domain) { nil }
it 'returns nil' do
@ -213,7 +213,7 @@ RSpec.describe Account, type: :model do
end
end
context 'domain is present' do
context 'when domain is present' do
let(:domain) { 'example.com' }
it 'calls ResolveAccountService#call' do

View file

@ -20,7 +20,7 @@ RSpec.describe Admin::AccountAction, type: :model do
)
end
context 'type is "disable"' do
context 'when type is "disable"' do
let(:type) { 'disable' }
it 'disable user' do
@ -29,7 +29,7 @@ RSpec.describe Admin::AccountAction, type: :model do
end
end
context 'type is "silence"' do
context 'when type is "silence"' do
let(:type) { 'silence' }
it 'silences account' do
@ -38,7 +38,7 @@ RSpec.describe Admin::AccountAction, type: :model do
end
end
context 'type is "suspend"' do
context 'when type is "suspend"' do
let(:type) { 'suspend' }
it 'suspends account' do
@ -75,7 +75,7 @@ RSpec.describe Admin::AccountAction, type: :model do
describe '#report' do
subject { account_action.report }
context 'report_id.present?' do
context 'with report_id.present?' do
before do
account_action.report_id = Fabricate(:report).id
end
@ -85,7 +85,7 @@ RSpec.describe Admin::AccountAction, type: :model do
end
end
context '!report_id.present?' do
context 'with !report_id.present?' do
it 'returns nil' do
expect(subject).to be_nil
end
@ -95,7 +95,7 @@ RSpec.describe Admin::AccountAction, type: :model do
describe '#with_report?' do
subject { account_action.with_report? }
context '!report.nil?' do
context 'with !report.nil?' do
before do
account_action.report_id = Fabricate(:report).id
end
@ -105,7 +105,7 @@ RSpec.describe Admin::AccountAction, type: :model do
end
end
context '!(!report.nil?)' do
context 'with !(!report.nil?)' do
it 'returns false' do
expect(subject).to be false
end
@ -115,7 +115,7 @@ RSpec.describe Admin::AccountAction, type: :model do
describe '.types_for_account' do
subject { described_class.types_for_account(account) }
context 'account.local?' do
context 'when Account.local?' do
let(:account) { Fabricate(:account, domain: nil) }
it 'returns ["none", "disable", "sensitive", "silence", "suspend"]' do
@ -123,7 +123,7 @@ RSpec.describe Admin::AccountAction, type: :model do
end
end
context '!account.local?' do
context 'with !account.local?' do
let(:account) { Fabricate(:account, domain: 'hoge.com') }
it 'returns ["sensitive", "silence", "suspend"]' do

View file

@ -13,14 +13,14 @@ describe AccountInteractions do
describe '.following_map' do
subject { Account.following_map(target_account_ids, account_id) }
context 'account with Follow' do
context 'when Account with Follow' do
it 'returns { target_account_id => true }' do
Fabricate(:follow, account: account, target_account: target_account)
expect(subject).to eq(target_account_id => { reblogs: true, notify: false, languages: nil })
end
end
context 'account without Follow' do
context 'when Account without Follow' do
it 'returns {}' do
expect(subject).to eq({})
end
@ -30,14 +30,14 @@ describe AccountInteractions do
describe '.followed_by_map' do
subject { Account.followed_by_map(target_account_ids, account_id) }
context 'account with Follow' do
context 'when Account with Follow' do
it 'returns { target_account_id => true }' do
Fabricate(:follow, account: target_account, target_account: account)
expect(subject).to eq(target_account_id => true)
end
end
context 'account without Follow' do
context 'when Account without Follow' do
it 'returns {}' do
expect(subject).to eq({})
end
@ -47,14 +47,14 @@ describe AccountInteractions do
describe '.blocking_map' do
subject { Account.blocking_map(target_account_ids, account_id) }
context 'account with Block' do
context 'when Account with Block' do
it 'returns { target_account_id => true }' do
Fabricate(:block, account: account, target_account: target_account)
expect(subject).to eq(target_account_id => true)
end
end
context 'account without Block' do
context 'when Account without Block' do
it 'returns {}' do
expect(subject).to eq({})
end
@ -64,12 +64,12 @@ describe AccountInteractions do
describe '.muting_map' do
subject { Account.muting_map(target_account_ids, account_id) }
context 'account with Mute' do
context 'when Account with Mute' do
before do
Fabricate(:mute, target_account: target_account, account: account, hide_notifications: hide)
end
context 'if Mute#hide_notifications?' do
context 'when Mute#hide_notifications?' do
let(:hide) { true }
it 'returns { target_account_id => { notifications: true } }' do
@ -77,7 +77,7 @@ describe AccountInteractions do
end
end
context 'unless Mute#hide_notifications?' do
context 'when not Mute#hide_notifications?' do
let(:hide) { false }
it 'returns { target_account_id => { notifications: false } }' do
@ -86,7 +86,7 @@ describe AccountInteractions do
end
end
context 'account without Mute' do
context 'when Account without Mute' do
it 'returns {}' do
expect(subject).to eq({})
end
@ -112,8 +112,8 @@ describe AccountInteractions do
describe '#mute!' do
subject { account.mute!(target_account, notifications: arg_notifications) }
context 'Mute does not exist yet' do
context 'arg :notifications is nil' do
context 'when Mute does not exist yet' do
context 'when arg :notifications is nil' do
let(:arg_notifications) { nil }
it 'creates Mute, and returns Mute' do
@ -123,7 +123,7 @@ describe AccountInteractions do
end
end
context 'arg :notifications is false' do
context 'when arg :notifications is false' do
let(:arg_notifications) { false }
it 'creates Mute, and returns Mute' do
@ -133,7 +133,7 @@ describe AccountInteractions do
end
end
context 'arg :notifications is true' do
context 'when arg :notifications is true' do
let(:arg_notifications) { true }
it 'creates Mute, and returns Mute' do
@ -144,7 +144,7 @@ describe AccountInteractions do
end
end
context 'Mute already exists' do
context 'when Mute already exists' do
before do
account.mute_relationships << mute
end
@ -156,10 +156,10 @@ describe AccountInteractions do
hide_notifications: hide_notifications)
end
context 'mute.hide_notifications is true' do
context 'when mute.hide_notifications is true' do
let(:hide_notifications) { true }
context 'arg :notifications is nil' do
context 'when arg :notifications is nil' do
let(:arg_notifications) { nil }
it 'returns Mute without updating mute.hide_notifications' do
@ -169,7 +169,7 @@ describe AccountInteractions do
end
end
context 'arg :notifications is false' do
context 'when arg :notifications is false' do
let(:arg_notifications) { false }
it 'returns Mute, and updates mute.hide_notifications false' do
@ -179,7 +179,7 @@ describe AccountInteractions do
end
end
context 'arg :notifications is true' do
context 'when arg :notifications is true' do
let(:arg_notifications) { true }
it 'returns Mute without updating mute.hide_notifications' do
@ -190,10 +190,10 @@ describe AccountInteractions do
end
end
context 'mute.hide_notifications is false' do
context 'when mute.hide_notifications is false' do
let(:hide_notifications) { false }
context 'arg :notifications is nil' do
context 'when arg :notifications is nil' do
let(:arg_notifications) { nil }
it 'returns Mute, and updates mute.hide_notifications true' do
@ -203,7 +203,7 @@ describe AccountInteractions do
end
end
context 'arg :notifications is false' do
context 'when arg :notifications is false' do
let(:arg_notifications) { false }
it 'returns Mute without updating mute.hide_notifications' do
@ -213,7 +213,7 @@ describe AccountInteractions do
end
end
context 'arg :notifications is true' do
context 'when arg :notifications is true' do
let(:arg_notifications) { true }
it 'returns Mute, and updates mute.hide_notifications true' do
@ -253,7 +253,7 @@ describe AccountInteractions do
describe '#unfollow!' do
subject { account.unfollow!(target_account) }
context 'following target_account' do
context 'when following target_account' do
it 'returns destroyed Follow' do
account.active_relationships.create(target_account: target_account)
expect(subject).to be_a Follow
@ -261,7 +261,7 @@ describe AccountInteractions do
end
end
context 'not following target_account' do
context 'when not following target_account' do
it 'returns nil' do
expect(subject).to be_nil
end
@ -271,7 +271,7 @@ describe AccountInteractions do
describe '#unblock!' do
subject { account.unblock!(target_account) }
context 'blocking target_account' do
context 'when blocking target_account' do
it 'returns destroyed Block' do
account.block_relationships.create(target_account: target_account)
expect(subject).to be_a Block
@ -279,7 +279,7 @@ describe AccountInteractions do
end
end
context 'not blocking target_account' do
context 'when not blocking target_account' do
it 'returns nil' do
expect(subject).to be_nil
end
@ -289,7 +289,7 @@ describe AccountInteractions do
describe '#unmute!' do
subject { account.unmute!(target_account) }
context 'muting target_account' do
context 'when muting target_account' do
it 'returns destroyed Mute' do
account.mute_relationships.create(target_account: target_account)
expect(subject).to be_a Mute
@ -297,7 +297,7 @@ describe AccountInteractions do
end
end
context 'not muting target_account' do
context 'when not muting target_account' do
it 'returns nil' do
expect(subject).to be_nil
end
@ -309,7 +309,7 @@ describe AccountInteractions do
let(:conversation) { Fabricate(:conversation) }
context 'muting the conversation' do
context 'when muting the conversation' do
it 'returns destroyed ConversationMute' do
account.conversation_mutes.create(conversation: conversation)
expect(subject).to be_a ConversationMute
@ -317,7 +317,7 @@ describe AccountInteractions do
end
end
context 'not muting the conversation' do
context 'when not muting the conversation' do
it 'returns nil' do
expect(subject).to be_nil
end
@ -329,7 +329,7 @@ describe AccountInteractions do
let(:domain) { 'example.com' }
context 'blocking the domain' do
context 'when blocking the domain' do
it 'returns destroyed AccountDomainBlock' do
account_domain_block = Fabricate(:account_domain_block, domain: domain)
account.domain_blocks << account_domain_block
@ -338,7 +338,7 @@ describe AccountInteractions do
end
end
context 'unblocking the domain' do
context 'when unblocking the domain' do
it 'returns nil' do
expect(subject).to be_nil
end
@ -348,14 +348,14 @@ describe AccountInteractions do
describe '#following?' do
subject { account.following?(target_account) }
context 'following target_account' do
context 'when following target_account' do
it 'returns true' do
account.active_relationships.create(target_account: target_account)
expect(subject).to be true
end
end
context 'not following target_account' do
context 'when not following target_account' do
it 'returns false' do
expect(subject).to be false
end
@ -365,14 +365,14 @@ describe AccountInteractions do
describe '#followed_by?' do
subject { account.followed_by?(target_account) }
context 'followed by target_account' do
context 'when followed by target_account' do
it 'returns true' do
account.passive_relationships.create(account: target_account)
expect(subject).to be true
end
end
context 'not followed by target_account' do
context 'when not followed by target_account' do
it 'returns false' do
expect(subject).to be false
end
@ -382,14 +382,14 @@ describe AccountInteractions do
describe '#blocking?' do
subject { account.blocking?(target_account) }
context 'blocking target_account' do
context 'when blocking target_account' do
it 'returns true' do
account.block_relationships.create(target_account: target_account)
expect(subject).to be true
end
end
context 'not blocking target_account' do
context 'when not blocking target_account' do
it 'returns false' do
expect(subject).to be false
end
@ -401,7 +401,7 @@ describe AccountInteractions do
let(:domain) { 'example.com' }
context 'blocking the domain' do
context 'when blocking the domain' do
it 'returns true' do
account_domain_block = Fabricate(:account_domain_block, domain: domain)
account.domain_blocks << account_domain_block
@ -409,7 +409,7 @@ describe AccountInteractions do
end
end
context 'not blocking the domain' do
context 'when not blocking the domain' do
it 'returns false' do
expect(subject).to be false
end
@ -419,7 +419,7 @@ describe AccountInteractions do
describe '#muting?' do
subject { account.muting?(target_account) }
context 'muting target_account' do
context 'when muting target_account' do
it 'returns true' do
mute = Fabricate(:mute, account: account, target_account: target_account)
account.mute_relationships << mute
@ -427,7 +427,7 @@ describe AccountInteractions do
end
end
context 'not muting target_account' do
context 'when not muting target_account' do
it 'returns false' do
expect(subject).to be false
end
@ -439,14 +439,14 @@ describe AccountInteractions do
let(:conversation) { Fabricate(:conversation) }
context 'muting the conversation' do
context 'when muting the conversation' do
it 'returns true' do
account.conversation_mutes.create(conversation: conversation)
expect(subject).to be true
end
end
context 'not muting the conversation' do
context 'when not muting the conversation' do
it 'returns false' do
expect(subject).to be false
end
@ -461,7 +461,7 @@ describe AccountInteractions do
account.mute_relationships << mute
end
context 'muting notifications of target_account' do
context 'when muting notifications of target_account' do
let(:hide) { true }
it 'returns true' do
@ -469,7 +469,7 @@ describe AccountInteractions do
end
end
context 'not muting notifications of target_account' do
context 'when not muting notifications of target_account' do
let(:hide) { false }
it 'returns false' do
@ -481,14 +481,14 @@ describe AccountInteractions do
describe '#requested?' do
subject { account.requested?(target_account) }
context 'requested by target_account' do
context 'with requested by target_account' do
it 'returns true' do
Fabricate(:follow_request, account: account, target_account: target_account)
expect(subject).to be true
end
end
context 'not requested by target_account' do
context 'when not requested by target_account' do
it 'returns false' do
expect(subject).to be false
end
@ -500,7 +500,7 @@ describe AccountInteractions do
let(:status) { Fabricate(:status, account: account, favourites: favourites) }
context 'favorited' do
context 'when favorited' do
let(:favourites) { [Fabricate(:favourite, account: account)] }
it 'returns true' do
@ -508,7 +508,7 @@ describe AccountInteractions do
end
end
context 'not favorited' do
context 'when not favorited' do
let(:favourites) { [] }
it 'returns false' do
@ -522,7 +522,7 @@ describe AccountInteractions do
let(:status) { Fabricate(:status, account: account, reblogs: reblogs) }
context 'reblogged' do
context 'with reblogged' do
let(:reblogs) { [Fabricate(:status, account: account)] }
it 'returns true' do
@ -530,7 +530,7 @@ describe AccountInteractions do
end
end
context 'not reblogged' do
context 'when not reblogged' do
let(:reblogs) { [] }
it 'returns false' do
@ -544,14 +544,14 @@ describe AccountInteractions do
let(:status) { Fabricate(:status, account: account) }
context 'pinned' do
context 'when pinned' do
it 'returns true' do
Fabricate(:status_pin, account: account, status: status)
expect(subject).to be true
end
end
context 'not pinned' do
context 'when not pinned' do
it 'returns false' do
expect(subject).to be false
end

View file

@ -156,7 +156,7 @@ RSpec.describe Remotable do
context 'when the response is successful' do
let(:code) { 200 }
context 'and contains Content-Disposition header' do
context 'when contains Content-Disposition header' do
let(:file) { 'filename="foo.txt"' }
let(:headers) { { 'content-disposition' => file } }

View file

@ -10,8 +10,8 @@ RSpec.describe CustomEmojiFilter do
let!(:custom_emoji_1) { Fabricate(:custom_emoji, domain: 'b') }
let!(:custom_emoji_2) { Fabricate(:custom_emoji, domain: nil, shortcode: 'hoge') }
context 'params have values' do
context 'local' do
context 'when params have values' do
context 'when local' do
let(:params) { { local: true } }
it 'returns ActiveRecord::Relation' do
@ -20,7 +20,7 @@ RSpec.describe CustomEmojiFilter do
end
end
context 'remote' do
context 'when remote' do
let(:params) { { remote: true } }
it 'returns ActiveRecord::Relation' do
@ -29,7 +29,7 @@ RSpec.describe CustomEmojiFilter do
end
end
context 'by_domain' do
context 'with by_domain' do
let(:params) { { by_domain: 'a' } }
it 'returns ActiveRecord::Relation' do
@ -38,7 +38,7 @@ RSpec.describe CustomEmojiFilter do
end
end
context 'shortcode' do
context 'when shortcode' do
let(:params) { { shortcode: 'hoge' } }
it 'returns ActiveRecord::Relation' do
@ -47,7 +47,7 @@ RSpec.describe CustomEmojiFilter do
end
end
context 'else' do
context 'when some other case' do
let(:params) { { else: 'else' } }
it 'raises Mastodon::InvalidParameterError' do
@ -58,7 +58,7 @@ RSpec.describe CustomEmojiFilter do
end
end
context 'params without value' do
context 'when params without value' do
let(:params) { { hoge: nil } }
it 'returns ActiveRecord::Relation' do

View file

@ -8,7 +8,7 @@ RSpec.describe CustomEmoji, type: :model do
let(:custom_emoji) { Fabricate(:custom_emoji, shortcode: shortcode) }
context 'shortcode is exact' do
context 'when shortcode is exact' do
let(:shortcode) { 'blobpats' }
let(:search_term) { 'blobpats' }
@ -17,7 +17,7 @@ RSpec.describe CustomEmoji, type: :model do
end
end
context 'shortcode is partial' do
context 'when shortcode is partial' do
let(:shortcode) { 'blobpats' }
let(:search_term) { 'blob' }
@ -32,7 +32,7 @@ RSpec.describe CustomEmoji, type: :model do
let(:custom_emoji) { Fabricate(:custom_emoji, domain: domain) }
context 'domain is nil' do
context 'when domain is nil' do
let(:domain) { nil }
it 'returns true' do
@ -40,7 +40,7 @@ RSpec.describe CustomEmoji, type: :model do
end
end
context 'domain is present' do
context 'when domain is present' do
let(:domain) { 'example.com' }
it 'returns false' do

View file

@ -6,7 +6,7 @@ RSpec.describe EmailDomainBlock, type: :model do
describe 'block?' do
let(:input) { nil }
context 'given an e-mail address' do
context 'when given an e-mail address' do
let(:input) { "foo@#{domain}" }
context do
@ -33,7 +33,7 @@ RSpec.describe EmailDomainBlock, type: :model do
end
end
context 'given an array of domains' do
context 'when given an array of domains' do
let(:input) { %w(foo.com mail.foo.com) }
it 'returns true if the domain is blocked' do

View file

@ -8,7 +8,7 @@ RSpec.describe MediaAttachment, type: :model do
let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url) }
context 'remote_url is blank' do
context 'when remote_url is blank' do
let(:remote_url) { '' }
it 'returns true' do
@ -16,7 +16,7 @@ RSpec.describe MediaAttachment, type: :model do
end
end
context 'remote_url is present' do
context 'when remote_url is present' do
let(:remote_url) { 'remote_url' }
it 'returns false' do
@ -30,10 +30,10 @@ RSpec.describe MediaAttachment, type: :model do
let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url, file: file) }
context 'file is blank' do
context 'when file is blank' do
let(:file) { nil }
context 'remote_url is present' do
context 'when remote_url is present' do
let(:remote_url) { 'remote_url' }
it 'returns true' do
@ -42,10 +42,10 @@ RSpec.describe MediaAttachment, type: :model do
end
end
context 'file is present' do
context 'when file is present' do
let(:file) { attachment_fixture('avatar.gif') }
context 'remote_url is blank' do
context 'when remote_url is blank' do
let(:remote_url) { '' }
it 'returns false' do
@ -53,7 +53,7 @@ RSpec.describe MediaAttachment, type: :model do
end
end
context 'remote_url is present' do
context 'when remote_url is present' do
let(:remote_url) { 'remote_url' }
it 'returns true' do

View file

@ -10,7 +10,7 @@ RSpec.describe Notification, type: :model do
let(:favourite) { Fabricate(:favourite, status: status) }
let(:mention) { Fabricate(:mention, status: status) }
context 'activity is reblog' do
context 'when Activity is reblog' do
let(:activity) { reblog }
it 'returns status' do
@ -18,7 +18,7 @@ RSpec.describe Notification, type: :model do
end
end
context 'activity is favourite' do
context 'when Activity is favourite' do
let(:type) { :favourite }
let(:activity) { favourite }
@ -27,7 +27,7 @@ RSpec.describe Notification, type: :model do
end
end
context 'activity is mention' do
context 'when Activity is mention' do
let(:activity) { mention }
it 'returns status' do
@ -66,7 +66,7 @@ RSpec.describe Notification, type: :model do
end
end
context 'notifications are empty' do
context 'when notifications are empty' do
let(:notifications) { [] }
it 'returns []' do
@ -74,7 +74,7 @@ RSpec.describe Notification, type: :model do
end
end
context 'notifications are present' do
context 'when notifications are present' do
before do
notifications.each(&:reload)
end

View file

@ -13,7 +13,7 @@ RSpec.describe RemoteFollow do
describe '.initialize' do
subject { remote_follow.acct }
context 'attrs with acct' do
context 'when attrs with acct' do
let(:attrs) { { acct: 'gargron@quitter.no' } }
it 'returns acct' do
@ -21,7 +21,7 @@ RSpec.describe RemoteFollow do
end
end
context 'attrs without acct' do
context 'when attrs without acct' do
let(:attrs) { {} }
it do
@ -33,7 +33,7 @@ RSpec.describe RemoteFollow do
describe '#valid?' do
subject { remote_follow.valid? }
context 'attrs with acct' do
context 'when attrs with acct' do
let(:attrs) { { acct: 'gargron@quitter.no' } }
it do
@ -41,7 +41,7 @@ RSpec.describe RemoteFollow do
end
end
context 'attrs without acct' do
context 'when attrs without acct' do
let(:attrs) { {} }
it do

View file

@ -89,13 +89,13 @@ describe Report do
let(:report) { Fabricate(:report, action_taken_at: action_taken) }
context 'if action is taken' do
context 'when action is taken' do
let(:action_taken) { Time.now.utc }
it { is_expected.to be false }
end
context 'if action not is taken' do
context 'when action not is taken' do
let(:action_taken) { nil }
it { is_expected.to be true }

View file

@ -40,7 +40,7 @@ RSpec.describe SessionActivation, type: :model do
describe '.active?' do
subject { described_class.active?(id) }
context 'id is absent' do
context 'when id is absent' do
let(:id) { nil }
it 'returns nil' do
@ -48,17 +48,17 @@ RSpec.describe SessionActivation, type: :model do
end
end
context 'id is present' do
context 'when id is present' do
let(:id) { '1' }
let!(:session_activation) { Fabricate(:session_activation, session_id: id) }
context 'id exists as session_id' do
context 'when id exists as session_id' do
it 'returns true' do
expect(subject).to be true
end
end
context 'id does not exist as session_id' do
context 'when id does not exist as session_id' do
before do
session_activation.update!(session_id: '2')
end
@ -85,7 +85,7 @@ RSpec.describe SessionActivation, type: :model do
end
describe '.deactivate' do
context 'id is absent' do
context 'when id is absent' do
let(:id) { nil }
it 'returns nil' do
@ -93,7 +93,7 @@ RSpec.describe SessionActivation, type: :model do
end
end
context 'id exists' do
context 'when id exists' do
let(:id) { '1' }
it 'calls where.destroy_all' do

View file

@ -19,7 +19,7 @@ RSpec.describe Setting, type: :model do
let(:key) { 'key' }
context 'rails_initialized? is falsey' do
context 'when rails_initialized? is falsey' do
let(:rails_initialized) { false }
it 'calls RailsSettings::Base#[]' do
@ -28,7 +28,7 @@ RSpec.describe Setting, type: :model do
end
end
context 'rails_initialized? is truthy' do
context 'when rails_initialized? is truthy' do
before do
allow(RailsSettings::Base).to receive(:cache_key).with(key, nil).and_return(cache_key)
end
@ -42,7 +42,7 @@ RSpec.describe Setting, type: :model do
described_class[key]
end
context 'Rails.cache does not exists' do
context 'when Rails.cache does not exists' do
before do
allow(RailsSettings::Settings).to receive(:object).with(key).and_return(object)
allow(described_class).to receive(:default_settings).and_return(default_settings)
@ -60,11 +60,11 @@ RSpec.describe Setting, type: :model do
described_class[key]
end
context 'RailsSettings::Settings.object returns truthy' do
context 'when RailsSettings::Settings.object returns truthy' do
let(:object) { db_val }
let(:db_val) { double(value: 'db_val') }
context 'default_value is a Hash' do
context 'when default_value is a Hash' do
let(:default_value) { { default_value: 'default_value' } }
it 'calls default_value.with_indifferent_access.merge!' do
@ -75,7 +75,7 @@ RSpec.describe Setting, type: :model do
end
end
context 'default_value is not a Hash' do
context 'when default_value is not a Hash' do
let(:default_value) { 'default_value' }
it 'returns db_val.value' do
@ -84,7 +84,7 @@ RSpec.describe Setting, type: :model do
end
end
context 'RailsSettings::Settings.object returns falsey' do
context 'when RailsSettings::Settings.object returns falsey' do
let(:object) { nil }
it 'returns default_settings[key]' do
@ -93,7 +93,7 @@ RSpec.describe Setting, type: :model do
end
end
context 'Rails.cache exists' do
context 'when Rails.cache exists' do
before do
Rails.cache.write(cache_key, cache_value)
end
@ -130,7 +130,7 @@ RSpec.describe Setting, type: :model do
expect(described_class.all_as_records).to be_a Hash
end
context 'records includes Setting with var as the key' do
context 'when records includes Setting with var as the key' do
let(:records) { [original_setting] }
it 'includes the original Setting' do
@ -139,10 +139,10 @@ RSpec.describe Setting, type: :model do
end
end
context 'records includes nothing' do
context 'when records includes nothing' do
let(:records) { [] }
context 'default_value is not a Hash' do
context 'when default_value is not a Hash' do
it 'includes Setting with value of default_value' do
setting = described_class.all_as_records[key]
@ -152,7 +152,7 @@ RSpec.describe Setting, type: :model do
end
end
context 'default_value is a Hash' do
context 'when default_value is a Hash' do
let(:default_value) { { 'foo' => 'fuga' } }
it 'returns {}' do
@ -169,7 +169,7 @@ RSpec.describe Setting, type: :model do
allow(RailsSettings::Default).to receive(:enabled?).and_return(enabled)
end
context 'RailsSettings::Default.enabled? is false' do
context 'when RailsSettings::Default.enabled? is false' do
let(:enabled) { false }
it 'returns {}' do
@ -177,7 +177,7 @@ RSpec.describe Setting, type: :model do
end
end
context 'RailsSettings::Settings.enabled? is true' do
context 'when RailsSettings::Settings.enabled? is true' do
let(:enabled) { true }
it 'returns instance of RailsSettings::Default' do

View file

@ -49,22 +49,22 @@ RSpec.describe Status, type: :model do
end
describe '#verb' do
context 'if destroyed?' do
context 'when destroyed?' do
it 'returns :delete' do
subject.destroy!
expect(subject.verb).to be :delete
end
end
context 'unless destroyed?' do
context 'if reblog?' do
context 'when not destroyed?' do
context 'when reblog?' do
it 'returns :share' do
subject.reblog = other
expect(subject.verb).to be :share
end
end
context 'unless reblog?' do
context 'when not reblog?' do
it 'returns :post' do
subject.reblog = nil
expect(subject.verb).to be :post
@ -85,28 +85,28 @@ RSpec.describe Status, type: :model do
end
describe '#hidden?' do
context 'if private_visibility?' do
context 'when private_visibility?' do
it 'returns true' do
subject.visibility = :private
expect(subject.hidden?).to be true
end
end
context 'if direct_visibility?' do
context 'when direct_visibility?' do
it 'returns true' do
subject.visibility = :direct
expect(subject.hidden?).to be true
end
end
context 'if public_visibility?' do
context 'when public_visibility?' do
it 'returns false' do
subject.visibility = :public
expect(subject.hidden?).to be false
end
end
context 'if unlisted_visibility?' do
context 'when unlisted_visibility?' do
it 'returns false' do
subject.visibility = :unlisted
expect(subject.hidden?).to be false

View file

@ -56,7 +56,7 @@ RSpec.describe Web::PushSubscription, type: :model do
context 'when policy is followed' do
let(:policy) { 'followed' }
context 'and notification is from someone you follow' do
context 'when notification is from someone you follow' do
before do
account.follow!(notification.from_account)
end
@ -66,7 +66,7 @@ RSpec.describe Web::PushSubscription, type: :model do
end
end
context 'and notification is not from someone you follow' do
context 'when notification is not from someone you follow' do
it 'returns false' do
expect(subject.pushable?(notification)).to be false
end
@ -76,7 +76,7 @@ RSpec.describe Web::PushSubscription, type: :model do
context 'when policy is follower' do
let(:policy) { 'follower' }
context 'and notification is from someone who follows you' do
context 'when notification is from someone who follows you' do
before do
notification.from_account.follow!(account)
end
@ -86,7 +86,7 @@ RSpec.describe Web::PushSubscription, type: :model do
end
end
context 'and notification is not from someone who follows you' do
context 'when notification is not from someone who follows you' do
it 'returns false' do
expect(subject.pushable?(notification)).to be false
end