Fix RSpec/DescribedClass
cop (#25104)
This commit is contained in:
parent
1e243e2df7
commit
c42591356d
66 changed files with 347 additions and 414 deletions
|
@ -237,79 +237,6 @@ RSpec/AnyInstance:
|
||||||
- 'spec/workers/activitypub/delivery_worker_spec.rb'
|
- 'spec/workers/activitypub/delivery_worker_spec.rb'
|
||||||
- 'spec/workers/web/push_notification_worker_spec.rb'
|
- 'spec/workers/web/push_notification_worker_spec.rb'
|
||||||
|
|
||||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
||||||
# Configuration parameters: SkipBlocks, EnforcedStyle.
|
|
||||||
# SupportedStyles: described_class, explicit
|
|
||||||
RSpec/DescribedClass:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/controllers/concerns/cache_concern_spec.rb'
|
|
||||||
- 'spec/controllers/concerns/challengable_concern_spec.rb'
|
|
||||||
- 'spec/lib/entity_cache_spec.rb'
|
|
||||||
- 'spec/lib/extractor_spec.rb'
|
|
||||||
- 'spec/lib/feed_manager_spec.rb'
|
|
||||||
- 'spec/lib/hash_object_spec.rb'
|
|
||||||
- 'spec/lib/ostatus/tag_manager_spec.rb'
|
|
||||||
- 'spec/lib/request_spec.rb'
|
|
||||||
- 'spec/lib/tag_manager_spec.rb'
|
|
||||||
- 'spec/lib/webfinger_resource_spec.rb'
|
|
||||||
- 'spec/mailers/notification_mailer_spec.rb'
|
|
||||||
- 'spec/mailers/user_mailer_spec.rb'
|
|
||||||
- 'spec/models/account_conversation_spec.rb'
|
|
||||||
- 'spec/models/account_domain_block_spec.rb'
|
|
||||||
- 'spec/models/account_migration_spec.rb'
|
|
||||||
- 'spec/models/account_spec.rb'
|
|
||||||
- 'spec/models/block_spec.rb'
|
|
||||||
- 'spec/models/domain_block_spec.rb'
|
|
||||||
- 'spec/models/email_domain_block_spec.rb'
|
|
||||||
- 'spec/models/export_spec.rb'
|
|
||||||
- 'spec/models/favourite_spec.rb'
|
|
||||||
- 'spec/models/follow_spec.rb'
|
|
||||||
- 'spec/models/identity_spec.rb'
|
|
||||||
- 'spec/models/import_spec.rb'
|
|
||||||
- 'spec/models/media_attachment_spec.rb'
|
|
||||||
- 'spec/models/notification_spec.rb'
|
|
||||||
- 'spec/models/relationship_filter_spec.rb'
|
|
||||||
- 'spec/models/report_filter_spec.rb'
|
|
||||||
- 'spec/models/session_activation_spec.rb'
|
|
||||||
- 'spec/models/setting_spec.rb'
|
|
||||||
- 'spec/models/site_upload_spec.rb'
|
|
||||||
- 'spec/models/status_pin_spec.rb'
|
|
||||||
- 'spec/models/status_spec.rb'
|
|
||||||
- 'spec/models/user_spec.rb'
|
|
||||||
- 'spec/policies/account_moderation_note_policy_spec.rb'
|
|
||||||
- 'spec/presenters/account_relationships_presenter_spec.rb'
|
|
||||||
- 'spec/presenters/status_relationships_presenter_spec.rb'
|
|
||||||
- 'spec/serializers/activitypub/note_serializer_spec.rb'
|
|
||||||
- 'spec/serializers/activitypub/update_poll_serializer_spec.rb'
|
|
||||||
- 'spec/serializers/rest/account_serializer_spec.rb'
|
|
||||||
- 'spec/services/activitypub/fetch_remote_account_service_spec.rb'
|
|
||||||
- 'spec/services/activitypub/fetch_remote_actor_service_spec.rb'
|
|
||||||
- 'spec/services/activitypub/fetch_remote_key_service_spec.rb'
|
|
||||||
- 'spec/services/after_block_domain_from_account_service_spec.rb'
|
|
||||||
- 'spec/services/authorize_follow_service_spec.rb'
|
|
||||||
- 'spec/services/batched_remove_status_service_spec.rb'
|
|
||||||
- 'spec/services/block_domain_service_spec.rb'
|
|
||||||
- 'spec/services/block_service_spec.rb'
|
|
||||||
- 'spec/services/bootstrap_timeline_service_spec.rb'
|
|
||||||
- 'spec/services/clear_domain_media_service_spec.rb'
|
|
||||||
- 'spec/services/favourite_service_spec.rb'
|
|
||||||
- 'spec/services/follow_service_spec.rb'
|
|
||||||
- 'spec/services/import_service_spec.rb'
|
|
||||||
- 'spec/services/post_status_service_spec.rb'
|
|
||||||
- 'spec/services/precompute_feed_service_spec.rb'
|
|
||||||
- 'spec/services/process_mentions_service_spec.rb'
|
|
||||||
- 'spec/services/purge_domain_service_spec.rb'
|
|
||||||
- 'spec/services/reblog_service_spec.rb'
|
|
||||||
- 'spec/services/reject_follow_service_spec.rb'
|
|
||||||
- 'spec/services/remove_from_followers_service_spec.rb'
|
|
||||||
- 'spec/services/remove_status_service_spec.rb'
|
|
||||||
- 'spec/services/unallow_domain_service_spec.rb'
|
|
||||||
- 'spec/services/unblock_service_spec.rb'
|
|
||||||
- 'spec/services/unfollow_service_spec.rb'
|
|
||||||
- 'spec/services/unmute_service_spec.rb'
|
|
||||||
- 'spec/services/update_account_service_spec.rb'
|
|
||||||
- 'spec/validators/note_length_validator_spec.rb'
|
|
||||||
|
|
||||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||||
RSpec/EmptyExampleGroup:
|
RSpec/EmptyExampleGroup:
|
||||||
Exclude:
|
Exclude:
|
||||||
|
|
6
spec/controllers/.rubocop.yml
Normal file
6
spec/controllers/.rubocop.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
inherit_from: ../../.rubocop.yml
|
||||||
|
|
||||||
|
# Anonymous controllers in specs cannot access described_class
|
||||||
|
# https://github.com/rubocop/rubocop-rspec/blob/master/lib/rubocop/cop/rspec/described_class.rb#L36-L39
|
||||||
|
RSpec/DescribedClass:
|
||||||
|
SkipBlocks: true
|
|
@ -7,7 +7,7 @@ RSpec.describe EntityCache do
|
||||||
let(:remote_account) { Fabricate(:account, domain: 'remote.test', username: 'bob', url: 'https://remote.test/') }
|
let(:remote_account) { Fabricate(:account, domain: 'remote.test', username: 'bob', url: 'https://remote.test/') }
|
||||||
|
|
||||||
describe '#emoji' do
|
describe '#emoji' do
|
||||||
subject { EntityCache.instance.emoji(shortcodes, domain) }
|
subject { described_class.instance.emoji(shortcodes, domain) }
|
||||||
|
|
||||||
context 'when called with an empty list of shortcodes' do
|
context 'when called with an empty list of shortcodes' do
|
||||||
let(:shortcodes) { [] }
|
let(:shortcodes) { [] }
|
||||||
|
|
|
@ -6,19 +6,19 @@ describe Extractor do
|
||||||
describe 'extract_mentions_or_lists_with_indices' do
|
describe 'extract_mentions_or_lists_with_indices' do
|
||||||
it 'returns an empty array if the given string does not have at signs' do
|
it 'returns an empty array if the given string does not have at signs' do
|
||||||
text = 'a string without at signs'
|
text = 'a string without at signs'
|
||||||
extracted = Extractor.extract_mentions_or_lists_with_indices(text)
|
extracted = described_class.extract_mentions_or_lists_with_indices(text)
|
||||||
expect(extracted).to eq []
|
expect(extracted).to eq []
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not extract mentions which ends with particular characters' do
|
it 'does not extract mentions which ends with particular characters' do
|
||||||
text = '@screen_name@'
|
text = '@screen_name@'
|
||||||
extracted = Extractor.extract_mentions_or_lists_with_indices(text)
|
extracted = described_class.extract_mentions_or_lists_with_indices(text)
|
||||||
expect(extracted).to eq []
|
expect(extracted).to eq []
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns mentions as an array' do
|
it 'returns mentions as an array' do
|
||||||
text = '@screen_name'
|
text = '@screen_name'
|
||||||
extracted = Extractor.extract_mentions_or_lists_with_indices(text)
|
extracted = described_class.extract_mentions_or_lists_with_indices(text)
|
||||||
expect(extracted).to eq [
|
expect(extracted).to eq [
|
||||||
{ screen_name: 'screen_name', indices: [0, 12] },
|
{ screen_name: 'screen_name', indices: [0, 12] },
|
||||||
]
|
]
|
||||||
|
@ -26,7 +26,7 @@ describe Extractor do
|
||||||
|
|
||||||
it 'yields mentions if a block is given' do
|
it 'yields mentions if a block is given' do
|
||||||
text = '@screen_name'
|
text = '@screen_name'
|
||||||
Extractor.extract_mentions_or_lists_with_indices(text) do |screen_name, start_position, end_position|
|
described_class.extract_mentions_or_lists_with_indices(text) do |screen_name, start_position, end_position|
|
||||||
expect(screen_name).to eq 'screen_name'
|
expect(screen_name).to eq 'screen_name'
|
||||||
expect(start_position).to eq 0
|
expect(start_position).to eq 0
|
||||||
expect(end_position).to eq 12
|
expect(end_position).to eq 12
|
||||||
|
@ -37,31 +37,31 @@ describe Extractor do
|
||||||
describe 'extract_hashtags_with_indices' do
|
describe 'extract_hashtags_with_indices' do
|
||||||
it 'returns an empty array if it does not have #' do
|
it 'returns an empty array if it does not have #' do
|
||||||
text = 'a string without hash sign'
|
text = 'a string without hash sign'
|
||||||
extracted = Extractor.extract_hashtags_with_indices(text)
|
extracted = described_class.extract_hashtags_with_indices(text)
|
||||||
expect(extracted).to eq []
|
expect(extracted).to eq []
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not exclude normal hash text before ://' do
|
it 'does not exclude normal hash text before ://' do
|
||||||
text = '#hashtag://'
|
text = '#hashtag://'
|
||||||
extracted = Extractor.extract_hashtags_with_indices(text)
|
extracted = described_class.extract_hashtags_with_indices(text)
|
||||||
expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }]
|
expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'excludes http://' do
|
it 'excludes http://' do
|
||||||
text = '#hashtaghttp://'
|
text = '#hashtaghttp://'
|
||||||
extracted = Extractor.extract_hashtags_with_indices(text)
|
extracted = described_class.extract_hashtags_with_indices(text)
|
||||||
expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }]
|
expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'excludes https://' do
|
it 'excludes https://' do
|
||||||
text = '#hashtaghttps://'
|
text = '#hashtaghttps://'
|
||||||
extracted = Extractor.extract_hashtags_with_indices(text)
|
extracted = described_class.extract_hashtags_with_indices(text)
|
||||||
expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }]
|
expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'yields hashtags if a block is given' do
|
it 'yields hashtags if a block is given' do
|
||||||
text = '#hashtag'
|
text = '#hashtag'
|
||||||
Extractor.extract_hashtags_with_indices(text) do |hashtag, start_position, end_position|
|
described_class.extract_hashtags_with_indices(text) do |hashtag, start_position, end_position|
|
||||||
expect(hashtag).to eq 'hashtag'
|
expect(hashtag).to eq 'hashtag'
|
||||||
expect(start_position).to eq 0
|
expect(start_position).to eq 0
|
||||||
expect(end_position).to eq 8
|
expect(end_position).to eq 8
|
||||||
|
@ -72,7 +72,7 @@ describe Extractor do
|
||||||
describe 'extract_cashtags_with_indices' do
|
describe 'extract_cashtags_with_indices' do
|
||||||
it 'returns []' do
|
it 'returns []' do
|
||||||
text = '$cashtag'
|
text = '$cashtag'
|
||||||
extracted = Extractor.extract_cashtags_with_indices(text)
|
extracted = described_class.extract_cashtags_with_indices(text)
|
||||||
expect(extracted).to eq []
|
expect(extracted).to eq []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@ RSpec.describe FeedManager do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#key' do
|
describe '#key' do
|
||||||
subject { FeedManager.instance.key(:home, 1) }
|
subject { described_class.instance.key(:home, 1) }
|
||||||
|
|
||||||
it 'returns a string' do
|
it 'returns a string' do
|
||||||
expect(subject).to be_a String
|
expect(subject).to be_a String
|
||||||
|
@ -32,26 +32,26 @@ RSpec.describe FeedManager do
|
||||||
it 'returns false for followee\'s status' do
|
it 'returns false for followee\'s status' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: alice)
|
status = Fabricate(:status, text: 'Hello world', account: alice)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
expect(FeedManager.instance.filter?(:home, status, bob)).to be false
|
expect(described_class.instance.filter?(:home, status, bob)).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false for reblog by followee' do
|
it 'returns false for reblog by followee' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: jeff)
|
status = Fabricate(:status, text: 'Hello world', account: jeff)
|
||||||
reblog = Fabricate(:status, reblog: status, account: alice)
|
reblog = Fabricate(:status, reblog: status, account: alice)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
expect(FeedManager.instance.filter?(:home, reblog, bob)).to be false
|
expect(described_class.instance.filter?(:home, reblog, bob)).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for post from account who blocked me' do
|
it 'returns true for post from account who blocked me' do
|
||||||
status = Fabricate(:status, text: 'Hello, World', account: alice)
|
status = Fabricate(:status, text: 'Hello, World', account: alice)
|
||||||
alice.block!(bob)
|
alice.block!(bob)
|
||||||
expect(FeedManager.instance.filter?(:home, status, bob)).to be true
|
expect(described_class.instance.filter?(:home, status, bob)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for post from blocked account' do
|
it 'returns true for post from blocked account' do
|
||||||
status = Fabricate(:status, text: 'Hello, World', account: alice)
|
status = Fabricate(:status, text: 'Hello, World', account: alice)
|
||||||
bob.block!(alice)
|
bob.block!(alice)
|
||||||
expect(FeedManager.instance.filter?(:home, status, bob)).to be true
|
expect(described_class.instance.filter?(:home, status, bob)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for reblog by followee of blocked account' do
|
it 'returns true for reblog by followee of blocked account' do
|
||||||
|
@ -59,7 +59,7 @@ RSpec.describe FeedManager do
|
||||||
reblog = Fabricate(:status, reblog: status, account: alice)
|
reblog = Fabricate(:status, reblog: status, account: alice)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
bob.block!(jeff)
|
bob.block!(jeff)
|
||||||
expect(FeedManager.instance.filter?(:home, reblog, bob)).to be true
|
expect(described_class.instance.filter?(:home, reblog, bob)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for reblog by followee of muted account' do
|
it 'returns true for reblog by followee of muted account' do
|
||||||
|
@ -67,7 +67,7 @@ RSpec.describe FeedManager do
|
||||||
reblog = Fabricate(:status, reblog: status, account: alice)
|
reblog = Fabricate(:status, reblog: status, account: alice)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
bob.mute!(jeff)
|
bob.mute!(jeff)
|
||||||
expect(FeedManager.instance.filter?(:home, reblog, bob)).to be true
|
expect(described_class.instance.filter?(:home, reblog, bob)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for reblog by followee of someone who is blocking recipient' do
|
it 'returns true for reblog by followee of someone who is blocking recipient' do
|
||||||
|
@ -75,14 +75,14 @@ RSpec.describe FeedManager do
|
||||||
reblog = Fabricate(:status, reblog: status, account: alice)
|
reblog = Fabricate(:status, reblog: status, account: alice)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
jeff.block!(bob)
|
jeff.block!(bob)
|
||||||
expect(FeedManager.instance.filter?(:home, reblog, bob)).to be true
|
expect(described_class.instance.filter?(:home, reblog, bob)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for reblog from account with reblogs disabled' do
|
it 'returns true for reblog from account with reblogs disabled' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: jeff)
|
status = Fabricate(:status, text: 'Hello world', account: jeff)
|
||||||
reblog = Fabricate(:status, reblog: status, account: alice)
|
reblog = Fabricate(:status, reblog: status, account: alice)
|
||||||
bob.follow!(alice, reblogs: false)
|
bob.follow!(alice, reblogs: false)
|
||||||
expect(FeedManager.instance.filter?(:home, reblog, bob)).to be true
|
expect(described_class.instance.filter?(:home, reblog, bob)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false for reply by followee to another followee' do
|
it 'returns false for reply by followee to another followee' do
|
||||||
|
@ -90,49 +90,49 @@ RSpec.describe FeedManager do
|
||||||
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
bob.follow!(jeff)
|
bob.follow!(jeff)
|
||||||
expect(FeedManager.instance.filter?(:home, reply, bob)).to be false
|
expect(described_class.instance.filter?(:home, reply, bob)).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false for reply by followee to recipient' do
|
it 'returns false for reply by followee to recipient' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: bob)
|
status = Fabricate(:status, text: 'Hello world', account: bob)
|
||||||
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
expect(FeedManager.instance.filter?(:home, reply, bob)).to be false
|
expect(described_class.instance.filter?(:home, reply, bob)).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false for reply by followee to self' do
|
it 'returns false for reply by followee to self' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: alice)
|
status = Fabricate(:status, text: 'Hello world', account: alice)
|
||||||
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
expect(FeedManager.instance.filter?(:home, reply, bob)).to be false
|
expect(described_class.instance.filter?(:home, reply, bob)).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for reply by followee to non-followed account' do
|
it 'returns true for reply by followee to non-followed account' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: jeff)
|
status = Fabricate(:status, text: 'Hello world', account: jeff)
|
||||||
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
expect(FeedManager.instance.filter?(:home, reply, bob)).to be true
|
expect(described_class.instance.filter?(:home, reply, bob)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for the second reply by followee to a non-federated status' do
|
it 'returns true for the second reply by followee to a non-federated status' do
|
||||||
reply = Fabricate(:status, text: 'Reply 1', reply: true, account: alice)
|
reply = Fabricate(:status, text: 'Reply 1', reply: true, account: alice)
|
||||||
second_reply = Fabricate(:status, text: 'Reply 2', thread: reply, account: alice)
|
second_reply = Fabricate(:status, text: 'Reply 2', thread: reply, account: alice)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
expect(FeedManager.instance.filter?(:home, second_reply, bob)).to be true
|
expect(described_class.instance.filter?(:home, second_reply, bob)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false for status by followee mentioning another account' do
|
it 'returns false for status by followee mentioning another account' do
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
jeff.follow!(alice)
|
jeff.follow!(alice)
|
||||||
status = PostStatusService.new.call(alice, text: 'Hey @jeff')
|
status = PostStatusService.new.call(alice, text: 'Hey @jeff')
|
||||||
expect(FeedManager.instance.filter?(:home, status, bob)).to be false
|
expect(described_class.instance.filter?(:home, status, bob)).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for status by followee mentioning blocked account' do
|
it 'returns true for status by followee mentioning blocked account' do
|
||||||
bob.block!(jeff)
|
bob.block!(jeff)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
status = PostStatusService.new.call(alice, text: 'Hey @jeff')
|
status = PostStatusService.new.call(alice, text: 'Hey @jeff')
|
||||||
expect(FeedManager.instance.filter?(:home, status, bob)).to be true
|
expect(described_class.instance.filter?(:home, status, bob)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for reblog of a personally blocked domain' do
|
it 'returns true for reblog of a personally blocked domain' do
|
||||||
|
@ -140,19 +140,19 @@ RSpec.describe FeedManager do
|
||||||
alice.follow!(jeff)
|
alice.follow!(jeff)
|
||||||
status = Fabricate(:status, text: 'Hello world', account: bob)
|
status = Fabricate(:status, text: 'Hello world', account: bob)
|
||||||
reblog = Fabricate(:status, reblog: status, account: jeff)
|
reblog = Fabricate(:status, reblog: status, account: jeff)
|
||||||
expect(FeedManager.instance.filter?(:home, reblog, alice)).to be true
|
expect(described_class.instance.filter?(:home, reblog, alice)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for German post when follow is set to English only' do
|
it 'returns true for German post when follow is set to English only' do
|
||||||
alice.follow!(bob, languages: %w(en))
|
alice.follow!(bob, languages: %w(en))
|
||||||
status = Fabricate(:status, text: 'Hallo Welt', account: bob, language: 'de')
|
status = Fabricate(:status, text: 'Hallo Welt', account: bob, language: 'de')
|
||||||
expect(FeedManager.instance.filter?(:home, status, alice)).to be true
|
expect(described_class.instance.filter?(:home, status, alice)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false for German post when follow is set to German' do
|
it 'returns false for German post when follow is set to German' do
|
||||||
alice.follow!(bob, languages: %w(de))
|
alice.follow!(bob, languages: %w(de))
|
||||||
status = Fabricate(:status, text: 'Hallo Welt', account: bob, language: 'de')
|
status = Fabricate(:status, text: 'Hallo Welt', account: bob, language: 'de')
|
||||||
expect(FeedManager.instance.filter?(:home, status, alice)).to be false
|
expect(described_class.instance.filter?(:home, status, alice)).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for post from followee on exclusive list' do
|
it 'returns true for post from followee on exclusive list' do
|
||||||
|
@ -196,27 +196,27 @@ RSpec.describe FeedManager do
|
||||||
it 'returns true for status that mentions blocked account' do
|
it 'returns true for status that mentions blocked account' do
|
||||||
bob.block!(jeff)
|
bob.block!(jeff)
|
||||||
status = PostStatusService.new.call(alice, text: 'Hey @jeff')
|
status = PostStatusService.new.call(alice, text: 'Hey @jeff')
|
||||||
expect(FeedManager.instance.filter?(:mentions, status, bob)).to be true
|
expect(described_class.instance.filter?(:mentions, status, bob)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for status that replies to a blocked account' do
|
it 'returns true for status that replies to a blocked account' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: jeff)
|
status = Fabricate(:status, text: 'Hello world', account: jeff)
|
||||||
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
||||||
bob.block!(jeff)
|
bob.block!(jeff)
|
||||||
expect(FeedManager.instance.filter?(:mentions, reply, bob)).to be true
|
expect(described_class.instance.filter?(:mentions, reply, bob)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for status by silenced account who recipient is not following' do
|
it 'returns true for status by silenced account who recipient is not following' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: alice)
|
status = Fabricate(:status, text: 'Hello world', account: alice)
|
||||||
alice.silence!
|
alice.silence!
|
||||||
expect(FeedManager.instance.filter?(:mentions, status, bob)).to be true
|
expect(described_class.instance.filter?(:mentions, status, bob)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false for status by followed silenced account' do
|
it 'returns false for status by followed silenced account' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: alice)
|
status = Fabricate(:status, text: 'Hello world', account: alice)
|
||||||
alice.silence!
|
alice.silence!
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
expect(FeedManager.instance.filter?(:mentions, status, bob)).to be false
|
expect(described_class.instance.filter?(:mentions, status, bob)).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -228,7 +228,7 @@ RSpec.describe FeedManager do
|
||||||
members = Array.new(FeedManager::MAX_ITEMS) { |count| [count, count] }
|
members = Array.new(FeedManager::MAX_ITEMS) { |count| [count, count] }
|
||||||
redis.zadd("feed:home:#{account.id}", members)
|
redis.zadd("feed:home:#{account.id}", members)
|
||||||
|
|
||||||
FeedManager.instance.push_to_home(account, status)
|
described_class.instance.push_to_home(account, status)
|
||||||
|
|
||||||
expect(redis.zcard("feed:home:#{account.id}")).to eq FeedManager::MAX_ITEMS
|
expect(redis.zcard("feed:home:#{account.id}")).to eq FeedManager::MAX_ITEMS
|
||||||
end
|
end
|
||||||
|
@ -239,7 +239,7 @@ RSpec.describe FeedManager do
|
||||||
reblogged = Fabricate(:status)
|
reblogged = Fabricate(:status)
|
||||||
reblog = Fabricate(:status, reblog: reblogged)
|
reblog = Fabricate(:status, reblog: reblogged)
|
||||||
|
|
||||||
expect(FeedManager.instance.push_to_home(account, reblog)).to be true
|
expect(described_class.instance.push_to_home(account, reblog)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not save a new reblog of a recent status' do
|
it 'does not save a new reblog of a recent status' do
|
||||||
|
@ -247,9 +247,9 @@ RSpec.describe FeedManager do
|
||||||
reblogged = Fabricate(:status)
|
reblogged = Fabricate(:status)
|
||||||
reblog = Fabricate(:status, reblog: reblogged)
|
reblog = Fabricate(:status, reblog: reblogged)
|
||||||
|
|
||||||
FeedManager.instance.push_to_home(account, reblogged)
|
described_class.instance.push_to_home(account, reblogged)
|
||||||
|
|
||||||
expect(FeedManager.instance.push_to_home(account, reblog)).to be false
|
expect(described_class.instance.push_to_home(account, reblog)).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'saves a new reblog of an old status' do
|
it 'saves a new reblog of an old status' do
|
||||||
|
@ -257,14 +257,14 @@ RSpec.describe FeedManager do
|
||||||
reblogged = Fabricate(:status)
|
reblogged = Fabricate(:status)
|
||||||
reblog = Fabricate(:status, reblog: reblogged)
|
reblog = Fabricate(:status, reblog: reblogged)
|
||||||
|
|
||||||
FeedManager.instance.push_to_home(account, reblogged)
|
described_class.instance.push_to_home(account, reblogged)
|
||||||
|
|
||||||
# Fill the feed with intervening statuses
|
# Fill the feed with intervening statuses
|
||||||
FeedManager::REBLOG_FALLOFF.times do
|
FeedManager::REBLOG_FALLOFF.times do
|
||||||
FeedManager.instance.push_to_home(account, Fabricate(:status))
|
described_class.instance.push_to_home(account, Fabricate(:status))
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(FeedManager.instance.push_to_home(account, reblog)).to be true
|
expect(described_class.instance.push_to_home(account, reblog)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not save a new reblog of a recently-reblogged status' do
|
it 'does not save a new reblog of a recently-reblogged status' do
|
||||||
|
@ -273,10 +273,10 @@ RSpec.describe FeedManager do
|
||||||
reblogs = Array.new(2) { Fabricate(:status, reblog: reblogged) }
|
reblogs = Array.new(2) { Fabricate(:status, reblog: reblogged) }
|
||||||
|
|
||||||
# The first reblog will be accepted
|
# The first reblog will be accepted
|
||||||
FeedManager.instance.push_to_home(account, reblogs.first)
|
described_class.instance.push_to_home(account, reblogs.first)
|
||||||
|
|
||||||
# The second reblog should be ignored
|
# The second reblog should be ignored
|
||||||
expect(FeedManager.instance.push_to_home(account, reblogs.last)).to be false
|
expect(described_class.instance.push_to_home(account, reblogs.last)).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'saves a new reblog of a recently-reblogged status when previous reblog has been deleted' do
|
it 'saves a new reblog of a recently-reblogged status when previous reblog has been deleted' do
|
||||||
|
@ -285,15 +285,15 @@ RSpec.describe FeedManager do
|
||||||
old_reblog = Fabricate(:status, reblog: reblogged)
|
old_reblog = Fabricate(:status, reblog: reblogged)
|
||||||
|
|
||||||
# The first reblog should be accepted
|
# The first reblog should be accepted
|
||||||
expect(FeedManager.instance.push_to_home(account, old_reblog)).to be true
|
expect(described_class.instance.push_to_home(account, old_reblog)).to be true
|
||||||
|
|
||||||
# The first reblog should be successfully removed
|
# The first reblog should be successfully removed
|
||||||
expect(FeedManager.instance.unpush_from_home(account, old_reblog)).to be true
|
expect(described_class.instance.unpush_from_home(account, old_reblog)).to be true
|
||||||
|
|
||||||
reblog = Fabricate(:status, reblog: reblogged)
|
reblog = Fabricate(:status, reblog: reblogged)
|
||||||
|
|
||||||
# The second reblog should be accepted
|
# The second reblog should be accepted
|
||||||
expect(FeedManager.instance.push_to_home(account, reblog)).to be true
|
expect(described_class.instance.push_to_home(account, reblog)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not save a new reblog of a multiply-reblogged-then-unreblogged status' do
|
it 'does not save a new reblog of a multiply-reblogged-then-unreblogged status' do
|
||||||
|
@ -302,14 +302,14 @@ RSpec.describe FeedManager do
|
||||||
reblogs = Array.new(3) { Fabricate(:status, reblog: reblogged) }
|
reblogs = Array.new(3) { Fabricate(:status, reblog: reblogged) }
|
||||||
|
|
||||||
# Accept the reblogs
|
# Accept the reblogs
|
||||||
FeedManager.instance.push_to_home(account, reblogs[0])
|
described_class.instance.push_to_home(account, reblogs[0])
|
||||||
FeedManager.instance.push_to_home(account, reblogs[1])
|
described_class.instance.push_to_home(account, reblogs[1])
|
||||||
|
|
||||||
# Unreblog the first one
|
# Unreblog the first one
|
||||||
FeedManager.instance.unpush_from_home(account, reblogs[0])
|
described_class.instance.unpush_from_home(account, reblogs[0])
|
||||||
|
|
||||||
# The last reblog should still be ignored
|
# The last reblog should still be ignored
|
||||||
expect(FeedManager.instance.push_to_home(account, reblogs.last)).to be false
|
expect(described_class.instance.push_to_home(account, reblogs.last)).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'saves a new reblog of a long-ago-reblogged status' do
|
it 'saves a new reblog of a long-ago-reblogged status' do
|
||||||
|
@ -318,15 +318,15 @@ RSpec.describe FeedManager do
|
||||||
reblogs = Array.new(2) { Fabricate(:status, reblog: reblogged) }
|
reblogs = Array.new(2) { Fabricate(:status, reblog: reblogged) }
|
||||||
|
|
||||||
# The first reblog will be accepted
|
# The first reblog will be accepted
|
||||||
FeedManager.instance.push_to_home(account, reblogs.first)
|
described_class.instance.push_to_home(account, reblogs.first)
|
||||||
|
|
||||||
# Fill the feed with intervening statuses
|
# Fill the feed with intervening statuses
|
||||||
FeedManager::REBLOG_FALLOFF.times do
|
FeedManager::REBLOG_FALLOFF.times do
|
||||||
FeedManager.instance.push_to_home(account, Fabricate(:status))
|
described_class.instance.push_to_home(account, Fabricate(:status))
|
||||||
end
|
end
|
||||||
|
|
||||||
# The second reblog should also be accepted
|
# The second reblog should also be accepted
|
||||||
expect(FeedManager.instance.push_to_home(account, reblogs.last)).to be true
|
expect(described_class.instance.push_to_home(account, reblogs.last)).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -334,9 +334,9 @@ RSpec.describe FeedManager do
|
||||||
account = Fabricate(:account)
|
account = Fabricate(:account)
|
||||||
reblog = Fabricate(:status)
|
reblog = Fabricate(:status)
|
||||||
status = Fabricate(:status, reblog: reblog)
|
status = Fabricate(:status, reblog: reblog)
|
||||||
FeedManager.instance.push_to_home(account, status)
|
described_class.instance.push_to_home(account, status)
|
||||||
|
|
||||||
expect(FeedManager.instance.push_to_home(account, reblog)).to be false
|
expect(described_class.instance.push_to_home(account, reblog)).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -359,9 +359,9 @@ RSpec.describe FeedManager do
|
||||||
it "does not push when the given status's reblog is already inserted" do
|
it "does not push when the given status's reblog is already inserted" do
|
||||||
reblog = Fabricate(:status)
|
reblog = Fabricate(:status)
|
||||||
status = Fabricate(:status, reblog: reblog)
|
status = Fabricate(:status, reblog: reblog)
|
||||||
FeedManager.instance.push_to_list(list, status)
|
described_class.instance.push_to_list(list, status)
|
||||||
|
|
||||||
expect(FeedManager.instance.push_to_list(list, reblog)).to be false
|
expect(described_class.instance.push_to_list(list, reblog)).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when replies policy is set to no replies' do
|
context 'when replies policy is set to no replies' do
|
||||||
|
@ -371,19 +371,19 @@ RSpec.describe FeedManager do
|
||||||
|
|
||||||
it 'pushes statuses that are not replies' do
|
it 'pushes statuses that are not replies' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: bob)
|
status = Fabricate(:status, text: 'Hello world', account: bob)
|
||||||
expect(FeedManager.instance.push_to_list(list, status)).to be true
|
expect(described_class.instance.push_to_list(list, status)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'pushes statuses that are replies to list owner' do
|
it 'pushes statuses that are replies to list owner' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: owner)
|
status = Fabricate(:status, text: 'Hello world', account: owner)
|
||||||
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
||||||
expect(FeedManager.instance.push_to_list(list, reply)).to be true
|
expect(described_class.instance.push_to_list(list, reply)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not push replies to another member of the list' do
|
it 'does not push replies to another member of the list' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: alice)
|
status = Fabricate(:status, text: 'Hello world', account: alice)
|
||||||
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
||||||
expect(FeedManager.instance.push_to_list(list, reply)).to be false
|
expect(described_class.instance.push_to_list(list, reply)).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -394,25 +394,25 @@ RSpec.describe FeedManager do
|
||||||
|
|
||||||
it 'pushes statuses that are not replies' do
|
it 'pushes statuses that are not replies' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: bob)
|
status = Fabricate(:status, text: 'Hello world', account: bob)
|
||||||
expect(FeedManager.instance.push_to_list(list, status)).to be true
|
expect(described_class.instance.push_to_list(list, status)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'pushes statuses that are replies to list owner' do
|
it 'pushes statuses that are replies to list owner' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: owner)
|
status = Fabricate(:status, text: 'Hello world', account: owner)
|
||||||
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
||||||
expect(FeedManager.instance.push_to_list(list, reply)).to be true
|
expect(described_class.instance.push_to_list(list, reply)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'pushes replies to another member of the list' do
|
it 'pushes replies to another member of the list' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: alice)
|
status = Fabricate(:status, text: 'Hello world', account: alice)
|
||||||
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
||||||
expect(FeedManager.instance.push_to_list(list, reply)).to be true
|
expect(described_class.instance.push_to_list(list, reply)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not push replies to someone not a member of the list' do
|
it 'does not push replies to someone not a member of the list' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: eve)
|
status = Fabricate(:status, text: 'Hello world', account: eve)
|
||||||
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
||||||
expect(FeedManager.instance.push_to_list(list, reply)).to be false
|
expect(described_class.instance.push_to_list(list, reply)).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -423,25 +423,25 @@ RSpec.describe FeedManager do
|
||||||
|
|
||||||
it 'pushes statuses that are not replies' do
|
it 'pushes statuses that are not replies' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: bob)
|
status = Fabricate(:status, text: 'Hello world', account: bob)
|
||||||
expect(FeedManager.instance.push_to_list(list, status)).to be true
|
expect(described_class.instance.push_to_list(list, status)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'pushes statuses that are replies to list owner' do
|
it 'pushes statuses that are replies to list owner' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: owner)
|
status = Fabricate(:status, text: 'Hello world', account: owner)
|
||||||
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
||||||
expect(FeedManager.instance.push_to_list(list, reply)).to be true
|
expect(described_class.instance.push_to_list(list, reply)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'pushes replies to another member of the list' do
|
it 'pushes replies to another member of the list' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: alice)
|
status = Fabricate(:status, text: 'Hello world', account: alice)
|
||||||
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
||||||
expect(FeedManager.instance.push_to_list(list, reply)).to be true
|
expect(described_class.instance.push_to_list(list, reply)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'pushes replies to someone not a member of the list' do
|
it 'pushes replies to someone not a member of the list' do
|
||||||
status = Fabricate(:status, text: 'Hello world', account: eve)
|
status = Fabricate(:status, text: 'Hello world', account: eve)
|
||||||
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
||||||
expect(FeedManager.instance.push_to_list(list, reply)).to be true
|
expect(described_class.instance.push_to_list(list, reply)).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -451,9 +451,9 @@ RSpec.describe FeedManager do
|
||||||
account = Fabricate(:account, id: 0)
|
account = Fabricate(:account, id: 0)
|
||||||
reblog = Fabricate(:status)
|
reblog = Fabricate(:status)
|
||||||
status = Fabricate(:status, reblog: reblog)
|
status = Fabricate(:status, reblog: reblog)
|
||||||
FeedManager.instance.push_to_home(account, status)
|
described_class.instance.push_to_home(account, status)
|
||||||
|
|
||||||
FeedManager.instance.merge_into_home(account, reblog.account)
|
described_class.instance.merge_into_home(account, reblog.account)
|
||||||
|
|
||||||
expect(redis.zscore('feed:home:0', reblog.id)).to be_nil
|
expect(redis.zscore('feed:home:0', reblog.id)).to be_nil
|
||||||
end
|
end
|
||||||
|
@ -466,14 +466,14 @@ RSpec.describe FeedManager do
|
||||||
reblogged = Fabricate(:status)
|
reblogged = Fabricate(:status)
|
||||||
status = Fabricate(:status, reblog: reblogged)
|
status = Fabricate(:status, reblog: reblogged)
|
||||||
|
|
||||||
FeedManager.instance.push_to_home(receiver, reblogged)
|
described_class.instance.push_to_home(receiver, reblogged)
|
||||||
FeedManager::REBLOG_FALLOFF.times { FeedManager.instance.push_to_home(receiver, Fabricate(:status)) }
|
FeedManager::REBLOG_FALLOFF.times { described_class.instance.push_to_home(receiver, Fabricate(:status)) }
|
||||||
FeedManager.instance.push_to_home(receiver, status)
|
described_class.instance.push_to_home(receiver, status)
|
||||||
|
|
||||||
# The reblogging status should show up under normal conditions.
|
# The reblogging status should show up under normal conditions.
|
||||||
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to include(status.id.to_s)
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to include(status.id.to_s)
|
||||||
|
|
||||||
FeedManager.instance.unpush_from_home(receiver, status)
|
described_class.instance.unpush_from_home(receiver, status)
|
||||||
|
|
||||||
# Restore original status
|
# Restore original status
|
||||||
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to_not include(status.id.to_s)
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to_not include(status.id.to_s)
|
||||||
|
@ -484,12 +484,12 @@ RSpec.describe FeedManager do
|
||||||
reblogged = Fabricate(:status)
|
reblogged = Fabricate(:status)
|
||||||
status = Fabricate(:status, reblog: reblogged)
|
status = Fabricate(:status, reblog: reblogged)
|
||||||
|
|
||||||
FeedManager.instance.push_to_home(receiver, status)
|
described_class.instance.push_to_home(receiver, status)
|
||||||
|
|
||||||
# The reblogging status should show up under normal conditions.
|
# The reblogging status should show up under normal conditions.
|
||||||
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [status.id.to_s]
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [status.id.to_s]
|
||||||
|
|
||||||
FeedManager.instance.unpush_from_home(receiver, status)
|
described_class.instance.unpush_from_home(receiver, status)
|
||||||
|
|
||||||
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to be_empty
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to be_empty
|
||||||
end
|
end
|
||||||
|
@ -499,14 +499,14 @@ RSpec.describe FeedManager do
|
||||||
reblogs = Array.new(3) { Fabricate(:status, reblog: reblogged) }
|
reblogs = Array.new(3) { Fabricate(:status, reblog: reblogged) }
|
||||||
|
|
||||||
reblogs.each do |reblog|
|
reblogs.each do |reblog|
|
||||||
FeedManager.instance.push_to_home(receiver, reblog)
|
described_class.instance.push_to_home(receiver, reblog)
|
||||||
end
|
end
|
||||||
|
|
||||||
# The reblogging status should show up under normal conditions.
|
# The reblogging status should show up under normal conditions.
|
||||||
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [reblogs.first.id.to_s]
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [reblogs.first.id.to_s]
|
||||||
|
|
||||||
reblogs[0...-1].each do |reblog|
|
reblogs[0...-1].each do |reblog|
|
||||||
FeedManager.instance.unpush_from_home(receiver, reblog)
|
described_class.instance.unpush_from_home(receiver, reblog)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [reblogs.last.id.to_s]
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [reblogs.last.id.to_s]
|
||||||
|
@ -515,10 +515,10 @@ RSpec.describe FeedManager do
|
||||||
it 'sends push updates' do
|
it 'sends push updates' do
|
||||||
status = Fabricate(:status)
|
status = Fabricate(:status)
|
||||||
|
|
||||||
FeedManager.instance.push_to_home(receiver, status)
|
described_class.instance.push_to_home(receiver, status)
|
||||||
|
|
||||||
allow(redis).to receive_messages(publish: nil)
|
allow(redis).to receive_messages(publish: nil)
|
||||||
FeedManager.instance.unpush_from_home(receiver, status)
|
described_class.instance.unpush_from_home(receiver, status)
|
||||||
|
|
||||||
deletion = Oj.dump(event: :delete, payload: status.id.to_s)
|
deletion = Oj.dump(event: :delete, payload: status.id.to_s)
|
||||||
expect(redis).to have_received(:publish).with("timeline:#{receiver.id}", deletion)
|
expect(redis).to have_received(:publish).with("timeline:#{receiver.id}", deletion)
|
||||||
|
@ -544,7 +544,7 @@ RSpec.describe FeedManager do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'correctly cleans the home timeline' do
|
it 'correctly cleans the home timeline' do
|
||||||
FeedManager.instance.clear_from_home(account, target_account)
|
described_class.instance.clear_from_home(account, target_account)
|
||||||
|
|
||||||
expect(redis.zrange("feed:home:#{account.id}", 0, -1)).to eq [status_1.id.to_s, status_7.id.to_s]
|
expect(redis.zrange("feed:home:#{account.id}", 0, -1)).to eq [status_1.id.to_s, status_7.id.to_s]
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,40 +5,40 @@ require 'rails_helper'
|
||||||
describe OStatus::TagManager do
|
describe OStatus::TagManager do
|
||||||
describe '#unique_tag' do
|
describe '#unique_tag' do
|
||||||
it 'returns a unique tag' do
|
it 'returns a unique tag' do
|
||||||
expect(OStatus::TagManager.instance.unique_tag(Time.utc(2000), 12, 'Status')).to eq 'tag:cb6e6126.ngrok.io,2000-01-01:objectId=12:objectType=Status'
|
expect(described_class.instance.unique_tag(Time.utc(2000), 12, 'Status')).to eq 'tag:cb6e6126.ngrok.io,2000-01-01:objectId=12:objectType=Status'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#unique_tag_to_local_id' do
|
describe '#unique_tag_to_local_id' do
|
||||||
it 'returns the ID part' do
|
it 'returns the ID part' do
|
||||||
expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectId=12:objectType=Status', 'Status')).to eql '12'
|
expect(described_class.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectId=12:objectType=Status', 'Status')).to eql '12'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns nil if it is not local id' do
|
it 'returns nil if it is not local id' do
|
||||||
expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:remote,2000-01-01:objectId=12:objectType=Status', 'Status')).to be_nil
|
expect(described_class.instance.unique_tag_to_local_id('tag:remote,2000-01-01:objectId=12:objectType=Status', 'Status')).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns nil if it is not expected type' do
|
it 'returns nil if it is not expected type' do
|
||||||
expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectId=12:objectType=Block', 'Status')).to be_nil
|
expect(described_class.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectId=12:objectType=Block', 'Status')).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns nil if it does not have object ID' do
|
it 'returns nil if it does not have object ID' do
|
||||||
expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectType=Status', 'Status')).to be_nil
|
expect(described_class.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectType=Status', 'Status')).to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#local_id?' do
|
describe '#local_id?' do
|
||||||
it 'returns true for a local ID' do
|
it 'returns true for a local ID' do
|
||||||
expect(OStatus::TagManager.instance.local_id?('tag:cb6e6126.ngrok.io;objectId=12:objectType=Status')).to be true
|
expect(described_class.instance.local_id?('tag:cb6e6126.ngrok.io;objectId=12:objectType=Status')).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false for a foreign ID' do
|
it 'returns false for a foreign ID' do
|
||||||
expect(OStatus::TagManager.instance.local_id?('tag:foreign.tld;objectId=12:objectType=Status')).to be false
|
expect(described_class.instance.local_id?('tag:foreign.tld;objectId=12:objectType=Status')).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#uri_for' do
|
describe '#uri_for' do
|
||||||
subject { OStatus::TagManager.instance.uri_for(target) }
|
subject { described_class.instance.uri_for(target) }
|
||||||
|
|
||||||
context 'with comment object' do
|
context 'with comment object' do
|
||||||
let(:target) { Fabricate(:status, created_at: '2000-01-01T00:00:00Z', reply: true) }
|
let(:target) { Fabricate(:status, created_at: '2000-01-01T00:00:00Z', reply: true) }
|
||||||
|
|
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
||||||
require 'securerandom'
|
require 'securerandom'
|
||||||
|
|
||||||
describe Request do
|
describe Request do
|
||||||
subject { Request.new(:get, 'http://example.com') }
|
subject { described_class.new(:get, 'http://example.com') }
|
||||||
|
|
||||||
describe '#headers' do
|
describe '#headers' do
|
||||||
it 'returns user agent' do
|
it 'returns user agent' do
|
||||||
|
|
|
@ -16,15 +16,15 @@ RSpec.describe TagManager do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for nil' do
|
it 'returns true for nil' do
|
||||||
expect(TagManager.instance.local_domain?(nil)).to be true
|
expect(described_class.instance.local_domain?(nil)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true if the slash-stripped string equals to local domain' do
|
it 'returns true if the slash-stripped string equals to local domain' do
|
||||||
expect(TagManager.instance.local_domain?('DoMaIn.Example.com/')).to be true
|
expect(described_class.instance.local_domain?('DoMaIn.Example.com/')).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false for irrelevant string' do
|
it 'returns false for irrelevant string' do
|
||||||
expect(TagManager.instance.local_domain?('DoMaIn.Example.com!')).to be false
|
expect(described_class.instance.local_domain?('DoMaIn.Example.com!')).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,25 +41,25 @@ RSpec.describe TagManager do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for nil' do
|
it 'returns true for nil' do
|
||||||
expect(TagManager.instance.web_domain?(nil)).to be true
|
expect(described_class.instance.web_domain?(nil)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true if the slash-stripped string equals to web domain' do
|
it 'returns true if the slash-stripped string equals to web domain' do
|
||||||
expect(TagManager.instance.web_domain?('DoMaIn.Example.com/')).to be true
|
expect(described_class.instance.web_domain?('DoMaIn.Example.com/')).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false for string with irrelevant characters' do
|
it 'returns false for string with irrelevant characters' do
|
||||||
expect(TagManager.instance.web_domain?('DoMaIn.Example.com!')).to be false
|
expect(described_class.instance.web_domain?('DoMaIn.Example.com!')).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#normalize_domain' do
|
describe '#normalize_domain' do
|
||||||
it 'returns nil if the given parameter is nil' do
|
it 'returns nil if the given parameter is nil' do
|
||||||
expect(TagManager.instance.normalize_domain(nil)).to be_nil
|
expect(described_class.instance.normalize_domain(nil)).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns normalized domain' do
|
it 'returns normalized domain' do
|
||||||
expect(TagManager.instance.normalize_domain('DoMaIn.Example.com/')).to eq 'domain.example.com'
|
expect(described_class.instance.normalize_domain('DoMaIn.Example.com/')).to eq 'domain.example.com'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -72,17 +72,17 @@ RSpec.describe TagManager do
|
||||||
|
|
||||||
it 'returns true if the normalized string with port is local URL' do
|
it 'returns true if the normalized string with port is local URL' do
|
||||||
Rails.configuration.x.web_domain = 'domain.example.com:42'
|
Rails.configuration.x.web_domain = 'domain.example.com:42'
|
||||||
expect(TagManager.instance.local_url?('https://DoMaIn.Example.com:42/')).to be true
|
expect(described_class.instance.local_url?('https://DoMaIn.Example.com:42/')).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true if the normalized string without port is local URL' do
|
it 'returns true if the normalized string without port is local URL' do
|
||||||
Rails.configuration.x.web_domain = 'domain.example.com'
|
Rails.configuration.x.web_domain = 'domain.example.com'
|
||||||
expect(TagManager.instance.local_url?('https://DoMaIn.Example.com/')).to be true
|
expect(described_class.instance.local_url?('https://DoMaIn.Example.com/')).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false for string with irrelevant characters' do
|
it 'returns false for string with irrelevant characters' do
|
||||||
Rails.configuration.x.web_domain = 'domain.example.com'
|
Rails.configuration.x.web_domain = 'domain.example.com'
|
||||||
expect(TagManager.instance.local_url?('https://domain.example.net/')).to be false
|
expect(described_class.instance.local_url?('https://domain.example.net/')).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ describe WebfingerResource do
|
||||||
resource = 'https://example.com/users/alice/other'
|
resource = 'https://example.com/users/alice/other'
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
WebfingerResource.new(resource).username
|
described_class.new(resource).username
|
||||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ describe WebfingerResource do
|
||||||
expect(Rails.application.routes).to receive(:recognize_path).with(resource).and_return(recognized).at_least(:once)
|
expect(Rails.application.routes).to receive(:recognize_path).with(resource).and_return(recognized).at_least(:once)
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
WebfingerResource.new(resource).username
|
described_class.new(resource).username
|
||||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -40,28 +40,28 @@ describe WebfingerResource do
|
||||||
resource = 'website for http://example.com/users/alice/other'
|
resource = 'website for http://example.com/users/alice/other'
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
WebfingerResource.new(resource).username
|
described_class.new(resource).username
|
||||||
end.to raise_error(WebfingerResource::InvalidRequest)
|
end.to raise_error(WebfingerResource::InvalidRequest)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'finds the username in a valid https route' do
|
it 'finds the username in a valid https route' do
|
||||||
resource = 'https://example.com/users/alice'
|
resource = 'https://example.com/users/alice'
|
||||||
|
|
||||||
result = WebfingerResource.new(resource).username
|
result = described_class.new(resource).username
|
||||||
expect(result).to eq 'alice'
|
expect(result).to eq 'alice'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'finds the username in a mixed case http route' do
|
it 'finds the username in a mixed case http route' do
|
||||||
resource = 'HTTp://exAMPLe.com/users/alice'
|
resource = 'HTTp://exAMPLe.com/users/alice'
|
||||||
|
|
||||||
result = WebfingerResource.new(resource).username
|
result = described_class.new(resource).username
|
||||||
expect(result).to eq 'alice'
|
expect(result).to eq 'alice'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'finds the username in a valid http route' do
|
it 'finds the username in a valid http route' do
|
||||||
resource = 'http://example.com/users/alice'
|
resource = 'http://example.com/users/alice'
|
||||||
|
|
||||||
result = WebfingerResource.new(resource).username
|
result = described_class.new(resource).username
|
||||||
expect(result).to eq 'alice'
|
expect(result).to eq 'alice'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -71,7 +71,7 @@ describe WebfingerResource do
|
||||||
resource = 'user@remote-host.com'
|
resource = 'user@remote-host.com'
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
WebfingerResource.new(resource).username
|
described_class.new(resource).username
|
||||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ describe WebfingerResource do
|
||||||
Rails.configuration.x.local_domain = 'example.com'
|
Rails.configuration.x.local_domain = 'example.com'
|
||||||
resource = 'alice@example.com'
|
resource = 'alice@example.com'
|
||||||
|
|
||||||
result = WebfingerResource.new(resource).username
|
result = described_class.new(resource).username
|
||||||
expect(result).to eq 'alice'
|
expect(result).to eq 'alice'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ describe WebfingerResource do
|
||||||
Rails.configuration.x.web_domain = 'example.com'
|
Rails.configuration.x.web_domain = 'example.com'
|
||||||
resource = 'alice@example.com'
|
resource = 'alice@example.com'
|
||||||
|
|
||||||
result = WebfingerResource.new(resource).username
|
result = described_class.new(resource).username
|
||||||
expect(result).to eq 'alice'
|
expect(result).to eq 'alice'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -97,7 +97,7 @@ describe WebfingerResource do
|
||||||
resource = 'acct:user@remote-host.com'
|
resource = 'acct:user@remote-host.com'
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
WebfingerResource.new(resource).username
|
described_class.new(resource).username
|
||||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ describe WebfingerResource do
|
||||||
resource = 'acct:user@remote-host@remote-hostess.remote.local@remote'
|
resource = 'acct:user@remote-host@remote-hostess.remote.local@remote'
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
WebfingerResource.new(resource).username
|
described_class.new(resource).username
|
||||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ describe WebfingerResource do
|
||||||
Rails.configuration.x.local_domain = 'example.com'
|
Rails.configuration.x.local_domain = 'example.com'
|
||||||
resource = 'acct:alice@example.com'
|
resource = 'acct:alice@example.com'
|
||||||
|
|
||||||
result = WebfingerResource.new(resource).username
|
result = described_class.new(resource).username
|
||||||
expect(result).to eq 'alice'
|
expect(result).to eq 'alice'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ describe WebfingerResource do
|
||||||
Rails.configuration.x.web_domain = 'example.com'
|
Rails.configuration.x.web_domain = 'example.com'
|
||||||
resource = 'acct:alice@example.com'
|
resource = 'acct:alice@example.com'
|
||||||
|
|
||||||
result = WebfingerResource.new(resource).username
|
result = described_class.new(resource).username
|
||||||
expect(result).to eq 'alice'
|
expect(result).to eq 'alice'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -131,7 +131,7 @@ describe WebfingerResource do
|
||||||
resource = 'df/:dfkj'
|
resource = 'df/:dfkj'
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
WebfingerResource.new(resource).username
|
described_class.new(resource).username
|
||||||
end.to raise_error(WebfingerResource::InvalidRequest)
|
end.to raise_error(WebfingerResource::InvalidRequest)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,7 @@ RSpec.describe NotificationMailer do
|
||||||
|
|
||||||
describe 'mention' do
|
describe 'mention' do
|
||||||
let(:mention) { Mention.create!(account: receiver.account, status: foreign_status) }
|
let(:mention) { Mention.create!(account: receiver.account, status: foreign_status) }
|
||||||
let(:mail) { NotificationMailer.mention(receiver.account, Notification.create!(account: receiver.account, activity: mention)) }
|
let(:mail) { described_class.mention(receiver.account, Notification.create!(account: receiver.account, activity: mention)) }
|
||||||
|
|
||||||
include_examples 'localized subject', 'notification_mailer.mention.subject', name: 'bob'
|
include_examples 'localized subject', 'notification_mailer.mention.subject', name: 'bob'
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ RSpec.describe NotificationMailer do
|
||||||
|
|
||||||
describe 'follow' do
|
describe 'follow' do
|
||||||
let(:follow) { sender.follow!(receiver.account) }
|
let(:follow) { sender.follow!(receiver.account) }
|
||||||
let(:mail) { NotificationMailer.follow(receiver.account, Notification.create!(account: receiver.account, activity: follow)) }
|
let(:mail) { described_class.follow(receiver.account, Notification.create!(account: receiver.account, activity: follow)) }
|
||||||
|
|
||||||
include_examples 'localized subject', 'notification_mailer.follow.subject', name: 'bob'
|
include_examples 'localized subject', 'notification_mailer.follow.subject', name: 'bob'
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ RSpec.describe NotificationMailer do
|
||||||
|
|
||||||
describe 'favourite' do
|
describe 'favourite' do
|
||||||
let(:favourite) { Favourite.create!(account: sender, status: own_status) }
|
let(:favourite) { Favourite.create!(account: sender, status: own_status) }
|
||||||
let(:mail) { NotificationMailer.favourite(own_status.account, Notification.create!(account: receiver.account, activity: favourite)) }
|
let(:mail) { described_class.favourite(own_status.account, Notification.create!(account: receiver.account, activity: favourite)) }
|
||||||
|
|
||||||
include_examples 'localized subject', 'notification_mailer.favourite.subject', name: 'bob'
|
include_examples 'localized subject', 'notification_mailer.favourite.subject', name: 'bob'
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ RSpec.describe NotificationMailer do
|
||||||
|
|
||||||
describe 'reblog' do
|
describe 'reblog' do
|
||||||
let(:reblog) { Status.create!(account: sender, reblog: own_status) }
|
let(:reblog) { Status.create!(account: sender, reblog: own_status) }
|
||||||
let(:mail) { NotificationMailer.reblog(own_status.account, Notification.create!(account: receiver.account, activity: reblog)) }
|
let(:mail) { described_class.reblog(own_status.account, Notification.create!(account: receiver.account, activity: reblog)) }
|
||||||
|
|
||||||
include_examples 'localized subject', 'notification_mailer.reblog.subject', name: 'bob'
|
include_examples 'localized subject', 'notification_mailer.reblog.subject', name: 'bob'
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ RSpec.describe NotificationMailer do
|
||||||
|
|
||||||
describe 'follow_request' do
|
describe 'follow_request' do
|
||||||
let(:follow_request) { Fabricate(:follow_request, account: sender, target_account: receiver.account) }
|
let(:follow_request) { Fabricate(:follow_request, account: sender, target_account: receiver.account) }
|
||||||
let(:mail) { NotificationMailer.follow_request(receiver.account, Notification.create!(account: receiver.account, activity: follow_request)) }
|
let(:mail) { described_class.follow_request(receiver.account, Notification.create!(account: receiver.account, activity: follow_request)) }
|
||||||
|
|
||||||
include_examples 'localized subject', 'notification_mailer.follow_request.subject', name: 'bob'
|
include_examples 'localized subject', 'notification_mailer.follow_request.subject', name: 'bob'
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe UserMailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'confirmation_instructions' do
|
describe 'confirmation_instructions' do
|
||||||
let(:mail) { UserMailer.confirmation_instructions(receiver, 'spec') }
|
let(:mail) { described_class.confirmation_instructions(receiver, 'spec') }
|
||||||
|
|
||||||
it 'renders confirmation instructions' do
|
it 'renders confirmation instructions' do
|
||||||
receiver.update!(locale: nil)
|
receiver.update!(locale: nil)
|
||||||
|
@ -34,7 +34,7 @@ describe UserMailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'reconfirmation_instructions' do
|
describe 'reconfirmation_instructions' do
|
||||||
let(:mail) { UserMailer.confirmation_instructions(receiver, 'spec') }
|
let(:mail) { described_class.confirmation_instructions(receiver, 'spec') }
|
||||||
|
|
||||||
it 'renders reconfirmation instructions' do
|
it 'renders reconfirmation instructions' do
|
||||||
receiver.update!(email: 'new-email@example.com', locale: nil)
|
receiver.update!(email: 'new-email@example.com', locale: nil)
|
||||||
|
@ -48,7 +48,7 @@ describe UserMailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'reset_password_instructions' do
|
describe 'reset_password_instructions' do
|
||||||
let(:mail) { UserMailer.reset_password_instructions(receiver, 'spec') }
|
let(:mail) { described_class.reset_password_instructions(receiver, 'spec') }
|
||||||
|
|
||||||
it 'renders reset password instructions' do
|
it 'renders reset password instructions' do
|
||||||
receiver.update!(locale: nil)
|
receiver.update!(locale: nil)
|
||||||
|
@ -61,7 +61,7 @@ describe UserMailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'password_change' do
|
describe 'password_change' do
|
||||||
let(:mail) { UserMailer.password_change(receiver) }
|
let(:mail) { described_class.password_change(receiver) }
|
||||||
|
|
||||||
it 'renders password change notification' do
|
it 'renders password change notification' do
|
||||||
receiver.update!(locale: nil)
|
receiver.update!(locale: nil)
|
||||||
|
@ -73,7 +73,7 @@ describe UserMailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'email_changed' do
|
describe 'email_changed' do
|
||||||
let(:mail) { UserMailer.email_changed(receiver) }
|
let(:mail) { described_class.email_changed(receiver) }
|
||||||
|
|
||||||
it 'renders email change notification' do
|
it 'renders email change notification' do
|
||||||
receiver.update!(locale: nil)
|
receiver.update!(locale: nil)
|
||||||
|
@ -86,7 +86,7 @@ describe UserMailer do
|
||||||
|
|
||||||
describe 'warning' do
|
describe 'warning' do
|
||||||
let(:strike) { Fabricate(:account_warning, target_account: receiver.account, text: 'dont worry its just the testsuite', action: 'suspend') }
|
let(:strike) { Fabricate(:account_warning, target_account: receiver.account, text: 'dont worry its just the testsuite', action: 'suspend') }
|
||||||
let(:mail) { UserMailer.warning(receiver, strike) }
|
let(:mail) { described_class.warning(receiver, strike) }
|
||||||
|
|
||||||
it 'renders warning notification' do
|
it 'renders warning notification' do
|
||||||
receiver.update!(locale: nil)
|
receiver.update!(locale: nil)
|
||||||
|
@ -97,7 +97,7 @@ describe UserMailer do
|
||||||
|
|
||||||
describe 'webauthn_credential_deleted' do
|
describe 'webauthn_credential_deleted' do
|
||||||
let(:credential) { Fabricate(:webauthn_credential, user_id: receiver.id) }
|
let(:credential) { Fabricate(:webauthn_credential, user_id: receiver.id) }
|
||||||
let(:mail) { UserMailer.webauthn_credential_deleted(receiver, credential) }
|
let(:mail) { described_class.webauthn_credential_deleted(receiver, credential) }
|
||||||
|
|
||||||
it 'renders webauthn credential deleted notification' do
|
it 'renders webauthn credential deleted notification' do
|
||||||
receiver.update!(locale: nil)
|
receiver.update!(locale: nil)
|
||||||
|
@ -112,7 +112,7 @@ describe UserMailer do
|
||||||
let(:ip) { '192.168.0.1' }
|
let(:ip) { '192.168.0.1' }
|
||||||
let(:agent) { 'NCSA_Mosaic/2.0 (Windows 3.1)' }
|
let(:agent) { 'NCSA_Mosaic/2.0 (Windows 3.1)' }
|
||||||
let(:timestamp) { Time.now.utc }
|
let(:timestamp) { Time.now.utc }
|
||||||
let(:mail) { UserMailer.suspicious_sign_in(receiver, ip, agent, timestamp) }
|
let(:mail) { described_class.suspicious_sign_in(receiver, ip, agent, timestamp) }
|
||||||
|
|
||||||
it 'renders suspicious sign in notification' do
|
it 'renders suspicious sign in notification' do
|
||||||
receiver.update!(locale: nil)
|
receiver.update!(locale: nil)
|
||||||
|
@ -125,7 +125,7 @@ describe UserMailer do
|
||||||
|
|
||||||
describe 'appeal_approved' do
|
describe 'appeal_approved' do
|
||||||
let(:appeal) { Fabricate(:appeal, account: receiver.account, approved_at: Time.now.utc) }
|
let(:appeal) { Fabricate(:appeal, account: receiver.account, approved_at: Time.now.utc) }
|
||||||
let(:mail) { UserMailer.appeal_approved(receiver, appeal) }
|
let(:mail) { described_class.appeal_approved(receiver, appeal) }
|
||||||
|
|
||||||
it 'renders appeal_approved notification' do
|
it 'renders appeal_approved notification' do
|
||||||
expect(mail.subject).to eq I18n.t('user_mailer.appeal_approved.subject', date: I18n.l(appeal.created_at))
|
expect(mail.subject).to eq I18n.t('user_mailer.appeal_approved.subject', date: I18n.l(appeal.created_at))
|
||||||
|
@ -135,7 +135,7 @@ describe UserMailer do
|
||||||
|
|
||||||
describe 'appeal_rejected' do
|
describe 'appeal_rejected' do
|
||||||
let(:appeal) { Fabricate(:appeal, account: receiver.account, rejected_at: Time.now.utc) }
|
let(:appeal) { Fabricate(:appeal, account: receiver.account, rejected_at: Time.now.utc) }
|
||||||
let(:mail) { UserMailer.appeal_rejected(receiver, appeal) }
|
let(:mail) { described_class.appeal_rejected(receiver, appeal) }
|
||||||
|
|
||||||
it 'renders appeal_rejected notification' do
|
it 'renders appeal_rejected notification' do
|
||||||
expect(mail.subject).to eq I18n.t('user_mailer.appeal_rejected.subject', date: I18n.l(appeal.created_at))
|
expect(mail.subject).to eq I18n.t('user_mailer.appeal_rejected.subject', date: I18n.l(appeal.created_at))
|
||||||
|
|
|
@ -12,7 +12,7 @@ RSpec.describe AccountConversation do
|
||||||
status = Fabricate(:status, account: alice, visibility: :direct)
|
status = Fabricate(:status, account: alice, visibility: :direct)
|
||||||
status.mentions.create(account: bob)
|
status.mentions.create(account: bob)
|
||||||
|
|
||||||
conversation = AccountConversation.add_status(alice, status)
|
conversation = described_class.add_status(alice, status)
|
||||||
|
|
||||||
expect(conversation.participant_accounts).to include(bob)
|
expect(conversation.participant_accounts).to include(bob)
|
||||||
expect(conversation.last_status).to eq status
|
expect(conversation.last_status).to eq status
|
||||||
|
@ -21,12 +21,12 @@ RSpec.describe AccountConversation do
|
||||||
|
|
||||||
it 'appends to old record when there is a match' do
|
it 'appends to old record when there is a match' do
|
||||||
last_status = Fabricate(:status, account: alice, visibility: :direct)
|
last_status = Fabricate(:status, account: alice, visibility: :direct)
|
||||||
conversation = AccountConversation.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id])
|
conversation = described_class.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id])
|
||||||
|
|
||||||
status = Fabricate(:status, account: bob, visibility: :direct, thread: last_status)
|
status = Fabricate(:status, account: bob, visibility: :direct, thread: last_status)
|
||||||
status.mentions.create(account: alice)
|
status.mentions.create(account: alice)
|
||||||
|
|
||||||
new_conversation = AccountConversation.add_status(alice, status)
|
new_conversation = described_class.add_status(alice, status)
|
||||||
|
|
||||||
expect(new_conversation.id).to eq conversation.id
|
expect(new_conversation.id).to eq conversation.id
|
||||||
expect(new_conversation.participant_accounts).to include(bob)
|
expect(new_conversation.participant_accounts).to include(bob)
|
||||||
|
@ -36,13 +36,13 @@ RSpec.describe AccountConversation do
|
||||||
|
|
||||||
it 'creates new record when new participants are added' do
|
it 'creates new record when new participants are added' do
|
||||||
last_status = Fabricate(:status, account: alice, visibility: :direct)
|
last_status = Fabricate(:status, account: alice, visibility: :direct)
|
||||||
conversation = AccountConversation.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id])
|
conversation = described_class.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id])
|
||||||
|
|
||||||
status = Fabricate(:status, account: bob, visibility: :direct, thread: last_status)
|
status = Fabricate(:status, account: bob, visibility: :direct, thread: last_status)
|
||||||
status.mentions.create(account: alice)
|
status.mentions.create(account: alice)
|
||||||
status.mentions.create(account: mark)
|
status.mentions.create(account: mark)
|
||||||
|
|
||||||
new_conversation = AccountConversation.add_status(alice, status)
|
new_conversation = described_class.add_status(alice, status)
|
||||||
|
|
||||||
expect(new_conversation.id).to_not eq conversation.id
|
expect(new_conversation.id).to_not eq conversation.id
|
||||||
expect(new_conversation.participant_accounts).to include(bob, mark)
|
expect(new_conversation.participant_accounts).to include(bob, mark)
|
||||||
|
@ -55,7 +55,7 @@ RSpec.describe AccountConversation do
|
||||||
it 'updates last status to a previous value' do
|
it 'updates last status to a previous value' do
|
||||||
last_status = Fabricate(:status, account: alice, visibility: :direct)
|
last_status = Fabricate(:status, account: alice, visibility: :direct)
|
||||||
status = Fabricate(:status, account: alice, visibility: :direct)
|
status = Fabricate(:status, account: alice, visibility: :direct)
|
||||||
conversation = AccountConversation.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [status.id, last_status.id])
|
conversation = described_class.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [status.id, last_status.id])
|
||||||
last_status.mentions.create(account: bob)
|
last_status.mentions.create(account: bob)
|
||||||
last_status.destroy!
|
last_status.destroy!
|
||||||
conversation.reload
|
conversation.reload
|
||||||
|
@ -65,10 +65,10 @@ RSpec.describe AccountConversation do
|
||||||
|
|
||||||
it 'removes the record if no other statuses are referenced' do
|
it 'removes the record if no other statuses are referenced' do
|
||||||
last_status = Fabricate(:status, account: alice, visibility: :direct)
|
last_status = Fabricate(:status, account: alice, visibility: :direct)
|
||||||
conversation = AccountConversation.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id])
|
conversation = described_class.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id])
|
||||||
last_status.mentions.create(account: bob)
|
last_status.mentions.create(account: bob)
|
||||||
last_status.destroy!
|
last_status.destroy!
|
||||||
expect(AccountConversation.where(id: conversation.id).count).to eq 0
|
expect(described_class.where(id: conversation.id).count).to eq 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,14 +7,14 @@ RSpec.describe AccountDomainBlock do
|
||||||
account = Fabricate(:account)
|
account = Fabricate(:account)
|
||||||
Rails.cache.write("exclude_domains_for:#{account.id}", 'a.domain.already.blocked')
|
Rails.cache.write("exclude_domains_for:#{account.id}", 'a.domain.already.blocked')
|
||||||
|
|
||||||
AccountDomainBlock.create!(account: account, domain: 'a.domain.blocked.later')
|
described_class.create!(account: account, domain: 'a.domain.blocked.later')
|
||||||
|
|
||||||
expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to be false
|
expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'removes blocking cache after destruction' do
|
it 'removes blocking cache after destruction' do
|
||||||
account = Fabricate(:account)
|
account = Fabricate(:account)
|
||||||
block = AccountDomainBlock.create!(account: account, domain: 'domain')
|
block = described_class.create!(account: account, domain: 'domain')
|
||||||
Rails.cache.write("exclude_domains_for:#{account.id}", 'domain')
|
Rails.cache.write("exclude_domains_for:#{account.id}", 'domain')
|
||||||
|
|
||||||
block.destroy!
|
block.destroy!
|
||||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe AccountMigration do
|
||||||
let(:source_account) { Fabricate(:account) }
|
let(:source_account) { Fabricate(:account) }
|
||||||
let(:target_acct) { target_account.acct }
|
let(:target_acct) { target_account.acct }
|
||||||
|
|
||||||
let(:subject) { AccountMigration.new(account: source_account, acct: target_acct) }
|
let(:subject) { described_class.new(account: source_account, acct: target_acct) }
|
||||||
|
|
||||||
context 'with valid properties' do
|
context 'with valid properties' do
|
||||||
let(:target_account) { Fabricate(:account, username: 'target', domain: 'remote.org') }
|
let(:target_account) { Fabricate(:account, username: 'target', domain: 'remote.org') }
|
||||||
|
|
|
@ -362,7 +362,7 @@ RSpec.describe Account do
|
||||||
suspended: true
|
suspended: true
|
||||||
)
|
)
|
||||||
|
|
||||||
results = Account.search_for('username')
|
results = described_class.search_for('username')
|
||||||
expect(results).to eq []
|
expect(results).to eq []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ RSpec.describe Account do
|
||||||
|
|
||||||
match.user.update(approved: false)
|
match.user.update(approved: false)
|
||||||
|
|
||||||
results = Account.search_for('username')
|
results = described_class.search_for('username')
|
||||||
expect(results).to eq []
|
expect(results).to eq []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ RSpec.describe Account do
|
||||||
|
|
||||||
match.user.update(confirmed_at: nil)
|
match.user.update(confirmed_at: nil)
|
||||||
|
|
||||||
results = Account.search_for('username')
|
results = described_class.search_for('username')
|
||||||
expect(results).to eq []
|
expect(results).to eq []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ RSpec.describe Account do
|
||||||
domain: 'example.com'
|
domain: 'example.com'
|
||||||
)
|
)
|
||||||
|
|
||||||
results = Account.search_for('A?l\i:c e')
|
results = described_class.search_for('A?l\i:c e')
|
||||||
expect(results).to eq [match]
|
expect(results).to eq [match]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -412,7 +412,7 @@ RSpec.describe Account do
|
||||||
domain: 'example.com'
|
domain: 'example.com'
|
||||||
)
|
)
|
||||||
|
|
||||||
results = Account.search_for('display')
|
results = described_class.search_for('display')
|
||||||
expect(results).to eq [match]
|
expect(results).to eq [match]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ RSpec.describe Account do
|
||||||
domain: 'example.com'
|
domain: 'example.com'
|
||||||
)
|
)
|
||||||
|
|
||||||
results = Account.search_for('username')
|
results = described_class.search_for('username')
|
||||||
expect(results).to eq [match]
|
expect(results).to eq [match]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -436,19 +436,19 @@ RSpec.describe Account do
|
||||||
domain: 'example.com'
|
domain: 'example.com'
|
||||||
)
|
)
|
||||||
|
|
||||||
results = Account.search_for('example')
|
results = described_class.search_for('example')
|
||||||
expect(results).to eq [match]
|
expect(results).to eq [match]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'limits by 10 by default' do
|
it 'limits by 10 by default' do
|
||||||
11.times.each { Fabricate(:account, display_name: 'Display Name') }
|
11.times.each { Fabricate(:account, display_name: 'Display Name') }
|
||||||
results = Account.search_for('display')
|
results = described_class.search_for('display')
|
||||||
expect(results.size).to eq 10
|
expect(results.size).to eq 10
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'accepts arbitrary limits' do
|
it 'accepts arbitrary limits' do
|
||||||
2.times.each { Fabricate(:account, display_name: 'Display Name') }
|
2.times.each { Fabricate(:account, display_name: 'Display Name') }
|
||||||
results = Account.search_for('display', limit: 1)
|
results = described_class.search_for('display', limit: 1)
|
||||||
expect(results.size).to eq 1
|
expect(results.size).to eq 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ RSpec.describe Account do
|
||||||
{ display_name: 'Display Name', username: 'username', domain: 'example.com' },
|
{ display_name: 'Display Name', username: 'username', domain: 'example.com' },
|
||||||
].map(&method(:Fabricate).curry(2).call(:account))
|
].map(&method(:Fabricate).curry(2).call(:account))
|
||||||
|
|
||||||
results = Account.search_for('username')
|
results = described_class.search_for('username')
|
||||||
expect(results).to eq matches
|
expect(results).to eq matches
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -476,7 +476,7 @@ RSpec.describe Account do
|
||||||
)
|
)
|
||||||
account.follow!(match)
|
account.follow!(match)
|
||||||
|
|
||||||
results = Account.advanced_search_for('A?l\i:c e', account, limit: 10, following: true)
|
results = described_class.advanced_search_for('A?l\i:c e', account, limit: 10, following: true)
|
||||||
expect(results).to eq [match]
|
expect(results).to eq [match]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ RSpec.describe Account do
|
||||||
domain: 'example.com'
|
domain: 'example.com'
|
||||||
)
|
)
|
||||||
|
|
||||||
results = Account.advanced_search_for('A?l\i:c e', account, limit: 10, following: true)
|
results = described_class.advanced_search_for('A?l\i:c e', account, limit: 10, following: true)
|
||||||
expect(results).to eq []
|
expect(results).to eq []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ RSpec.describe Account do
|
||||||
suspended: true
|
suspended: true
|
||||||
)
|
)
|
||||||
|
|
||||||
results = Account.advanced_search_for('username', account, limit: 10, following: true)
|
results = described_class.advanced_search_for('username', account, limit: 10, following: true)
|
||||||
expect(results).to eq []
|
expect(results).to eq []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -514,7 +514,7 @@ RSpec.describe Account do
|
||||||
|
|
||||||
match.user.update(approved: false)
|
match.user.update(approved: false)
|
||||||
|
|
||||||
results = Account.advanced_search_for('username', account, limit: 10, following: true)
|
results = described_class.advanced_search_for('username', account, limit: 10, following: true)
|
||||||
expect(results).to eq []
|
expect(results).to eq []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -527,7 +527,7 @@ RSpec.describe Account do
|
||||||
|
|
||||||
match.user.update(confirmed_at: nil)
|
match.user.update(confirmed_at: nil)
|
||||||
|
|
||||||
results = Account.advanced_search_for('username', account, limit: 10, following: true)
|
results = described_class.advanced_search_for('username', account, limit: 10, following: true)
|
||||||
expect(results).to eq []
|
expect(results).to eq []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -541,7 +541,7 @@ RSpec.describe Account do
|
||||||
suspended: true
|
suspended: true
|
||||||
)
|
)
|
||||||
|
|
||||||
results = Account.advanced_search_for('username', account)
|
results = described_class.advanced_search_for('username', account)
|
||||||
expect(results).to eq []
|
expect(results).to eq []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -554,7 +554,7 @@ RSpec.describe Account do
|
||||||
|
|
||||||
match.user.update(approved: false)
|
match.user.update(approved: false)
|
||||||
|
|
||||||
results = Account.advanced_search_for('username', account)
|
results = described_class.advanced_search_for('username', account)
|
||||||
expect(results).to eq []
|
expect(results).to eq []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -567,7 +567,7 @@ RSpec.describe Account do
|
||||||
|
|
||||||
match.user.update(confirmed_at: nil)
|
match.user.update(confirmed_at: nil)
|
||||||
|
|
||||||
results = Account.advanced_search_for('username', account)
|
results = described_class.advanced_search_for('username', account)
|
||||||
expect(results).to eq []
|
expect(results).to eq []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -579,19 +579,19 @@ RSpec.describe Account do
|
||||||
domain: 'example.com'
|
domain: 'example.com'
|
||||||
)
|
)
|
||||||
|
|
||||||
results = Account.advanced_search_for('A?l\i:c e', account)
|
results = described_class.advanced_search_for('A?l\i:c e', account)
|
||||||
expect(results).to eq [match]
|
expect(results).to eq [match]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'limits by 10 by default' do
|
it 'limits by 10 by default' do
|
||||||
11.times { Fabricate(:account, display_name: 'Display Name') }
|
11.times { Fabricate(:account, display_name: 'Display Name') }
|
||||||
results = Account.advanced_search_for('display', account)
|
results = described_class.advanced_search_for('display', account)
|
||||||
expect(results.size).to eq 10
|
expect(results.size).to eq 10
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'accepts arbitrary limits' do
|
it 'accepts arbitrary limits' do
|
||||||
2.times { Fabricate(:account, display_name: 'Display Name') }
|
2.times { Fabricate(:account, display_name: 'Display Name') }
|
||||||
results = Account.advanced_search_for('display', account, limit: 1)
|
results = described_class.advanced_search_for('display', account, limit: 1)
|
||||||
expect(results.size).to eq 1
|
expect(results.size).to eq 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -600,7 +600,7 @@ RSpec.describe Account do
|
||||||
followed_match = Fabricate(:account, username: 'Matcher')
|
followed_match = Fabricate(:account, username: 'Matcher')
|
||||||
Fabricate(:follow, account: account, target_account: followed_match)
|
Fabricate(:follow, account: account, target_account: followed_match)
|
||||||
|
|
||||||
results = Account.advanced_search_for('match', account)
|
results = described_class.advanced_search_for('match', account)
|
||||||
expect(results).to eq [followed_match, match]
|
expect(results).to eq [followed_match, match]
|
||||||
expect(results.first.rank).to be > results.last.rank
|
expect(results.first.rank).to be > results.last.rank
|
||||||
end
|
end
|
||||||
|
@ -639,31 +639,31 @@ RSpec.describe Account do
|
||||||
|
|
||||||
describe '.following_map' do
|
describe '.following_map' do
|
||||||
it 'returns an hash' do
|
it 'returns an hash' do
|
||||||
expect(Account.following_map([], 1)).to be_a Hash
|
expect(described_class.following_map([], 1)).to be_a Hash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.followed_by_map' do
|
describe '.followed_by_map' do
|
||||||
it 'returns an hash' do
|
it 'returns an hash' do
|
||||||
expect(Account.followed_by_map([], 1)).to be_a Hash
|
expect(described_class.followed_by_map([], 1)).to be_a Hash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.blocking_map' do
|
describe '.blocking_map' do
|
||||||
it 'returns an hash' do
|
it 'returns an hash' do
|
||||||
expect(Account.blocking_map([], 1)).to be_a Hash
|
expect(described_class.blocking_map([], 1)).to be_a Hash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.requested_map' do
|
describe '.requested_map' do
|
||||||
it 'returns an hash' do
|
it 'returns an hash' do
|
||||||
expect(Account.requested_map([], 1)).to be_a Hash
|
expect(described_class.requested_map([], 1)).to be_a Hash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.requested_by_map' do
|
describe '.requested_by_map' do
|
||||||
it 'returns an hash' do
|
it 'returns an hash' do
|
||||||
expect(Account.requested_by_map([], 1)).to be_a Hash
|
expect(described_class.requested_by_map([], 1)).to be_a Hash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -834,7 +834,7 @@ RSpec.describe Account do
|
||||||
{ username: 'b', domain: 'b' },
|
{ username: 'b', domain: 'b' },
|
||||||
].map(&method(:Fabricate).curry(2).call(:account))
|
].map(&method(:Fabricate).curry(2).call(:account))
|
||||||
|
|
||||||
expect(Account.where('id > 0').alphabetic).to eq matches
|
expect(described_class.where('id > 0').alphabetic).to eq matches
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -843,7 +843,7 @@ RSpec.describe Account do
|
||||||
match = Fabricate(:account, display_name: 'pattern and suffix')
|
match = Fabricate(:account, display_name: 'pattern and suffix')
|
||||||
Fabricate(:account, display_name: 'prefix and pattern')
|
Fabricate(:account, display_name: 'prefix and pattern')
|
||||||
|
|
||||||
expect(Account.matches_display_name('pattern')).to eq [match]
|
expect(described_class.matches_display_name('pattern')).to eq [match]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -852,24 +852,24 @@ RSpec.describe Account do
|
||||||
match = Fabricate(:account, username: 'pattern_and_suffix')
|
match = Fabricate(:account, username: 'pattern_and_suffix')
|
||||||
Fabricate(:account, username: 'prefix_and_pattern')
|
Fabricate(:account, username: 'prefix_and_pattern')
|
||||||
|
|
||||||
expect(Account.matches_username('pattern')).to eq [match]
|
expect(described_class.matches_username('pattern')).to eq [match]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'by_domain_and_subdomains' do
|
describe 'by_domain_and_subdomains' do
|
||||||
it 'returns exact domain matches' do
|
it 'returns exact domain matches' do
|
||||||
account = Fabricate(:account, domain: 'example.com')
|
account = Fabricate(:account, domain: 'example.com')
|
||||||
expect(Account.by_domain_and_subdomains('example.com')).to eq [account]
|
expect(described_class.by_domain_and_subdomains('example.com')).to eq [account]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns subdomains' do
|
it 'returns subdomains' do
|
||||||
account = Fabricate(:account, domain: 'foo.example.com')
|
account = Fabricate(:account, domain: 'foo.example.com')
|
||||||
expect(Account.by_domain_and_subdomains('example.com')).to eq [account]
|
expect(described_class.by_domain_and_subdomains('example.com')).to eq [account]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not return partially matching domains' do
|
it 'does not return partially matching domains' do
|
||||||
account = Fabricate(:account, domain: 'grexample.com')
|
account = Fabricate(:account, domain: 'grexample.com')
|
||||||
expect(Account.by_domain_and_subdomains('example.com')).to_not eq [account]
|
expect(described_class.by_domain_and_subdomains('example.com')).to_not eq [account]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -877,7 +877,7 @@ RSpec.describe Account do
|
||||||
it 'returns an array of accounts who have a domain' do
|
it 'returns an array of accounts who have a domain' do
|
||||||
account_1 = Fabricate(:account, domain: nil)
|
account_1 = Fabricate(:account, domain: nil)
|
||||||
account_2 = Fabricate(:account, domain: 'example.com')
|
account_2 = Fabricate(:account, domain: 'example.com')
|
||||||
expect(Account.remote).to contain_exactly(account_2)
|
expect(described_class.remote).to contain_exactly(account_2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -885,7 +885,7 @@ RSpec.describe Account do
|
||||||
it 'returns an array of accounts who do not have a domain' do
|
it 'returns an array of accounts who do not have a domain' do
|
||||||
account_1 = Fabricate(:account, domain: nil)
|
account_1 = Fabricate(:account, domain: nil)
|
||||||
account_2 = Fabricate(:account, domain: 'example.com')
|
account_2 = Fabricate(:account, domain: 'example.com')
|
||||||
expect(Account.where('id > 0').local).to contain_exactly(account_1)
|
expect(described_class.where('id > 0').local).to contain_exactly(account_1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -896,14 +896,14 @@ RSpec.describe Account do
|
||||||
matches[index] = Fabricate(:account, domain: matches[index])
|
matches[index] = Fabricate(:account, domain: matches[index])
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(Account.where('id > 0').partitioned).to match_array(matches)
|
expect(described_class.where('id > 0').partitioned).to match_array(matches)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'recent' do
|
describe 'recent' do
|
||||||
it 'returns a relation of accounts sorted by recent creation' do
|
it 'returns a relation of accounts sorted by recent creation' do
|
||||||
matches = Array.new(2) { Fabricate(:account) }
|
matches = Array.new(2) { Fabricate(:account) }
|
||||||
expect(Account.where('id > 0').recent).to match_array(matches)
|
expect(described_class.where('id > 0').recent).to match_array(matches)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -911,7 +911,7 @@ RSpec.describe Account do
|
||||||
it 'returns an array of accounts who are silenced' do
|
it 'returns an array of accounts who are silenced' do
|
||||||
account_1 = Fabricate(:account, silenced: true)
|
account_1 = Fabricate(:account, silenced: true)
|
||||||
account_2 = Fabricate(:account, silenced: false)
|
account_2 = Fabricate(:account, silenced: false)
|
||||||
expect(Account.silenced).to contain_exactly(account_1)
|
expect(described_class.silenced).to contain_exactly(account_1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -919,7 +919,7 @@ RSpec.describe Account do
|
||||||
it 'returns an array of accounts who are suspended' do
|
it 'returns an array of accounts who are suspended' do
|
||||||
account_1 = Fabricate(:account, suspended: true)
|
account_1 = Fabricate(:account, suspended: true)
|
||||||
account_2 = Fabricate(:account, suspended: false)
|
account_2 = Fabricate(:account, suspended: false)
|
||||||
expect(Account.suspended).to contain_exactly(account_1)
|
expect(described_class.suspended).to contain_exactly(account_1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -941,18 +941,18 @@ RSpec.describe Account do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns every usable non-suspended account' do
|
it 'returns every usable non-suspended account' do
|
||||||
expect(Account.searchable).to contain_exactly(silenced_local, silenced_remote, local_account, remote_account)
|
expect(described_class.searchable).to contain_exactly(silenced_local, silenced_remote, local_account, remote_account)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not mess with previously-applied scopes' do
|
it 'does not mess with previously-applied scopes' do
|
||||||
expect(Account.where.not(id: remote_account.id).searchable).to contain_exactly(silenced_local, silenced_remote, local_account)
|
expect(described_class.where.not(id: remote_account.id).searchable).to contain_exactly(silenced_local, silenced_remote, local_account)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when is local' do
|
context 'when is local' do
|
||||||
it 'generates keys' do
|
it 'generates keys' do
|
||||||
account = Account.create!(domain: nil, username: Faker::Internet.user_name(separators: ['_']))
|
account = described_class.create!(domain: nil, username: Faker::Internet.user_name(separators: ['_']))
|
||||||
expect(account.keypair).to be_private
|
expect(account.keypair).to be_private
|
||||||
expect(account.keypair).to be_public
|
expect(account.keypair).to be_public
|
||||||
end
|
end
|
||||||
|
@ -961,12 +961,12 @@ RSpec.describe Account do
|
||||||
context 'when is remote' do
|
context 'when is remote' do
|
||||||
it 'does not generate keys' do
|
it 'does not generate keys' do
|
||||||
key = OpenSSL::PKey::RSA.new(1024).public_key
|
key = OpenSSL::PKey::RSA.new(1024).public_key
|
||||||
account = Account.create!(domain: 'remote', username: Faker::Internet.user_name(separators: ['_']), public_key: key.to_pem)
|
account = described_class.create!(domain: 'remote', username: Faker::Internet.user_name(separators: ['_']), public_key: key.to_pem)
|
||||||
expect(account.keypair.params).to eq key.params
|
expect(account.keypair.params).to eq key.params
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'normalizes domain' do
|
it 'normalizes domain' do
|
||||||
account = Account.create!(domain: 'にゃん', username: Faker::Internet.user_name(separators: ['_']))
|
account = described_class.create!(domain: 'にゃん', username: Faker::Internet.user_name(separators: ['_']))
|
||||||
expect(account.domain).to eq 'xn--r9j5b5b'
|
expect(account.domain).to eq 'xn--r9j5b5b'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -986,7 +986,7 @@ RSpec.describe Account do
|
||||||
threads = Array.new(increment_by) do
|
threads = Array.new(increment_by) do
|
||||||
Thread.new do
|
Thread.new do
|
||||||
true while wait_for_start
|
true while wait_for_start
|
||||||
Account.find(subject.id).increment_count!(:followers_count)
|
described_class.find(subject.id).increment_count!(:followers_count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ RSpec.describe Block do
|
||||||
Rails.cache.write("exclude_account_ids_for:#{account.id}", [])
|
Rails.cache.write("exclude_account_ids_for:#{account.id}", [])
|
||||||
Rails.cache.write("exclude_account_ids_for:#{target_account.id}", [])
|
Rails.cache.write("exclude_account_ids_for:#{target_account.id}", [])
|
||||||
|
|
||||||
Block.create!(account: account, target_account: target_account)
|
described_class.create!(account: account, target_account: target_account)
|
||||||
|
|
||||||
expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to be false
|
expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to be false
|
||||||
expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to be false
|
expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to be false
|
||||||
|
@ -32,7 +32,7 @@ RSpec.describe Block do
|
||||||
it 'removes blocking cache after destruction' do
|
it 'removes blocking cache after destruction' do
|
||||||
account = Fabricate(:account)
|
account = Fabricate(:account)
|
||||||
target_account = Fabricate(:account)
|
target_account = Fabricate(:account)
|
||||||
block = Block.create!(account: account, target_account: target_account)
|
block = described_class.create!(account: account, target_account: target_account)
|
||||||
Rails.cache.write("exclude_account_ids_for:#{account.id}", [target_account.id])
|
Rails.cache.write("exclude_account_ids_for:#{account.id}", [target_account.id])
|
||||||
Rails.cache.write("exclude_account_ids_for:#{target_account.id}", [account.id])
|
Rails.cache.write("exclude_account_ids_for:#{target_account.id}", [account.id])
|
||||||
|
|
||||||
|
|
|
@ -21,73 +21,73 @@ RSpec.describe DomainBlock do
|
||||||
describe '.blocked?' do
|
describe '.blocked?' do
|
||||||
it 'returns true if the domain is suspended' do
|
it 'returns true if the domain is suspended' do
|
||||||
Fabricate(:domain_block, domain: 'example.com', severity: :suspend)
|
Fabricate(:domain_block, domain: 'example.com', severity: :suspend)
|
||||||
expect(DomainBlock.blocked?('example.com')).to be true
|
expect(described_class.blocked?('example.com')).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false even if the domain is silenced' do
|
it 'returns false even if the domain is silenced' do
|
||||||
Fabricate(:domain_block, domain: 'example.com', severity: :silence)
|
Fabricate(:domain_block, domain: 'example.com', severity: :silence)
|
||||||
expect(DomainBlock.blocked?('example.com')).to be false
|
expect(described_class.blocked?('example.com')).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false if the domain is not suspended nor silenced' do
|
it 'returns false if the domain is not suspended nor silenced' do
|
||||||
expect(DomainBlock.blocked?('example.com')).to be false
|
expect(described_class.blocked?('example.com')).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.rule_for' do
|
describe '.rule_for' do
|
||||||
it 'returns rule matching a blocked domain' do
|
it 'returns rule matching a blocked domain' do
|
||||||
block = Fabricate(:domain_block, domain: 'example.com')
|
block = Fabricate(:domain_block, domain: 'example.com')
|
||||||
expect(DomainBlock.rule_for('example.com')).to eq block
|
expect(described_class.rule_for('example.com')).to eq block
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a rule matching a subdomain of a blocked domain' do
|
it 'returns a rule matching a subdomain of a blocked domain' do
|
||||||
block = Fabricate(:domain_block, domain: 'example.com')
|
block = Fabricate(:domain_block, domain: 'example.com')
|
||||||
expect(DomainBlock.rule_for('sub.example.com')).to eq block
|
expect(described_class.rule_for('sub.example.com')).to eq block
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a rule matching a blocked subdomain' do
|
it 'returns a rule matching a blocked subdomain' do
|
||||||
block = Fabricate(:domain_block, domain: 'sub.example.com')
|
block = Fabricate(:domain_block, domain: 'sub.example.com')
|
||||||
expect(DomainBlock.rule_for('sub.example.com')).to eq block
|
expect(described_class.rule_for('sub.example.com')).to eq block
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a rule matching a blocked TLD' do
|
it 'returns a rule matching a blocked TLD' do
|
||||||
block = Fabricate(:domain_block, domain: 'google')
|
block = Fabricate(:domain_block, domain: 'google')
|
||||||
expect(DomainBlock.rule_for('google')).to eq block
|
expect(described_class.rule_for('google')).to eq block
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a rule matching a subdomain of a blocked TLD' do
|
it 'returns a rule matching a subdomain of a blocked TLD' do
|
||||||
block = Fabricate(:domain_block, domain: 'google')
|
block = Fabricate(:domain_block, domain: 'google')
|
||||||
expect(DomainBlock.rule_for('maps.google')).to eq block
|
expect(described_class.rule_for('maps.google')).to eq block
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#stricter_than?' do
|
describe '#stricter_than?' do
|
||||||
it 'returns true if the new block has suspend severity while the old has lower severity' do
|
it 'returns true if the new block has suspend severity while the old has lower severity' do
|
||||||
suspend = DomainBlock.new(domain: 'domain', severity: :suspend)
|
suspend = described_class.new(domain: 'domain', severity: :suspend)
|
||||||
silence = DomainBlock.new(domain: 'domain', severity: :silence)
|
silence = described_class.new(domain: 'domain', severity: :silence)
|
||||||
noop = DomainBlock.new(domain: 'domain', severity: :noop)
|
noop = described_class.new(domain: 'domain', severity: :noop)
|
||||||
expect(suspend.stricter_than?(silence)).to be true
|
expect(suspend.stricter_than?(silence)).to be true
|
||||||
expect(suspend.stricter_than?(noop)).to be true
|
expect(suspend.stricter_than?(noop)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false if the new block has lower severity than the old one' do
|
it 'returns false if the new block has lower severity than the old one' do
|
||||||
suspend = DomainBlock.new(domain: 'domain', severity: :suspend)
|
suspend = described_class.new(domain: 'domain', severity: :suspend)
|
||||||
silence = DomainBlock.new(domain: 'domain', severity: :silence)
|
silence = described_class.new(domain: 'domain', severity: :silence)
|
||||||
noop = DomainBlock.new(domain: 'domain', severity: :noop)
|
noop = described_class.new(domain: 'domain', severity: :noop)
|
||||||
expect(silence.stricter_than?(suspend)).to be false
|
expect(silence.stricter_than?(suspend)).to be false
|
||||||
expect(noop.stricter_than?(suspend)).to be false
|
expect(noop.stricter_than?(suspend)).to be false
|
||||||
expect(noop.stricter_than?(silence)).to be false
|
expect(noop.stricter_than?(silence)).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false if the new block does is less strict regarding reports' do
|
it 'returns false if the new block does is less strict regarding reports' do
|
||||||
older = DomainBlock.new(domain: 'domain', severity: :silence, reject_reports: true)
|
older = described_class.new(domain: 'domain', severity: :silence, reject_reports: true)
|
||||||
newer = DomainBlock.new(domain: 'domain', severity: :silence, reject_reports: false)
|
newer = described_class.new(domain: 'domain', severity: :silence, reject_reports: false)
|
||||||
expect(newer.stricter_than?(older)).to be false
|
expect(newer.stricter_than?(older)).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false if the new block does is less strict regarding media' do
|
it 'returns false if the new block does is less strict regarding media' do
|
||||||
older = DomainBlock.new(domain: 'domain', severity: :silence, reject_media: true)
|
older = described_class.new(domain: 'domain', severity: :silence, reject_media: true)
|
||||||
newer = DomainBlock.new(domain: 'domain', severity: :silence, reject_media: false)
|
newer = described_class.new(domain: 'domain', severity: :silence, reject_media: false)
|
||||||
expect(newer.stricter_than?(older)).to be false
|
expect(newer.stricter_than?(older)).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,12 +14,12 @@ RSpec.describe EmailDomainBlock do
|
||||||
|
|
||||||
it 'returns true if the domain is blocked' do
|
it 'returns true if the domain is blocked' do
|
||||||
Fabricate(:email_domain_block, domain: 'example.com')
|
Fabricate(:email_domain_block, domain: 'example.com')
|
||||||
expect(EmailDomainBlock.block?(input)).to be true
|
expect(described_class.block?(input)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false if the domain is not blocked' do
|
it 'returns false if the domain is not blocked' do
|
||||||
Fabricate(:email_domain_block, domain: 'other-example.com')
|
Fabricate(:email_domain_block, domain: 'other-example.com')
|
||||||
expect(EmailDomainBlock.block?(input)).to be false
|
expect(described_class.block?(input)).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ RSpec.describe EmailDomainBlock do
|
||||||
|
|
||||||
it 'returns true if the domain is blocked' do
|
it 'returns true if the domain is blocked' do
|
||||||
Fabricate(:email_domain_block, domain: 'mail.foo.com')
|
Fabricate(:email_domain_block, domain: 'mail.foo.com')
|
||||||
expect(EmailDomainBlock.block?(input)).to be true
|
expect(described_class.block?(input)).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe Export do
|
||||||
it 'returns a csv of the blocked accounts' do
|
it 'returns a csv of the blocked accounts' do
|
||||||
target_accounts.each { |target_account| account.block!(target_account) }
|
target_accounts.each { |target_account| account.block!(target_account) }
|
||||||
|
|
||||||
export = Export.new(account).to_blocked_accounts_csv
|
export = described_class.new(account).to_blocked_accounts_csv
|
||||||
results = export.strip.split
|
results = export.strip.split
|
||||||
|
|
||||||
expect(results.size).to eq 2
|
expect(results.size).to eq 2
|
||||||
|
@ -22,7 +22,7 @@ describe Export do
|
||||||
it 'returns a csv of the muted accounts' do
|
it 'returns a csv of the muted accounts' do
|
||||||
target_accounts.each { |target_account| account.mute!(target_account) }
|
target_accounts.each { |target_account| account.mute!(target_account) }
|
||||||
|
|
||||||
export = Export.new(account).to_muted_accounts_csv
|
export = described_class.new(account).to_muted_accounts_csv
|
||||||
results = export.strip.split("\n")
|
results = export.strip.split("\n")
|
||||||
|
|
||||||
expect(results.size).to eq 3
|
expect(results.size).to eq 3
|
||||||
|
@ -33,7 +33,7 @@ describe Export do
|
||||||
it 'returns a csv of the following accounts' do
|
it 'returns a csv of the following accounts' do
|
||||||
target_accounts.each { |target_account| account.follow!(target_account) }
|
target_accounts.each { |target_account| account.follow!(target_account) }
|
||||||
|
|
||||||
export = Export.new(account).to_following_accounts_csv
|
export = described_class.new(account).to_following_accounts_csv
|
||||||
results = export.strip.split("\n")
|
results = export.strip.split("\n")
|
||||||
|
|
||||||
expect(results.size).to eq 3
|
expect(results.size).to eq 3
|
||||||
|
@ -45,24 +45,24 @@ describe Export do
|
||||||
describe 'total_storage' do
|
describe 'total_storage' do
|
||||||
it 'returns the total size of the media attachments' do
|
it 'returns the total size of the media attachments' do
|
||||||
media_attachment = Fabricate(:media_attachment, account: account)
|
media_attachment = Fabricate(:media_attachment, account: account)
|
||||||
expect(Export.new(account).total_storage).to eq media_attachment.file_file_size || 0
|
expect(described_class.new(account).total_storage).to eq media_attachment.file_file_size || 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'total_follows' do
|
describe 'total_follows' do
|
||||||
it 'returns the total number of the followed accounts' do
|
it 'returns the total number of the followed accounts' do
|
||||||
target_accounts.each { |target_account| account.follow!(target_account) }
|
target_accounts.each { |target_account| account.follow!(target_account) }
|
||||||
expect(Export.new(account.reload).total_follows).to eq 2
|
expect(described_class.new(account.reload).total_follows).to eq 2
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns the total number of the blocked accounts' do
|
it 'returns the total number of the blocked accounts' do
|
||||||
target_accounts.each { |target_account| account.block!(target_account) }
|
target_accounts.each { |target_account| account.block!(target_account) }
|
||||||
expect(Export.new(account.reload).total_blocks).to eq 2
|
expect(described_class.new(account.reload).total_blocks).to eq 2
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns the total number of the muted accounts' do
|
it 'returns the total number of the muted accounts' do
|
||||||
target_accounts.each { |target_account| account.mute!(target_account) }
|
target_accounts.each { |target_account| account.mute!(target_account) }
|
||||||
expect(Export.new(account.reload).total_mutes).to eq 2
|
expect(described_class.new(account.reload).total_mutes).to eq 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,12 +10,12 @@ RSpec.describe Favourite do
|
||||||
let(:status) { Fabricate(:status, reblog: reblog) }
|
let(:status) { Fabricate(:status, reblog: reblog) }
|
||||||
|
|
||||||
it 'invalidates if the reblogged status is already a favourite' do
|
it 'invalidates if the reblogged status is already a favourite' do
|
||||||
Favourite.create!(account: account, status: reblog)
|
described_class.create!(account: account, status: reblog)
|
||||||
expect(Favourite.new(account: account, status: status).valid?).to be false
|
expect(described_class.new(account: account, status: status).valid?).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'replaces status with the reblogged one if it is a reblog' do
|
it 'replaces status with the reblogged one if it is a reblog' do
|
||||||
favourite = Favourite.create!(account: account, status: status)
|
favourite = described_class.create!(account: account, status: status)
|
||||||
expect(favourite.status).to eq reblog
|
expect(favourite.status).to eq reblog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -24,7 +24,7 @@ RSpec.describe Favourite do
|
||||||
let(:status) { Fabricate(:status, reblog: nil) }
|
let(:status) { Fabricate(:status, reblog: nil) }
|
||||||
|
|
||||||
it 'saves with the specified status' do
|
it 'saves with the specified status' do
|
||||||
favourite = Favourite.create!(account: account, status: status)
|
favourite = described_class.create!(account: account, status: status)
|
||||||
expect(favourite.status).to eq status
|
expect(favourite.status).to eq status
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe Follow do
|
||||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||||
|
|
||||||
describe 'validations' do
|
describe 'validations' do
|
||||||
subject { Follow.new(account: alice, target_account: bob, rate_limit: true) }
|
subject { described_class.new(account: alice, target_account: bob, rate_limit: true) }
|
||||||
|
|
||||||
it 'is invalid without an account' do
|
it 'is invalid without an account' do
|
||||||
follow = Fabricate.build(:follow, account: nil)
|
follow = Fabricate.build(:follow, account: nil)
|
||||||
|
@ -38,10 +38,10 @@ RSpec.describe Follow do
|
||||||
|
|
||||||
describe 'recent' do
|
describe 'recent' do
|
||||||
it 'sorts so that more recent follows comes earlier' do
|
it 'sorts so that more recent follows comes earlier' do
|
||||||
follow0 = Follow.create!(account: alice, target_account: bob)
|
follow0 = described_class.create!(account: alice, target_account: bob)
|
||||||
follow1 = Follow.create!(account: bob, target_account: alice)
|
follow1 = described_class.create!(account: bob, target_account: alice)
|
||||||
|
|
||||||
a = Follow.recent.to_a
|
a = described_class.recent.to_a
|
||||||
|
|
||||||
expect(a.size).to eq 2
|
expect(a.size).to eq 2
|
||||||
expect(a[0]).to eq follow1
|
expect(a[0]).to eq follow1
|
||||||
|
|
|
@ -12,7 +12,7 @@ RSpec.describe Identity do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns an instance of Identity' do
|
it 'returns an instance of Identity' do
|
||||||
expect(described_class.find_for_oauth(auth)).to be_instance_of Identity
|
expect(described_class.find_for_oauth(auth)).to be_instance_of described_class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,17 +9,17 @@ RSpec.describe Import do
|
||||||
|
|
||||||
describe 'validations' do
|
describe 'validations' do
|
||||||
it 'has a valid parameters' do
|
it 'has a valid parameters' do
|
||||||
import = Import.create(account: account, type: type, data: data)
|
import = described_class.create(account: account, type: type, data: data)
|
||||||
expect(import).to be_valid
|
expect(import).to be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is invalid without an type' do
|
it 'is invalid without an type' do
|
||||||
import = Import.create(account: account, data: data)
|
import = described_class.create(account: account, data: data)
|
||||||
expect(import).to model_have_error_on_field(:type)
|
expect(import).to model_have_error_on_field(:type)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is invalid without a data' do
|
it 'is invalid without a data' do
|
||||||
import = Import.create(account: account, type: type)
|
import = described_class.create(account: account, type: type)
|
||||||
expect(import).to model_have_error_on_field(:data)
|
expect(import).to model_have_error_on_field(:data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -85,7 +85,7 @@ RSpec.describe MediaAttachment do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'animated gif conversion' do
|
describe 'animated gif conversion' do
|
||||||
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('avatar.gif')) }
|
let(:media) { described_class.create(account: Fabricate(:account), file: attachment_fixture('avatar.gif')) }
|
||||||
|
|
||||||
it 'sets type to gifv' do
|
it 'sets type to gifv' do
|
||||||
expect(media.type).to eq 'gifv'
|
expect(media.type).to eq 'gifv'
|
||||||
|
@ -109,7 +109,7 @@ RSpec.describe MediaAttachment do
|
||||||
|
|
||||||
fixtures.each do |fixture|
|
fixtures.each do |fixture|
|
||||||
context fixture[:filename] do
|
context fixture[:filename] do
|
||||||
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture(fixture[:filename])) }
|
let(:media) { described_class.create(account: Fabricate(:account), file: attachment_fixture(fixture[:filename])) }
|
||||||
|
|
||||||
it 'sets type to image' do
|
it 'sets type to image' do
|
||||||
expect(media.type).to eq 'image'
|
expect(media.type).to eq 'image'
|
||||||
|
@ -129,7 +129,7 @@ RSpec.describe MediaAttachment do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'ogg with cover art' do
|
describe 'ogg with cover art' do
|
||||||
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('boop.ogg')) }
|
let(:media) { described_class.create(account: Fabricate(:account), file: attachment_fixture('boop.ogg')) }
|
||||||
|
|
||||||
it 'detects it as an audio file' do
|
it 'detects it as an audio file' do
|
||||||
expect(media.type).to eq 'audio'
|
expect(media.type).to eq 'audio'
|
||||||
|
@ -153,7 +153,7 @@ RSpec.describe MediaAttachment do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'jpeg' do
|
describe 'jpeg' do
|
||||||
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) }
|
let(:media) { described_class.create(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) }
|
||||||
|
|
||||||
it 'sets meta for different style' do
|
it 'sets meta for different style' do
|
||||||
expect(media.file.meta['original']['width']).to eq 600
|
expect(media.file.meta['original']['width']).to eq 600
|
||||||
|
@ -171,7 +171,7 @@ RSpec.describe MediaAttachment do
|
||||||
|
|
||||||
describe 'base64-encoded jpeg' do
|
describe 'base64-encoded jpeg' do
|
||||||
let(:base64_attachment) { "data:image/jpeg;base64,#{Base64.encode64(attachment_fixture('attachment.jpg').read)}" }
|
let(:base64_attachment) { "data:image/jpeg;base64,#{Base64.encode64(attachment_fixture('attachment.jpg').read)}" }
|
||||||
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: base64_attachment) }
|
let(:media) { described_class.create(account: Fabricate(:account), file: base64_attachment) }
|
||||||
|
|
||||||
it 'saves media attachment' do
|
it 'saves media attachment' do
|
||||||
expect(media.persisted?).to be true
|
expect(media.persisted?).to be true
|
||||||
|
@ -184,7 +184,7 @@ RSpec.describe MediaAttachment do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is invalid without file' do
|
it 'is invalid without file' do
|
||||||
media = MediaAttachment.new(account: Fabricate(:account))
|
media = described_class.new(account: Fabricate(:account))
|
||||||
expect(media.valid?).to be false
|
expect(media.valid?).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -192,26 +192,26 @@ RSpec.describe MediaAttachment do
|
||||||
it 'rejects video files that are too large' do
|
it 'rejects video files that are too large' do
|
||||||
stub_const 'MediaAttachment::IMAGE_LIMIT', 100.megabytes
|
stub_const 'MediaAttachment::IMAGE_LIMIT', 100.megabytes
|
||||||
stub_const 'MediaAttachment::VIDEO_LIMIT', 1.kilobyte
|
stub_const 'MediaAttachment::VIDEO_LIMIT', 1.kilobyte
|
||||||
expect { MediaAttachment.create!(account: Fabricate(:account), file: attachment_fixture('attachment.webm')) }.to raise_error(ActiveRecord::RecordInvalid)
|
expect { described_class.create!(account: Fabricate(:account), file: attachment_fixture('attachment.webm')) }.to raise_error(ActiveRecord::RecordInvalid)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'accepts video files that are small enough' do
|
it 'accepts video files that are small enough' do
|
||||||
stub_const 'MediaAttachment::IMAGE_LIMIT', 1.kilobyte
|
stub_const 'MediaAttachment::IMAGE_LIMIT', 1.kilobyte
|
||||||
stub_const 'MediaAttachment::VIDEO_LIMIT', 100.megabytes
|
stub_const 'MediaAttachment::VIDEO_LIMIT', 100.megabytes
|
||||||
media = MediaAttachment.create!(account: Fabricate(:account), file: attachment_fixture('attachment.webm'))
|
media = described_class.create!(account: Fabricate(:account), file: attachment_fixture('attachment.webm'))
|
||||||
expect(media.valid?).to be true
|
expect(media.valid?).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'rejects image files that are too large' do
|
it 'rejects image files that are too large' do
|
||||||
stub_const 'MediaAttachment::IMAGE_LIMIT', 1.kilobyte
|
stub_const 'MediaAttachment::IMAGE_LIMIT', 1.kilobyte
|
||||||
stub_const 'MediaAttachment::VIDEO_LIMIT', 100.megabytes
|
stub_const 'MediaAttachment::VIDEO_LIMIT', 100.megabytes
|
||||||
expect { MediaAttachment.create!(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) }.to raise_error(ActiveRecord::RecordInvalid)
|
expect { described_class.create!(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) }.to raise_error(ActiveRecord::RecordInvalid)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'accepts image files that are small enough' do
|
it 'accepts image files that are small enough' do
|
||||||
stub_const 'MediaAttachment::IMAGE_LIMIT', 100.megabytes
|
stub_const 'MediaAttachment::IMAGE_LIMIT', 100.megabytes
|
||||||
stub_const 'MediaAttachment::VIDEO_LIMIT', 1.kilobyte
|
stub_const 'MediaAttachment::VIDEO_LIMIT', 1.kilobyte
|
||||||
media = MediaAttachment.create!(account: Fabricate(:account), file: attachment_fixture('attachment.jpg'))
|
media = described_class.create!(account: Fabricate(:account), file: attachment_fixture('attachment.jpg'))
|
||||||
expect(media.valid?).to be true
|
expect(media.valid?).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,22 +38,22 @@ RSpec.describe Notification do
|
||||||
|
|
||||||
describe '#type' do
|
describe '#type' do
|
||||||
it 'returns :reblog for a Status' do
|
it 'returns :reblog for a Status' do
|
||||||
notification = Notification.new(activity: Status.new)
|
notification = described_class.new(activity: Status.new)
|
||||||
expect(notification.type).to eq :reblog
|
expect(notification.type).to eq :reblog
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns :mention for a Mention' do
|
it 'returns :mention for a Mention' do
|
||||||
notification = Notification.new(activity: Mention.new)
|
notification = described_class.new(activity: Mention.new)
|
||||||
expect(notification.type).to eq :mention
|
expect(notification.type).to eq :mention
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns :favourite for a Favourite' do
|
it 'returns :favourite for a Favourite' do
|
||||||
notification = Notification.new(activity: Favourite.new)
|
notification = described_class.new(activity: Favourite.new)
|
||||||
expect(notification.type).to eq :favourite
|
expect(notification.type).to eq :favourite
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns :follow for a Follow' do
|
it 'returns :follow for a Follow' do
|
||||||
notification = Notification.new(activity: Follow.new)
|
notification = described_class.new(activity: Follow.new)
|
||||||
expect(notification.type).to eq :follow
|
expect(notification.type).to eq :follow
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe RelationshipFilter do
|
||||||
describe '#results' do
|
describe '#results' do
|
||||||
context 'when default params are used' do
|
context 'when default params are used' do
|
||||||
let(:subject) do
|
let(:subject) do
|
||||||
RelationshipFilter.new(account, 'order' => 'active').results
|
described_class.new(account, 'order' => 'active').results
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -5,7 +5,7 @@ require 'rails_helper'
|
||||||
describe ReportFilter do
|
describe ReportFilter do
|
||||||
describe 'with empty params' do
|
describe 'with empty params' do
|
||||||
it 'defaults to unresolved reports list' do
|
it 'defaults to unresolved reports list' do
|
||||||
filter = ReportFilter.new({})
|
filter = described_class.new({})
|
||||||
|
|
||||||
expect(filter.results).to eq Report.unresolved
|
expect(filter.results).to eq Report.unresolved
|
||||||
end
|
end
|
||||||
|
@ -13,7 +13,7 @@ describe ReportFilter do
|
||||||
|
|
||||||
describe 'with invalid params' do
|
describe 'with invalid params' do
|
||||||
it 'raises with key error' do
|
it 'raises with key error' do
|
||||||
filter = ReportFilter.new(wrong: true)
|
filter = described_class.new(wrong: true)
|
||||||
|
|
||||||
expect { filter.results }.to raise_error(/wrong/)
|
expect { filter.results }.to raise_error(/wrong/)
|
||||||
end
|
end
|
||||||
|
@ -21,7 +21,7 @@ describe ReportFilter do
|
||||||
|
|
||||||
describe 'with valid params' do
|
describe 'with valid params' do
|
||||||
it 'combines filters on Report' do
|
it 'combines filters on Report' do
|
||||||
filter = ReportFilter.new(account_id: '123', resolved: true, target_account_id: '456')
|
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(:where).and_return(Report.none)
|
||||||
allow(Report).to receive(:resolved).and_return(Report.none)
|
allow(Report).to receive(:resolved).and_return(Report.none)
|
||||||
|
|
|
@ -80,7 +80,7 @@ RSpec.describe SessionActivation do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns an instance of SessionActivation' do
|
it 'returns an instance of SessionActivation' do
|
||||||
expect(described_class.activate(**options)).to be_a SessionActivation
|
expect(described_class.activate(**options)).to be_a described_class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ RSpec.describe Setting do
|
||||||
it 'includes Setting with value of default_value' do
|
it 'includes Setting with value of default_value' do
|
||||||
setting = described_class.all_as_records[key]
|
setting = described_class.all_as_records[key]
|
||||||
|
|
||||||
expect(setting).to be_a Setting
|
expect(setting).to be_a described_class
|
||||||
expect(setting).to have_attributes(var: key)
|
expect(setting).to have_attributes(var: key)
|
||||||
expect(setting).to have_attributes(value: 'default_value')
|
expect(setting).to have_attributes(value: 'default_value')
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe SiteUpload do
|
RSpec.describe SiteUpload do
|
||||||
describe '#cache_key' do
|
describe '#cache_key' do
|
||||||
let(:site_upload) { SiteUpload.new(var: 'var') }
|
let(:site_upload) { described_class.new(var: 'var') }
|
||||||
|
|
||||||
it 'returns cache_key' do
|
it 'returns cache_key' do
|
||||||
expect(site_upload.cache_key).to eq 'site_uploads/var'
|
expect(site_upload.cache_key).to eq 'site_uploads/var'
|
||||||
|
|
|
@ -8,14 +8,14 @@ RSpec.describe StatusPin do
|
||||||
account = Fabricate(:account)
|
account = Fabricate(:account)
|
||||||
status = Fabricate(:status, account: account)
|
status = Fabricate(:status, account: account)
|
||||||
|
|
||||||
expect(StatusPin.new(account: account, status: status).save).to be true
|
expect(described_class.new(account: account, status: status).save).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not allow pins of statuses by someone else' do
|
it 'does not allow pins of statuses by someone else' do
|
||||||
account = Fabricate(:account)
|
account = Fabricate(:account)
|
||||||
status = Fabricate(:status)
|
status = Fabricate(:status)
|
||||||
|
|
||||||
expect(StatusPin.new(account: account, status: status).save).to be false
|
expect(described_class.new(account: account, status: status).save).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not allow pins of reblogs' do
|
it 'does not allow pins of reblogs' do
|
||||||
|
@ -23,21 +23,21 @@ RSpec.describe StatusPin do
|
||||||
status = Fabricate(:status, account: account)
|
status = Fabricate(:status, account: account)
|
||||||
reblog = Fabricate(:status, reblog: status)
|
reblog = Fabricate(:status, reblog: status)
|
||||||
|
|
||||||
expect(StatusPin.new(account: account, status: reblog).save).to be false
|
expect(described_class.new(account: account, status: reblog).save).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does allow pins of direct statuses' do
|
it 'does allow pins of direct statuses' do
|
||||||
account = Fabricate(:account)
|
account = Fabricate(:account)
|
||||||
status = Fabricate(:status, account: account, visibility: :private)
|
status = Fabricate(:status, account: account, visibility: :private)
|
||||||
|
|
||||||
expect(StatusPin.new(account: account, status: status).save).to be true
|
expect(described_class.new(account: account, status: status).save).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not allow pins of direct statuses' do
|
it 'does not allow pins of direct statuses' do
|
||||||
account = Fabricate(:account)
|
account = Fabricate(:account)
|
||||||
status = Fabricate(:status, account: account, visibility: :direct)
|
status = Fabricate(:status, account: account, visibility: :direct)
|
||||||
|
|
||||||
expect(StatusPin.new(account: account, status: status).save).to be false
|
expect(described_class.new(account: account, status: status).save).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
max_pins = 5
|
max_pins = 5
|
||||||
|
@ -50,10 +50,10 @@ RSpec.describe StatusPin do
|
||||||
end
|
end
|
||||||
|
|
||||||
max_pins.times do |i|
|
max_pins.times do |i|
|
||||||
expect(StatusPin.new(account: account, status: status[i]).save).to be true
|
expect(described_class.new(account: account, status: status[i]).save).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(StatusPin.new(account: account, status: status[max_pins]).save).to be false
|
expect(described_class.new(account: account, status: status[max_pins]).save).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'allows pins above the max for remote accounts' do
|
it 'allows pins above the max for remote accounts' do
|
||||||
|
@ -65,10 +65,10 @@ RSpec.describe StatusPin do
|
||||||
end
|
end
|
||||||
|
|
||||||
max_pins.times do |i|
|
max_pins.times do |i|
|
||||||
expect(StatusPin.new(account: account, status: status[i]).save).to be true
|
expect(described_class.new(account: account, status: status[i]).save).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(StatusPin.new(account: account, status: status[max_pins]).save).to be true
|
expect(described_class.new(account: account, status: status[max_pins]).save).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -160,7 +160,7 @@ RSpec.describe Status do
|
||||||
reblog = Fabricate(:status, account: bob, reblog: subject)
|
reblog = Fabricate(:status, account: bob, reblog: subject)
|
||||||
expect(subject.reblogs_count).to eq 1
|
expect(subject.reblogs_count).to eq 1
|
||||||
expect { subject.destroy }.to_not raise_error
|
expect { subject.destroy }.to_not raise_error
|
||||||
expect(Status.find_by(id: reblog.id)).to be_nil
|
expect(described_class.find_by(id: reblog.id)).to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ RSpec.describe Status do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.mutes_map' do
|
describe '.mutes_map' do
|
||||||
subject { Status.mutes_map([status.conversation.id], account) }
|
subject { described_class.mutes_map([status.conversation.id], account) }
|
||||||
|
|
||||||
let(:status) { Fabricate(:status) }
|
let(:status) { Fabricate(:status) }
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
|
@ -222,7 +222,7 @@ RSpec.describe Status do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.favourites_map' do
|
describe '.favourites_map' do
|
||||||
subject { Status.favourites_map([status], account) }
|
subject { described_class.favourites_map([status], account) }
|
||||||
|
|
||||||
let(:status) { Fabricate(:status) }
|
let(:status) { Fabricate(:status) }
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
|
@ -238,7 +238,7 @@ RSpec.describe Status do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.reblogs_map' do
|
describe '.reblogs_map' do
|
||||||
subject { Status.reblogs_map([status], account) }
|
subject { described_class.reblogs_map([status], account) }
|
||||||
|
|
||||||
let(:status) { Fabricate(:status) }
|
let(:status) { Fabricate(:status) }
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
|
@ -265,17 +265,17 @@ RSpec.describe Status do
|
||||||
|
|
||||||
context 'when given one tag' do
|
context 'when given one tag' do
|
||||||
it 'returns the expected statuses' do
|
it 'returns the expected statuses' do
|
||||||
expect(Status.tagged_with([tag1.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status5.id)
|
expect(described_class.tagged_with([tag1.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status5.id)
|
||||||
expect(Status.tagged_with([tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status5.id)
|
expect(described_class.tagged_with([tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status5.id)
|
||||||
expect(Status.tagged_with([tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status3.id, status5.id)
|
expect(described_class.tagged_with([tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status3.id, status5.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when given multiple tags' do
|
context 'when given multiple tags' do
|
||||||
it 'returns the expected statuses' do
|
it 'returns the expected statuses' do
|
||||||
expect(Status.tagged_with([tag1.id, tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status2.id, status5.id)
|
expect(described_class.tagged_with([tag1.id, tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status2.id, status5.id)
|
||||||
expect(Status.tagged_with([tag1.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status3.id, status5.id)
|
expect(described_class.tagged_with([tag1.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status3.id, status5.id)
|
||||||
expect(Status.tagged_with([tag2.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status3.id, status5.id)
|
expect(described_class.tagged_with([tag2.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status3.id, status5.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -292,17 +292,17 @@ RSpec.describe Status do
|
||||||
|
|
||||||
context 'when given one tag' do
|
context 'when given one tag' do
|
||||||
it 'returns the expected statuses' do
|
it 'returns the expected statuses' do
|
||||||
expect(Status.tagged_with_all([tag1.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status5.id)
|
expect(described_class.tagged_with_all([tag1.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status5.id)
|
||||||
expect(Status.tagged_with_all([tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status5.id)
|
expect(described_class.tagged_with_all([tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status5.id)
|
||||||
expect(Status.tagged_with_all([tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status3.id)
|
expect(described_class.tagged_with_all([tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status3.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when given multiple tags' do
|
context 'when given multiple tags' do
|
||||||
it 'returns the expected statuses' do
|
it 'returns the expected statuses' do
|
||||||
expect(Status.tagged_with_all([tag1.id, tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status5.id)
|
expect(described_class.tagged_with_all([tag1.id, tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status5.id)
|
||||||
expect(Status.tagged_with_all([tag1.id, tag3.id]).reorder(:id).pluck(:id).uniq).to eq []
|
expect(described_class.tagged_with_all([tag1.id, tag3.id]).reorder(:id).pluck(:id).uniq).to eq []
|
||||||
expect(Status.tagged_with_all([tag2.id, tag3.id]).reorder(:id).pluck(:id).uniq).to eq []
|
expect(described_class.tagged_with_all([tag2.id, tag3.id]).reorder(:id).pluck(:id).uniq).to eq []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -319,17 +319,17 @@ RSpec.describe Status do
|
||||||
|
|
||||||
context 'when given one tag' do
|
context 'when given one tag' do
|
||||||
it 'returns the expected statuses' do
|
it 'returns the expected statuses' do
|
||||||
expect(Status.tagged_with_none([tag1.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status3.id, status4.id)
|
expect(described_class.tagged_with_none([tag1.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status3.id, status4.id)
|
||||||
expect(Status.tagged_with_none([tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status3.id, status4.id)
|
expect(described_class.tagged_with_none([tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status3.id, status4.id)
|
||||||
expect(Status.tagged_with_none([tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status2.id, status4.id)
|
expect(described_class.tagged_with_none([tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status2.id, status4.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when given multiple tags' do
|
context 'when given multiple tags' do
|
||||||
it 'returns the expected statuses' do
|
it 'returns the expected statuses' do
|
||||||
expect(Status.tagged_with_none([tag1.id, tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status3.id, status4.id)
|
expect(described_class.tagged_with_none([tag1.id, tag2.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status3.id, status4.id)
|
||||||
expect(Status.tagged_with_none([tag1.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status4.id)
|
expect(described_class.tagged_with_none([tag1.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status2.id, status4.id)
|
||||||
expect(Status.tagged_with_none([tag2.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status4.id)
|
expect(described_class.tagged_with_none([tag2.id, tag3.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status1.id, status4.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -344,21 +344,21 @@ RSpec.describe Status do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates new conversation for stand-alone status' do
|
it 'creates new conversation for stand-alone status' do
|
||||||
expect(Status.create(account: alice, text: 'First').conversation_id).to_not be_nil
|
expect(described_class.create(account: alice, text: 'First').conversation_id).to_not be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'keeps conversation of parent node' do
|
it 'keeps conversation of parent node' do
|
||||||
parent = Fabricate(:status, text: 'First')
|
parent = Fabricate(:status, text: 'First')
|
||||||
expect(Status.create(account: alice, thread: parent, text: 'Response').conversation_id).to eq parent.conversation_id
|
expect(described_class.create(account: alice, thread: parent, text: 'Response').conversation_id).to eq parent.conversation_id
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets `local` to true for status by local account' do
|
it 'sets `local` to true for status by local account' do
|
||||||
expect(Status.create(account: alice, text: 'foo').local).to be true
|
expect(described_class.create(account: alice, text: 'foo').local).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets `local` to false for status by remote account' do
|
it 'sets `local` to false for status by remote account' do
|
||||||
alice.update(domain: 'example.com')
|
alice.update(domain: 'example.com')
|
||||||
expect(Status.create(account: alice, text: 'foo').local).to be false
|
expect(described_class.create(account: alice, text: 'foo').local).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ RSpec.describe Status do
|
||||||
|
|
||||||
describe 'after_create' do
|
describe 'after_create' do
|
||||||
it 'saves ActivityPub uri as uri for local status' do
|
it 'saves ActivityPub uri as uri for local status' do
|
||||||
status = Status.create(account: alice, text: 'foo')
|
status = described_class.create(account: alice, text: 'foo')
|
||||||
status.reload
|
status.reload
|
||||||
expect(status.uri).to start_with('https://')
|
expect(status.uri).to start_with('https://')
|
||||||
end
|
end
|
||||||
|
|
|
@ -57,7 +57,7 @@ RSpec.describe User do
|
||||||
it 'returns an array of recent users ordered by id' do
|
it 'returns an array of recent users ordered by id' do
|
||||||
user_1 = Fabricate(:user)
|
user_1 = Fabricate(:user)
|
||||||
user_2 = Fabricate(:user)
|
user_2 = Fabricate(:user)
|
||||||
expect(User.recent).to eq [user_2, user_1]
|
expect(described_class.recent).to eq [user_2, user_1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ RSpec.describe User do
|
||||||
it 'returns an array of users who are confirmed' do
|
it 'returns an array of users who are confirmed' do
|
||||||
user_1 = Fabricate(:user, confirmed_at: nil)
|
user_1 = Fabricate(:user, confirmed_at: nil)
|
||||||
user_2 = Fabricate(:user, confirmed_at: Time.zone.now)
|
user_2 = Fabricate(:user, confirmed_at: Time.zone.now)
|
||||||
expect(User.confirmed).to contain_exactly(user_2)
|
expect(described_class.confirmed).to contain_exactly(user_2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ RSpec.describe User do
|
||||||
specified = Fabricate(:user, current_sign_in_at: 15.days.ago)
|
specified = Fabricate(:user, current_sign_in_at: 15.days.ago)
|
||||||
Fabricate(:user, current_sign_in_at: 6.days.ago)
|
Fabricate(:user, current_sign_in_at: 6.days.ago)
|
||||||
|
|
||||||
expect(User.inactive).to contain_exactly(specified)
|
expect(described_class.inactive).to contain_exactly(specified)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ RSpec.describe User do
|
||||||
specified = Fabricate(:user, email: 'specified@spec')
|
specified = Fabricate(:user, email: 'specified@spec')
|
||||||
Fabricate(:user, email: 'unspecified@spec')
|
Fabricate(:user, email: 'unspecified@spec')
|
||||||
|
|
||||||
expect(User.matches_email('specified')).to contain_exactly(specified)
|
expect(described_class.matches_email('specified')).to contain_exactly(specified)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ RSpec.describe User do
|
||||||
Fabricate(:session_activation, user: user2, ip: '2160:8888::24', session_id: '3')
|
Fabricate(:session_activation, user: user2, ip: '2160:8888::24', session_id: '3')
|
||||||
Fabricate(:session_activation, user: user2, ip: '2160:8888::25', session_id: '4')
|
Fabricate(:session_activation, user: user2, ip: '2160:8888::25', session_id: '4')
|
||||||
|
|
||||||
expect(User.matches_ip('2160:2160::/32')).to contain_exactly(user1)
|
expect(described_class.matches_ip('2160:2160::/32')).to contain_exactly(user1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -113,19 +113,19 @@ RSpec.describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'allows a non-blacklisted user to be created' do
|
it 'allows a non-blacklisted user to be created' do
|
||||||
user = User.new(email: 'foo@example.com', account: account, password: password, agreement: true)
|
user = described_class.new(email: 'foo@example.com', account: account, password: password, agreement: true)
|
||||||
|
|
||||||
expect(user).to be_valid
|
expect(user).to be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not allow a blacklisted user to be created' do
|
it 'does not allow a blacklisted user to be created' do
|
||||||
user = User.new(email: 'foo@mvrht.com', account: account, password: password, agreement: true)
|
user = described_class.new(email: 'foo@mvrht.com', account: account, password: password, agreement: true)
|
||||||
|
|
||||||
expect(user).to_not be_valid
|
expect(user).to_not be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not allow a subdomain blacklisted user to be created' do
|
it 'does not allow a subdomain blacklisted user to be created' do
|
||||||
user = User.new(email: 'foo@mvrht.com.topdomain.tld', account: account, password: password, agreement: true)
|
user = described_class.new(email: 'foo@mvrht.com.topdomain.tld', account: account, password: password, agreement: true)
|
||||||
|
|
||||||
expect(user).to_not be_valid
|
expect(user).to_not be_valid
|
||||||
end
|
end
|
||||||
|
@ -349,17 +349,17 @@ RSpec.describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not allow a user to be created unless they are whitelisted' do
|
it 'does not allow a user to be created unless they are whitelisted' do
|
||||||
user = User.new(email: 'foo@example.com', account: account, password: password, agreement: true)
|
user = described_class.new(email: 'foo@example.com', account: account, password: password, agreement: true)
|
||||||
expect(user).to_not be_valid
|
expect(user).to_not be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'allows a user to be created if they are whitelisted' do
|
it 'allows a user to be created if they are whitelisted' do
|
||||||
user = User.new(email: 'foo@mastodon.space', account: account, password: password, agreement: true)
|
user = described_class.new(email: 'foo@mastodon.space', account: account, password: password, agreement: true)
|
||||||
expect(user).to be_valid
|
expect(user).to be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not allow a user with a whitelisted top domain as subdomain in their email address to be created' do
|
it 'does not allow a user with a whitelisted top domain as subdomain in their email address to be created' do
|
||||||
user = User.new(email: 'foo@mastodon.space.userdomain.com', account: account, password: password, agreement: true)
|
user = described_class.new(email: 'foo@mastodon.space.userdomain.com', account: account, password: password, agreement: true)
|
||||||
expect(user).to_not be_valid
|
expect(user).to_not be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ RSpec.describe User do
|
||||||
it 'does not allow a user to be created with a specific blacklisted subdomain even if the top domain is whitelisted' do
|
it 'does not allow a user to be created with a specific blacklisted subdomain even if the top domain is whitelisted' do
|
||||||
Rails.configuration.x.email_domains_blacklist = 'blacklisted.mastodon.space'
|
Rails.configuration.x.email_domains_blacklist = 'blacklisted.mastodon.space'
|
||||||
|
|
||||||
user = User.new(email: 'foo@blacklisted.mastodon.space', account: account, password: password)
|
user = described_class.new(email: 'foo@blacklisted.mastodon.space', account: account, password: password)
|
||||||
expect(user).to_not be_valid
|
expect(user).to_not be_valid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -527,19 +527,19 @@ RSpec.describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.those_who_can' do
|
describe '.those_who_can' do
|
||||||
let!(:moderator_user) { Fabricate(:user, role: UserRole.find_by(name: 'Moderator')) }
|
before { Fabricate(:user, role: UserRole.find_by(name: 'Moderator')) }
|
||||||
|
|
||||||
context 'when there are not any user roles' do
|
context 'when there are not any user roles' do
|
||||||
before { UserRole.destroy_all }
|
before { UserRole.destroy_all }
|
||||||
|
|
||||||
it 'returns an empty list' do
|
it 'returns an empty list' do
|
||||||
expect(User.those_who_can(:manage_blocks)).to eq([])
|
expect(described_class.those_who_can(:manage_blocks)).to eq([])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when there are not users with the needed role' do
|
context 'when there are not users with the needed role' do
|
||||||
it 'returns an empty list' do
|
it 'returns an empty list' do
|
||||||
expect(User.those_who_can(:manage_blocks)).to eq([])
|
expect(described_class.those_who_can(:manage_blocks)).to eq([])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ RSpec.describe User do
|
||||||
let!(:admin_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
let!(:admin_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||||
|
|
||||||
it 'returns the users with the role' do
|
it 'returns the users with the role' do
|
||||||
expect(User.those_who_can(:manage_blocks)).to eq([admin_user])
|
expect(described_class.those_who_can(:manage_blocks)).to eq([admin_user])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,13 +11,13 @@ RSpec.describe AccountModerationNotePolicy do
|
||||||
permissions :create? do
|
permissions :create? do
|
||||||
context 'when staff' do
|
context 'when staff' do
|
||||||
it 'grants to create' do
|
it 'grants to create' do
|
||||||
expect(subject).to permit(admin, AccountModerationNotePolicy)
|
expect(subject).to permit(admin, described_class)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when not staff' do
|
context 'when not staff' do
|
||||||
it 'denies to create' do
|
it 'denies to create' do
|
||||||
expect(subject).to_not permit(john, AccountModerationNotePolicy)
|
expect(subject).to_not permit(john, described_class)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe AccountRelationshipsPresenter do
|
||||||
allow(Account).to receive(:domain_blocking_map).with(account_ids, current_account_id).and_return(default_map)
|
allow(Account).to receive(:domain_blocking_map).with(account_ids, current_account_id).and_return(default_map)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:presenter) { AccountRelationshipsPresenter.new(account_ids, current_account_id, **options) }
|
let(:presenter) { described_class.new(account_ids, current_account_id, **options) }
|
||||||
let(:current_account_id) { Fabricate(:account).id }
|
let(:current_account_id) { Fabricate(:account).id }
|
||||||
let(:account_ids) { [Fabricate(:account).id] }
|
let(:account_ids) { [Fabricate(:account).id] }
|
||||||
let(:default_map) { { 1 => true } }
|
let(:default_map) { { 1 => true } }
|
||||||
|
|
|
@ -12,7 +12,7 @@ RSpec.describe StatusRelationshipsPresenter do
|
||||||
allow(Status).to receive(:pins_map).with(anything, current_account_id).and_return(default_map)
|
allow(Status).to receive(:pins_map).with(anything, current_account_id).and_return(default_map)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:presenter) { StatusRelationshipsPresenter.new(statuses, current_account_id, **options) }
|
let(:presenter) { described_class.new(statuses, current_account_id, **options) }
|
||||||
let(:current_account_id) { Fabricate(:account).id }
|
let(:current_account_id) { Fabricate(:account).id }
|
||||||
let(:statuses) { [Fabricate(:status)] }
|
let(:statuses) { [Fabricate(:status)] }
|
||||||
let(:status_ids) { statuses.map(&:id) + statuses.filter_map(&:reblog_of_id) }
|
let(:status_ids) { statuses.map(&:id) + statuses.filter_map(&:reblog_of_id) }
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe ActivityPub::NoteSerializer do
|
||||||
let!(:reply5) { Fabricate(:status, account: account, thread: parent, visibility: :direct) }
|
let!(:reply5) { Fabricate(:status, account: account, thread: parent, visibility: :direct) }
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@serialization = ActiveModelSerializers::SerializableResource.new(parent, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter)
|
@serialization = ActiveModelSerializers::SerializableResource.new(parent, serializer: described_class, adapter: ActivityPub::Adapter)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has a Note type' do
|
it 'has a Note type' do
|
||||||
|
|
|
@ -10,7 +10,7 @@ describe ActivityPub::UpdatePollSerializer do
|
||||||
let!(:status) { Fabricate(:status, account: account, poll: poll) }
|
let!(:status) { Fabricate(:status, account: account, poll: poll) }
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@serialization = ActiveModelSerializers::SerializableResource.new(status, serializer: ActivityPub::UpdatePollSerializer, adapter: ActivityPub::Adapter)
|
@serialization = ActiveModelSerializers::SerializableResource.new(status, serializer: described_class, adapter: ActivityPub::Adapter)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has a Update type' do
|
it 'has a Update type' do
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe REST::AccountSerializer do
|
describe REST::AccountSerializer do
|
||||||
subject { JSON.parse(ActiveModelSerializers::SerializableResource.new(account, serializer: REST::AccountSerializer).to_json) }
|
subject { JSON.parse(ActiveModelSerializers::SerializableResource.new(account, serializer: described_class).to_json) }
|
||||||
|
|
||||||
let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) }
|
let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) }
|
||||||
let(:user) { Fabricate(:user, role: role) }
|
let(:user) { Fabricate(:user, role: role) }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
||||||
subject { ActivityPub::FetchRemoteAccountService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let!(:actor) do
|
let!(:actor) do
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
|
RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
|
||||||
subject { ActivityPub::FetchRemoteActorService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let!(:actor) do
|
let!(:actor) do
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ActivityPub::FetchRemoteKeyService, type: :service do
|
RSpec.describe ActivityPub::FetchRemoteKeyService, type: :service do
|
||||||
subject { ActivityPub::FetchRemoteKeyService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice' }] } }
|
let(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice' }] } }
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe AfterBlockDomainFromAccountService, type: :service do
|
RSpec.describe AfterBlockDomainFromAccountService, type: :service do
|
||||||
subject { AfterBlockDomainFromAccountService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let!(:wolf) { Fabricate(:account, username: 'wolf', domain: 'evil.org', inbox_url: 'https://evil.org/inbox', protocol: :activitypub) }
|
let!(:wolf) { Fabricate(:account, username: 'wolf', domain: 'evil.org', inbox_url: 'https://evil.org/inbox', protocol: :activitypub) }
|
||||||
let!(:alice) { Fabricate(:account, username: 'alice') }
|
let!(:alice) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe AuthorizeFollowService, type: :service do
|
RSpec.describe AuthorizeFollowService, type: :service do
|
||||||
subject { AuthorizeFollowService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe BatchedRemoveStatusService, type: :service do
|
RSpec.describe BatchedRemoveStatusService, type: :service do
|
||||||
subject { BatchedRemoveStatusService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let!(:alice) { Fabricate(:account) }
|
let!(:alice) { Fabricate(:account) }
|
||||||
let!(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') }
|
let!(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe BlockDomainService, type: :service do
|
RSpec.describe BlockDomainService, type: :service do
|
||||||
subject { BlockDomainService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
||||||
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe BlockService, type: :service do
|
RSpec.describe BlockService, type: :service do
|
||||||
subject { BlockService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe BootstrapTimelineService, type: :service do
|
RSpec.describe BootstrapTimelineService, type: :service do
|
||||||
subject { BootstrapTimelineService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
context 'when the new user has registered from an invite' do
|
context 'when the new user has registered from an invite' do
|
||||||
let(:service) { double }
|
let(:service) { double }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ClearDomainMediaService, type: :service do
|
RSpec.describe ClearDomainMediaService, type: :service do
|
||||||
subject { ClearDomainMediaService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
||||||
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe FavouriteService, type: :service do
|
RSpec.describe FavouriteService, type: :service do
|
||||||
subject { FavouriteService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe FollowService, type: :service do
|
RSpec.describe FollowService, type: :service do
|
||||||
subject { FollowService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe ImportService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when importing old-style list of muted users' do
|
context 'when importing old-style list of muted users' do
|
||||||
subject { ImportService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:csv) { attachment_fixture('mute-imports.txt') }
|
let(:csv) { attachment_fixture('mute-imports.txt') }
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ RSpec.describe ImportService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when importing new-style list of muted users' do
|
context 'when importing new-style list of muted users' do
|
||||||
subject { ImportService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:csv) { attachment_fixture('new-mute-imports.txt') }
|
let(:csv) { attachment_fixture('new-mute-imports.txt') }
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ RSpec.describe ImportService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when importing old-style list of followed users' do
|
context 'when importing old-style list of followed users' do
|
||||||
subject { ImportService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:csv) { attachment_fixture('mute-imports.txt') }
|
let(:csv) { attachment_fixture('mute-imports.txt') }
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ RSpec.describe ImportService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when importing new-style list of followed users' do
|
context 'when importing new-style list of followed users' do
|
||||||
subject { ImportService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:csv) { attachment_fixture('new-following-imports.txt') }
|
let(:csv) { attachment_fixture('new-following-imports.txt') }
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ RSpec.describe ImportService, type: :service do
|
||||||
#
|
#
|
||||||
# https://github.com/mastodon/mastodon/issues/20571
|
# https://github.com/mastodon/mastodon/issues/20571
|
||||||
context 'with a utf-8 encoded domains' do
|
context 'with a utf-8 encoded domains' do
|
||||||
subject { ImportService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let!(:nare) { Fabricate(:account, username: 'nare', domain: 'թութ.հայ', locked: false, protocol: :activitypub, inbox_url: 'https://թութ.հայ/inbox') }
|
let!(:nare) { Fabricate(:account, username: 'nare', domain: 'թութ.հայ', locked: false, protocol: :activitypub, inbox_url: 'https://թութ.հայ/inbox') }
|
||||||
let(:csv) { attachment_fixture('utf8-followers.txt') }
|
let(:csv) { attachment_fixture('utf8-followers.txt') }
|
||||||
|
@ -201,7 +201,7 @@ RSpec.describe ImportService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when importing bookmarks' do
|
context 'when importing bookmarks' do
|
||||||
subject { ImportService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:csv) { attachment_fixture('bookmark-imports.txt') }
|
let(:csv) { attachment_fixture('bookmark-imports.txt') }
|
||||||
let(:local_account) { Fabricate(:account, username: 'foo', domain: '') }
|
let(:local_account) { Fabricate(:account, username: 'foo', domain: '') }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe PostStatusService, type: :service do
|
RSpec.describe PostStatusService, type: :service do
|
||||||
subject { PostStatusService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
it 'creates a new status' do
|
it 'creates a new status' do
|
||||||
account = Fabricate(:account)
|
account = Fabricate(:account)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe PrecomputeFeedService, type: :service do
|
RSpec.describe PrecomputeFeedService, type: :service do
|
||||||
subject { PrecomputeFeedService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
describe 'call' do
|
describe 'call' do
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ProcessMentionsService, type: :service do
|
RSpec.describe ProcessMentionsService, type: :service do
|
||||||
subject { ProcessMentionsService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:account) { Fabricate(:account, username: 'alice') }
|
let(:account) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe PurgeDomainService, type: :service do
|
RSpec.describe PurgeDomainService, type: :service do
|
||||||
subject { PurgeDomainService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let!(:old_account) { Fabricate(:account, domain: 'obsolete.org') }
|
let!(:old_account) { Fabricate(:account, domain: 'obsolete.org') }
|
||||||
let!(:old_status1) { Fabricate(:status, account: old_account) }
|
let!(:old_status1) { Fabricate(:status, account: old_account) }
|
||||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe ReblogService, type: :service do
|
||||||
let(:alice) { Fabricate(:account, username: 'alice') }
|
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
context 'when creates a reblog with appropriate visibility' do
|
context 'when creates a reblog with appropriate visibility' do
|
||||||
subject { ReblogService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:visibility) { :public }
|
let(:visibility) { :public }
|
||||||
let(:reblog_visibility) { :public }
|
let(:reblog_visibility) { :public }
|
||||||
|
@ -62,7 +62,7 @@ RSpec.describe ReblogService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with ActivityPub' do
|
context 'with ActivityPub' do
|
||||||
subject { ReblogService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
|
let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
|
||||||
let(:status) { Fabricate(:status, account: bob) }
|
let(:status) { Fabricate(:status, account: bob) }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe RejectFollowService, type: :service do
|
RSpec.describe RejectFollowService, type: :service do
|
||||||
subject { RejectFollowService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe RemoveFromFollowersService, type: :service do
|
RSpec.describe RemoveFromFollowersService, type: :service do
|
||||||
subject { RemoveFromFollowersService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe RemoveStatusService, type: :service do
|
RSpec.describe RemoveStatusService, type: :service do
|
||||||
subject { RemoveStatusService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let!(:alice) { Fabricate(:account) }
|
let!(:alice) { Fabricate(:account) }
|
||||||
let!(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') }
|
let!(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe UnallowDomainService, type: :service do
|
RSpec.describe UnallowDomainService, type: :service do
|
||||||
subject { UnallowDomainService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
||||||
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe UnblockService, type: :service do
|
RSpec.describe UnblockService, type: :service do
|
||||||
subject { UnblockService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe UnfollowService, type: :service do
|
RSpec.describe UnfollowService, type: :service do
|
||||||
subject { UnfollowService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe UnmuteService, type: :service do
|
RSpec.describe UnmuteService, type: :service do
|
||||||
subject { UnmuteService.new }
|
subject { described_class.new }
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe UpdateAccountService, type: :service do
|
RSpec.describe UpdateAccountService, type: :service do
|
||||||
subject { UpdateAccountService.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
describe 'switching form locked to unlocked accounts' do
|
describe 'switching form locked to unlocked accounts' do
|
||||||
let(:account) { Fabricate(:account, locked: true) }
|
let(:account) { Fabricate(:account, locked: true) }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe NoteLengthValidator do
|
describe NoteLengthValidator do
|
||||||
subject { NoteLengthValidator.new(attributes: { note: true }, maximum: 500) }
|
subject { described_class.new(attributes: { note: true }, maximum: 500) }
|
||||||
|
|
||||||
describe '#validate' do
|
describe '#validate' do
|
||||||
it 'adds an error when text is over 500 characters' do
|
it 'adds an error when text is over 500 characters' do
|
||||||
|
|
Loading…
Reference in a new issue