mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-25 07:23:43 +01:00
Fix RSpec/InstanceVariable
cop (#27766)
This commit is contained in:
parent
4329616c53
commit
69d00e2721
11 changed files with 97 additions and 124 deletions
|
@ -71,26 +71,6 @@ RSpec/AnyInstance:
|
||||||
RSpec/ExampleLength:
|
RSpec/ExampleLength:
|
||||||
Max: 22
|
Max: 22
|
||||||
|
|
||||||
# Configuration parameters: AssignmentOnly.
|
|
||||||
RSpec/InstanceVariable:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/controllers/api/v1/streaming_controller_spec.rb'
|
|
||||||
- 'spec/controllers/auth/confirmations_controller_spec.rb'
|
|
||||||
- 'spec/controllers/auth/passwords_controller_spec.rb'
|
|
||||||
- 'spec/controllers/auth/sessions_controller_spec.rb'
|
|
||||||
- 'spec/controllers/concerns/export_controller_concern_spec.rb'
|
|
||||||
- 'spec/controllers/home_controller_spec.rb'
|
|
||||||
- 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb'
|
|
||||||
- 'spec/controllers/statuses_cleanup_controller_spec.rb'
|
|
||||||
- 'spec/models/concerns/account_finder_concern_spec.rb'
|
|
||||||
- 'spec/models/concerns/account_interactions_spec.rb'
|
|
||||||
- 'spec/models/public_feed_spec.rb'
|
|
||||||
- 'spec/serializers/activitypub/note_serializer_spec.rb'
|
|
||||||
- 'spec/serializers/activitypub/update_poll_serializer_spec.rb'
|
|
||||||
- 'spec/services/remove_status_service_spec.rb'
|
|
||||||
- 'spec/services/search_service_spec.rb'
|
|
||||||
- 'spec/services/unblock_domain_service_spec.rb'
|
|
||||||
|
|
||||||
RSpec/LetSetup:
|
RSpec/LetSetup:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'spec/controllers/api/v1/accounts/statuses_controller_spec.rb'
|
- 'spec/controllers/api/v1/accounts/statuses_controller_spec.rb'
|
||||||
|
|
|
@ -26,7 +26,6 @@ describe Api::V1::StreamingController do
|
||||||
context 'with streaming api on different host' do
|
context 'with streaming api on different host' do
|
||||||
before do
|
before do
|
||||||
Rails.configuration.x.streaming_api_base_url = "wss://streaming-#{Rails.configuration.x.web_domain}"
|
Rails.configuration.x.streaming_api_base_url = "wss://streaming-#{Rails.configuration.x.web_domain}"
|
||||||
@streaming_host = URI.parse(Rails.configuration.x.streaming_api_base_url).host
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #index' do
|
describe 'GET #index' do
|
||||||
|
@ -38,7 +37,13 @@ describe Api::V1::StreamingController do
|
||||||
[:scheme, :path, :query, :fragment].each do |part|
|
[:scheme, :path, :query, :fragment].each do |part|
|
||||||
expect(redirect_to_uri.send(part)).to eq(request_uri.send(part)), "redirect target #{part}"
|
expect(redirect_to_uri.send(part)).to eq(request_uri.send(part)), "redirect target #{part}"
|
||||||
end
|
end
|
||||||
expect(redirect_to_uri.host).to eq(@streaming_host), 'redirect target host'
|
expect(redirect_to_uri.host).to eq(streaming_host), 'redirect target host'
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def streaming_host
|
||||||
|
URI.parse(Rails.configuration.x.streaming_api_base_url).host
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,12 +18,14 @@ describe Auth::PasswordsController do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
request.env['devise.mapping'] = Devise.mappings[:user]
|
request.env['devise.mapping'] = Devise.mappings[:user]
|
||||||
@token = user.send_reset_password_instructions
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with valid reset_password_token' do
|
context 'with valid reset_password_token' do
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :edit, params: { reset_password_token: @token }
|
token = user.send_reset_password_instructions
|
||||||
|
|
||||||
|
get :edit, params: { reset_password_token: token }
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -38,9 +40,9 @@ describe Auth::PasswordsController do
|
||||||
|
|
||||||
describe 'POST #update' do
|
describe 'POST #update' do
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
|
let(:password) { 'reset0password' }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@password = 'reset0password'
|
|
||||||
request.env['devise.mapping'] = Devise.mappings[:user]
|
request.env['devise.mapping'] = Devise.mappings[:user]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,9 +52,9 @@ describe Auth::PasswordsController do
|
||||||
let!(:web_push_subscription) { Fabricate(:web_push_subscription, access_token: access_token) }
|
let!(:web_push_subscription) { Fabricate(:web_push_subscription, access_token: access_token) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@token = user.send_reset_password_instructions
|
token = user.send_reset_password_instructions
|
||||||
|
|
||||||
post :update, params: { user: { password: @password, password_confirmation: @password, reset_password_token: @token } }
|
post :update, params: { user: { password: password, password_confirmation: password, reset_password_token: token } }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirect to sign in' do
|
it 'redirect to sign in' do
|
||||||
|
@ -63,7 +65,7 @@ describe Auth::PasswordsController do
|
||||||
this_user = User.find(user.id)
|
this_user = User.find(user.id)
|
||||||
|
|
||||||
expect(this_user).to_not be_nil
|
expect(this_user).to_not be_nil
|
||||||
expect(this_user.valid_password?(@password)).to be true
|
expect(this_user.valid_password?(password)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deactivates all sessions' do
|
it 'deactivates all sessions' do
|
||||||
|
@ -81,7 +83,7 @@ describe Auth::PasswordsController do
|
||||||
|
|
||||||
context 'with invalid reset_password_token' do
|
context 'with invalid reset_password_token' do
|
||||||
before do
|
before do
|
||||||
post :update, params: { user: { password: @password, password_confirmation: @password, reset_password_token: 'some_invalid_value' } }
|
post :update, params: { user: { password: password, password_confirmation: password, reset_password_token: 'some_invalid_value' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders reset password' do
|
it 'renders reset password' do
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe ExportControllerConcern do
|
||||||
end
|
end
|
||||||
|
|
||||||
def export_data
|
def export_data
|
||||||
@export.account.username
|
'body data value'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ describe ExportControllerConcern do
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
expect(response.media_type).to eq 'text/csv'
|
expect(response.media_type).to eq 'text/csv'
|
||||||
expect(response.headers['Content-Disposition']).to start_with 'attachment; filename="anonymous.csv"'
|
expect(response.headers['Content-Disposition']).to start_with 'attachment; filename="anonymous.csv"'
|
||||||
expect(response.body).to eq user.account.username
|
expect(response.body).to eq 'body data value'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns unauthorized when not signed in' do
|
it 'returns unauthorized when not signed in' do
|
||||||
|
|
|
@ -5,9 +5,10 @@ require 'rails_helper'
|
||||||
RSpec.describe StatusesCleanupController do
|
RSpec.describe StatusesCleanupController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
|
let!(:user) { Fabricate(:user) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@user = Fabricate(:user)
|
sign_in user, scope: :user
|
||||||
sign_in @user, scope: :user
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
|
@ -30,9 +31,9 @@ RSpec.describe StatusesCleanupController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates the account status cleanup policy' do
|
it 'updates the account status cleanup policy' do
|
||||||
expect(@user.account.statuses_cleanup_policy.enabled).to be true
|
expect(user.account.statuses_cleanup_policy.enabled).to be true
|
||||||
expect(@user.account.statuses_cleanup_policy.keep_direct).to be false
|
expect(user.account.statuses_cleanup_policy.keep_direct).to be false
|
||||||
expect(@user.account.statuses_cleanup_policy.keep_polls).to be true
|
expect(user.account.statuses_cleanup_policy.keep_polls).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects' do
|
it 'redirects' do
|
||||||
|
|
|
@ -4,17 +4,15 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe AccountFinderConcern do
|
describe AccountFinderConcern do
|
||||||
describe 'local finders' do
|
describe 'local finders' do
|
||||||
before do
|
let!(:account) { Fabricate(:account, username: 'Alice') }
|
||||||
@account = Fabricate(:account, username: 'Alice')
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '.find_local' do
|
describe '.find_local' do
|
||||||
it 'returns case-insensitive result' do
|
it 'returns case-insensitive result' do
|
||||||
expect(Account.find_local('alice')).to eq(@account)
|
expect(Account.find_local('alice')).to eq(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns correctly cased result' do
|
it 'returns correctly cased result' do
|
||||||
expect(Account.find_local('Alice')).to eq(@account)
|
expect(Account.find_local('Alice')).to eq(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns nil without a match' do
|
it 'returns nil without a match' do
|
||||||
|
@ -36,7 +34,7 @@ describe AccountFinderConcern do
|
||||||
|
|
||||||
describe '.find_local!' do
|
describe '.find_local!' do
|
||||||
it 'returns matching result' do
|
it 'returns matching result' do
|
||||||
expect(Account.find_local!('alice')).to eq(@account)
|
expect(Account.find_local!('alice')).to eq(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises on non-matching result' do
|
it 'raises on non-matching result' do
|
||||||
|
@ -54,17 +52,15 @@ describe AccountFinderConcern do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'remote finders' do
|
describe 'remote finders' do
|
||||||
before do
|
let!(:account) { Fabricate(:account, username: 'Alice', domain: 'mastodon.social') }
|
||||||
@account = Fabricate(:account, username: 'Alice', domain: 'mastodon.social')
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '.find_remote' do
|
describe '.find_remote' do
|
||||||
it 'returns exact match result' do
|
it 'returns exact match result' do
|
||||||
expect(Account.find_remote('alice', 'mastodon.social')).to eq(@account)
|
expect(Account.find_remote('alice', 'mastodon.social')).to eq(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns case-insensitive result' do
|
it 'returns case-insensitive result' do
|
||||||
expect(Account.find_remote('ALICE', 'MASTODON.SOCIAL')).to eq(@account)
|
expect(Account.find_remote('ALICE', 'MASTODON.SOCIAL')).to eq(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns nil when username does not match' do
|
it 'returns nil when username does not match' do
|
||||||
|
@ -90,7 +86,7 @@ describe AccountFinderConcern do
|
||||||
|
|
||||||
describe '.find_remote!' do
|
describe '.find_remote!' do
|
||||||
it 'returns matching result' do
|
it 'returns matching result' do
|
||||||
expect(Account.find_remote!('alice', 'mastodon.social')).to eq(@account)
|
expect(Account.find_remote!('alice', 'mastodon.social')).to eq(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises on non-matching result' do
|
it 'raises on non-matching result' do
|
||||||
|
|
|
@ -648,38 +648,36 @@ describe AccountInteractions do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'ignoring reblogs from an account' do
|
describe 'ignoring reblogs from an account' do
|
||||||
before do
|
let!(:me) { Fabricate(:account, username: 'Me') }
|
||||||
@me = Fabricate(:account, username: 'Me')
|
let!(:you) { Fabricate(:account, username: 'You') }
|
||||||
@you = Fabricate(:account, username: 'You')
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with the reblogs option unspecified' do
|
context 'with the reblogs option unspecified' do
|
||||||
before do
|
before do
|
||||||
@me.follow!(@you)
|
me.follow!(you)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'defaults to showing reblogs' do
|
it 'defaults to showing reblogs' do
|
||||||
expect(@me.muting_reblogs?(@you)).to be(false)
|
expect(me.muting_reblogs?(you)).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with the reblogs option set to false' do
|
context 'with the reblogs option set to false' do
|
||||||
before do
|
before do
|
||||||
@me.follow!(@you, reblogs: false)
|
me.follow!(you, reblogs: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does mute reblogs' do
|
it 'does mute reblogs' do
|
||||||
expect(@me.muting_reblogs?(@you)).to be(true)
|
expect(me.muting_reblogs?(you)).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with the reblogs option set to true' do
|
context 'with the reblogs option set to true' do
|
||||||
before do
|
before do
|
||||||
@me.follow!(@you, reblogs: true)
|
me.follow!(you, reblogs: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not mute reblogs' do
|
it 'does not mute reblogs' do
|
||||||
expect(@me.muting_reblogs?(@you)).to be(false)
|
expect(me.muting_reblogs?(you)).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -137,15 +137,13 @@ RSpec.describe PublicFeed do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with an account passed in' do
|
describe 'with an account passed in' do
|
||||||
subject { described_class.new(@account).get(20).map(&:id) }
|
subject { described_class.new(account).get(20).map(&:id) }
|
||||||
|
|
||||||
before do
|
let!(:account) { Fabricate(:account) }
|
||||||
@account = Fabricate(:account)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'excludes statuses from accounts blocked by the account' do
|
it 'excludes statuses from accounts blocked by the account' do
|
||||||
blocked = Fabricate(:account)
|
blocked = Fabricate(:account)
|
||||||
@account.block!(blocked)
|
account.block!(blocked)
|
||||||
blocked_status = Fabricate(:status, account: blocked)
|
blocked_status = Fabricate(:status, account: blocked)
|
||||||
|
|
||||||
expect(subject).to_not include(blocked_status.id)
|
expect(subject).to_not include(blocked_status.id)
|
||||||
|
@ -153,7 +151,7 @@ RSpec.describe PublicFeed do
|
||||||
|
|
||||||
it 'excludes statuses from accounts who have blocked the account' do
|
it 'excludes statuses from accounts who have blocked the account' do
|
||||||
blocker = Fabricate(:account)
|
blocker = Fabricate(:account)
|
||||||
blocker.block!(@account)
|
blocker.block!(account)
|
||||||
blocked_status = Fabricate(:status, account: blocker)
|
blocked_status = Fabricate(:status, account: blocker)
|
||||||
|
|
||||||
expect(subject).to_not include(blocked_status.id)
|
expect(subject).to_not include(blocked_status.id)
|
||||||
|
@ -161,7 +159,7 @@ RSpec.describe PublicFeed do
|
||||||
|
|
||||||
it 'excludes statuses from accounts muted by the account' do
|
it 'excludes statuses from accounts muted by the account' do
|
||||||
muted = Fabricate(:account)
|
muted = Fabricate(:account)
|
||||||
@account.mute!(muted)
|
account.mute!(muted)
|
||||||
muted_status = Fabricate(:status, account: muted)
|
muted_status = Fabricate(:status, account: muted)
|
||||||
|
|
||||||
expect(subject).to_not include(muted_status.id)
|
expect(subject).to_not include(muted_status.id)
|
||||||
|
@ -169,7 +167,7 @@ RSpec.describe PublicFeed do
|
||||||
|
|
||||||
it 'excludes statuses from accounts from personally blocked domains' do
|
it 'excludes statuses from accounts from personally blocked domains' do
|
||||||
blocked = Fabricate(:account, domain: 'example.com')
|
blocked = Fabricate(:account, domain: 'example.com')
|
||||||
@account.block_domain!(blocked.domain)
|
account.block_domain!(blocked.domain)
|
||||||
blocked_status = Fabricate(:status, account: blocked)
|
blocked_status = Fabricate(:status, account: blocked)
|
||||||
|
|
||||||
expect(subject).to_not include(blocked_status.id)
|
expect(subject).to_not include(blocked_status.id)
|
||||||
|
@ -177,7 +175,7 @@ RSpec.describe PublicFeed do
|
||||||
|
|
||||||
context 'with language preferences' do
|
context 'with language preferences' do
|
||||||
it 'excludes statuses in languages not allowed by the account user' do
|
it 'excludes statuses in languages not allowed by the account user' do
|
||||||
@account.user.update(chosen_languages: [:en, :es])
|
account.user.update(chosen_languages: [:en, :es])
|
||||||
en_status = Fabricate(:status, language: 'en')
|
en_status = Fabricate(:status, language: 'en')
|
||||||
es_status = Fabricate(:status, language: 'es')
|
es_status = Fabricate(:status, language: 'es')
|
||||||
fr_status = Fabricate(:status, language: 'fr')
|
fr_status = Fabricate(:status, language: 'fr')
|
||||||
|
@ -188,7 +186,7 @@ RSpec.describe PublicFeed do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'includes all languages when user does not have a setting' do
|
it 'includes all languages when user does not have a setting' do
|
||||||
@account.user.update(chosen_languages: nil)
|
account.user.update(chosen_languages: nil)
|
||||||
|
|
||||||
en_status = Fabricate(:status, language: 'en')
|
en_status = Fabricate(:status, language: 'en')
|
||||||
es_status = Fabricate(:status, language: 'es')
|
es_status = Fabricate(:status, language: 'es')
|
||||||
|
@ -198,7 +196,7 @@ RSpec.describe PublicFeed do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'includes all languages when account does not have a user' do
|
it 'includes all languages when account does not have a user' do
|
||||||
@account.update(user: nil)
|
account.update(user: nil)
|
||||||
|
|
||||||
en_status = Fabricate(:status, language: 'en')
|
en_status = Fabricate(:status, language: 'en')
|
||||||
es_status = Fabricate(:status, language: 'es')
|
es_status = Fabricate(:status, language: 'es')
|
||||||
|
|
|
@ -20,71 +20,70 @@ RSpec.describe RemoveStatusService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when removed status is not a reblog' do
|
context 'when removed status is not a reblog' do
|
||||||
|
let!(:status) { PostStatusService.new.call(alice, text: 'Hello @bob@example.com ThisIsASecret') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@status = PostStatusService.new.call(alice, text: 'Hello @bob@example.com ThisIsASecret')
|
FavouriteService.new.call(jeff, status)
|
||||||
FavouriteService.new.call(jeff, @status)
|
Fabricate(:status, account: bill, reblog: status, uri: 'hoge')
|
||||||
Fabricate(:status, account: bill, reblog: @status, uri: 'hoge')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'removes status from author\'s home feed' do
|
it 'removes status from author\'s home feed' do
|
||||||
subject.call(@status)
|
subject.call(status)
|
||||||
expect(HomeFeed.new(alice).get(10).pluck(:id)).to_not include(@status.id)
|
expect(HomeFeed.new(alice).get(10).pluck(:id)).to_not include(status.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'removes status from local follower\'s home feed' do
|
it 'removes status from local follower\'s home feed' do
|
||||||
subject.call(@status)
|
subject.call(status)
|
||||||
expect(HomeFeed.new(jeff).get(10).pluck(:id)).to_not include(@status.id)
|
expect(HomeFeed.new(jeff).get(10).pluck(:id)).to_not include(status.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends Delete activity to followers' do
|
it 'sends Delete activity to followers' do
|
||||||
subject.call(@status)
|
subject.call(status)
|
||||||
expect(a_request(:post, 'http://example.com/inbox').with(
|
expect(a_request(:post, 'http://example.com/inbox').with(
|
||||||
body: hash_including({
|
body: hash_including({
|
||||||
'type' => 'Delete',
|
'type' => 'Delete',
|
||||||
'object' => {
|
'object' => {
|
||||||
'type' => 'Tombstone',
|
'type' => 'Tombstone',
|
||||||
'id' => ActivityPub::TagManager.instance.uri_for(@status),
|
'id' => ActivityPub::TagManager.instance.uri_for(status),
|
||||||
'atomUri' => OStatus::TagManager.instance.uri_for(@status),
|
'atomUri' => OStatus::TagManager.instance.uri_for(status),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
)).to have_been_made.once
|
)).to have_been_made.once
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends Delete activity to rebloggers' do
|
it 'sends Delete activity to rebloggers' do
|
||||||
subject.call(@status)
|
subject.call(status)
|
||||||
expect(a_request(:post, 'http://example2.com/inbox').with(
|
expect(a_request(:post, 'http://example2.com/inbox').with(
|
||||||
body: hash_including({
|
body: hash_including({
|
||||||
'type' => 'Delete',
|
'type' => 'Delete',
|
||||||
'object' => {
|
'object' => {
|
||||||
'type' => 'Tombstone',
|
'type' => 'Tombstone',
|
||||||
'id' => ActivityPub::TagManager.instance.uri_for(@status),
|
'id' => ActivityPub::TagManager.instance.uri_for(status),
|
||||||
'atomUri' => OStatus::TagManager.instance.uri_for(@status),
|
'atomUri' => OStatus::TagManager.instance.uri_for(status),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
)).to have_been_made.once
|
)).to have_been_made.once
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'remove status from notifications' do
|
it 'remove status from notifications' do
|
||||||
expect { subject.call(@status) }.to change {
|
expect { subject.call(status) }.to change {
|
||||||
Notification.where(activity_type: 'Favourite', from_account: jeff, account: alice).count
|
Notification.where(activity_type: 'Favourite', from_account: jeff, account: alice).count
|
||||||
}.from(1).to(0)
|
}.from(1).to(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when removed status is a private self-reblog' do
|
context 'when removed status is a private self-reblog' do
|
||||||
before do
|
let!(:original_status) { Fabricate(:status, account: alice, text: 'Hello ThisIsASecret', visibility: :private) }
|
||||||
@original_status = Fabricate(:status, account: alice, text: 'Hello ThisIsASecret', visibility: :private)
|
let!(:status) { ReblogService.new.call(alice, original_status) }
|
||||||
@status = ReblogService.new.call(alice, @original_status)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sends Undo activity to followers' do
|
it 'sends Undo activity to followers' do
|
||||||
subject.call(@status)
|
subject.call(status)
|
||||||
expect(a_request(:post, 'http://example.com/inbox').with(
|
expect(a_request(:post, 'http://example.com/inbox').with(
|
||||||
body: hash_including({
|
body: hash_including({
|
||||||
'type' => 'Undo',
|
'type' => 'Undo',
|
||||||
'object' => hash_including({
|
'object' => hash_including({
|
||||||
'type' => 'Announce',
|
'type' => 'Announce',
|
||||||
'object' => ActivityPub::TagManager.instance.uri_for(@original_status),
|
'object' => ActivityPub::TagManager.instance.uri_for(original_status),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
)).to have_been_made.once
|
)).to have_been_made.once
|
||||||
|
@ -92,19 +91,17 @@ RSpec.describe RemoveStatusService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when removed status is public self-reblog' do
|
context 'when removed status is public self-reblog' do
|
||||||
before do
|
let!(:original_status) { Fabricate(:status, account: alice, text: 'Hello ThisIsASecret', visibility: :public) }
|
||||||
@original_status = Fabricate(:status, account: alice, text: 'Hello ThisIsASecret', visibility: :public)
|
let!(:status) { ReblogService.new.call(alice, original_status) }
|
||||||
@status = ReblogService.new.call(alice, @original_status)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sends Undo activity to followers' do
|
it 'sends Undo activity to followers' do
|
||||||
subject.call(@status)
|
subject.call(status)
|
||||||
expect(a_request(:post, 'http://example.com/inbox').with(
|
expect(a_request(:post, 'http://example.com/inbox').with(
|
||||||
body: hash_including({
|
body: hash_including({
|
||||||
'type' => 'Undo',
|
'type' => 'Undo',
|
||||||
'object' => hash_including({
|
'object' => hash_including({
|
||||||
'type' => 'Announce',
|
'type' => 'Announce',
|
||||||
'object' => ActivityPub::TagManager.instance.uri_for(@original_status),
|
'object' => ActivityPub::TagManager.instance.uri_for(original_status),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
)).to have_been_made.once
|
)).to have_been_made.once
|
||||||
|
|
|
@ -19,17 +19,15 @@ describe SearchService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with an url query' do
|
describe 'with an url query' do
|
||||||
before do
|
let(:query) { 'http://test.host/query' }
|
||||||
@query = 'http://test.host/query'
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when it does not find anything' do
|
context 'when it does not find anything' do
|
||||||
it 'returns the empty results' do
|
it 'returns the empty results' do
|
||||||
service = instance_double(ResolveURLService, call: nil)
|
service = instance_double(ResolveURLService, call: nil)
|
||||||
allow(ResolveURLService).to receive(:new).and_return(service)
|
allow(ResolveURLService).to receive(:new).and_return(service)
|
||||||
results = subject.call(@query, nil, 10, resolve: true)
|
results = subject.call(query, nil, 10, resolve: true)
|
||||||
|
|
||||||
expect(service).to have_received(:call).with(@query, on_behalf_of: nil)
|
expect(service).to have_received(:call).with(query, on_behalf_of: nil)
|
||||||
expect(results).to eq empty_results
|
expect(results).to eq empty_results
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -40,8 +38,8 @@ describe SearchService, type: :service do
|
||||||
service = instance_double(ResolveURLService, call: account)
|
service = instance_double(ResolveURLService, call: account)
|
||||||
allow(ResolveURLService).to receive(:new).and_return(service)
|
allow(ResolveURLService).to receive(:new).and_return(service)
|
||||||
|
|
||||||
results = subject.call(@query, nil, 10, resolve: true)
|
results = subject.call(query, nil, 10, resolve: true)
|
||||||
expect(service).to have_received(:call).with(@query, on_behalf_of: nil)
|
expect(service).to have_received(:call).with(query, on_behalf_of: nil)
|
||||||
expect(results).to eq empty_results.merge(accounts: [account])
|
expect(results).to eq empty_results.merge(accounts: [account])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -52,8 +50,8 @@ describe SearchService, type: :service do
|
||||||
service = instance_double(ResolveURLService, call: status)
|
service = instance_double(ResolveURLService, call: status)
|
||||||
allow(ResolveURLService).to receive(:new).and_return(service)
|
allow(ResolveURLService).to receive(:new).and_return(service)
|
||||||
|
|
||||||
results = subject.call(@query, nil, 10, resolve: true)
|
results = subject.call(query, nil, 10, resolve: true)
|
||||||
expect(service).to have_received(:call).with(@query, on_behalf_of: nil)
|
expect(service).to have_received(:call).with(query, on_behalf_of: nil)
|
||||||
expect(results).to eq empty_results.merge(statuses: [status])
|
expect(results).to eq empty_results.merge(statuses: [status])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,38 +6,36 @@ describe UnblockDomainService, type: :service do
|
||||||
subject { described_class.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
describe 'call' do
|
describe 'call' do
|
||||||
before do
|
let!(:independently_suspended) { Fabricate(:account, domain: 'example.com', suspended_at: 1.hour.ago) }
|
||||||
@independently_suspended = Fabricate(:account, domain: 'example.com', suspended_at: 1.hour.ago)
|
let!(:independently_silenced) { Fabricate(:account, domain: 'example.com', silenced_at: 1.hour.ago) }
|
||||||
@independently_silenced = Fabricate(:account, domain: 'example.com', silenced_at: 1.hour.ago)
|
let!(:domain_block) { Fabricate(:domain_block, domain: 'example.com') }
|
||||||
@domain_block = Fabricate(:domain_block, domain: 'example.com')
|
let!(:silenced) { Fabricate(:account, domain: 'example.com', silenced_at: domain_block.created_at) }
|
||||||
@silenced = Fabricate(:account, domain: 'example.com', silenced_at: @domain_block.created_at)
|
let!(:suspended) { Fabricate(:account, domain: 'example.com', suspended_at: domain_block.created_at) }
|
||||||
@suspended = Fabricate(:account, domain: 'example.com', suspended_at: @domain_block.created_at)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'unsilences accounts and removes block' do
|
it 'unsilences accounts and removes block' do
|
||||||
@domain_block.update(severity: :silence)
|
domain_block.update(severity: :silence)
|
||||||
|
|
||||||
subject.call(@domain_block)
|
subject.call(domain_block)
|
||||||
expect_deleted_domain_block
|
expect_deleted_domain_block
|
||||||
expect(@silenced.reload.silenced?).to be false
|
expect(silenced.reload.silenced?).to be false
|
||||||
expect(@suspended.reload.suspended?).to be true
|
expect(suspended.reload.suspended?).to be true
|
||||||
expect(@independently_suspended.reload.suspended?).to be true
|
expect(independently_suspended.reload.suspended?).to be true
|
||||||
expect(@independently_silenced.reload.silenced?).to be true
|
expect(independently_silenced.reload.silenced?).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'unsuspends accounts and removes block' do
|
it 'unsuspends accounts and removes block' do
|
||||||
@domain_block.update(severity: :suspend)
|
domain_block.update(severity: :suspend)
|
||||||
|
|
||||||
subject.call(@domain_block)
|
subject.call(domain_block)
|
||||||
expect_deleted_domain_block
|
expect_deleted_domain_block
|
||||||
expect(@suspended.reload.suspended?).to be false
|
expect(suspended.reload.suspended?).to be false
|
||||||
expect(@silenced.reload.silenced?).to be false
|
expect(silenced.reload.silenced?).to be false
|
||||||
expect(@independently_suspended.reload.suspended?).to be true
|
expect(independently_suspended.reload.suspended?).to be true
|
||||||
expect(@independently_silenced.reload.silenced?).to be true
|
expect(independently_silenced.reload.silenced?).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def expect_deleted_domain_block
|
def expect_deleted_domain_block
|
||||||
expect { @domain_block.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
expect { domain_block.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue