Merge commit 'b896b16cb3c8626fbee12a7eda7f882114b1a040' into glitch-soc/merge-upstream

This commit is contained in:
Claire
2023-05-28 15:01:53 +02:00
40 changed files with 227 additions and 216 deletions

View File

@@ -43,7 +43,7 @@ describe Api::V1::Accounts::NotesController do
it 'does not create account note' do
subject
expect(AccountNote.where(account_id: user.account.id, target_account_id: account.id).exists?).to be_falsey
expect(AccountNote.where(account_id: user.account.id, target_account_id: account.id)).to_not exist
end
end
end

View File

@@ -15,23 +15,19 @@ RSpec.describe Api::V1::MediaController do
describe 'POST #create' do
describe 'with paperclip errors' do
context 'when imagemagick cant identify the file type' do
before do
it 'returns http 422' do
expect_any_instance_of(Account).to receive_message_chain(:media_attachments, :create!).and_raise(Paperclip::Errors::NotIdentifiedByImageMagickError)
post :create, params: { file: fixture_file_upload('attachment.jpg', 'image/jpeg') }
end
it 'returns http 422' do
expect(response).to have_http_status(422)
end
end
context 'when there is a generic error' do
before do
it 'returns http 422' do
expect_any_instance_of(Account).to receive_message_chain(:media_attachments, :create!).and_raise(Paperclip::Error)
post :create, params: { file: fixture_file_upload('attachment.jpg', 'image/jpeg') }
end
it 'returns http 422' do
expect(response).to have_http_status(500)
end
end

View File

@@ -182,12 +182,10 @@ describe Settings::ApplicationsController do
describe 'regenerate' do
let(:token) { user.token_for_app(app) }
before do
it 'creates new token' do
expect(token).to_not be_nil
post :regenerate, params: { id: app.id }
end
it 'creates new token' do
expect(user.token_for_app(app)).to_not eql(token)
end
end

View File

@@ -1,9 +1,9 @@
# frozen_string_literal: true
require 'rails_helper'
require 'mastodon/ip_blocks_cli'
require 'mastodon/cli/ip_blocks'
RSpec.describe Mastodon::IpBlocksCLI do
RSpec.describe Mastodon::CLI::IpBlocks do
let(:cli) { described_class.new }
describe '#add' do

View File

@@ -1,9 +1,9 @@
# frozen_string_literal: true
require 'rails_helper'
require 'cli'
require 'mastodon/cli/main'
describe Mastodon::CLI do
describe Mastodon::CLI::Main do
describe 'version' do
it 'returns the Mastodon version' do
expect { described_class.new.invoke(:version) }.to output(

View File

@@ -1,11 +1,11 @@
# frozen_string_literal: true
require 'rails_helper'
require 'mastodon/settings_cli'
require 'mastodon/cli/settings'
RSpec.describe Mastodon::SettingsCLI do
RSpec.describe Mastodon::CLI::Settings do
describe 'subcommand "registrations"' do
let(:cli) { Mastodon::RegistrationsCLI.new }
let(:cli) { Mastodon::CLI::Registrations.new }
before do
Setting.registrations_mode = nil

View File

@@ -7,7 +7,7 @@ describe StatusFilter do
let(:status) { Fabricate(:status) }
context 'without an account' do
subject { described_class.new(status, nil) }
subject(:filter) { described_class.new(status, nil) }
context 'when there are no connections' do
it { is_expected.to_not be_filtered }
@@ -22,16 +22,16 @@ describe StatusFilter do
end
context 'when status policy does not allow show' do
before do
it 'filters the status' do
expect_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
end
it { is_expected.to be_filtered }
expect(filter).to be_filtered
end
end
end
context 'with real account' do
subject { described_class.new(status, account) }
subject(:filter) { described_class.new(status, account) }
let(:account) { Fabricate(:account) }
@@ -73,11 +73,11 @@ describe StatusFilter do
end
context 'when status policy does not allow show' do
before do
it 'filters the status' do
expect_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
end
it { is_expected.to be_filtered }
expect(filter).to be_filtered
end
end
end
end

View File

@@ -115,19 +115,19 @@ RSpec.describe User do
it 'allows a non-blacklisted user to be created' do
user = User.new(email: 'foo@example.com', account: account, password: password, agreement: true)
expect(user.valid?).to be_truthy
expect(user).to be_valid
end
it 'does not allow a blacklisted user to be created' do
user = User.new(email: 'foo@mvrht.com', account: account, password: password, agreement: true)
expect(user.valid?).to be_falsey
expect(user).to_not be_valid
end
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)
expect(user.valid?).to be_falsey
expect(user).to_not be_valid
end
end
@@ -350,17 +350,17 @@ RSpec.describe User 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)
expect(user.valid?).to be_falsey
expect(user).to_not be_valid
end
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)
expect(user.valid?).to be_truthy
expect(user).to be_valid
end
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)
expect(user.valid?).to be_falsey
expect(user).to_not be_valid
end
context do
@@ -374,7 +374,7 @@ RSpec.describe User do
Rails.configuration.x.email_domains_blacklist = 'blacklisted.mastodon.space'
user = User.new(email: 'foo@blacklisted.mastodon.space', account: account, password: password)
expect(user.valid?).to be_falsey
expect(user).to_not be_valid
end
end
end

View File

@@ -0,0 +1,26 @@
# frozen_string_literal: true
require 'rails_helper'
describe 'Backups' do
include RoutingHelper
describe 'GET backups#download' do
let(:user) { Fabricate(:user) }
let(:backup) { Fabricate(:backup, user: user) }
before do
sign_in user
end
it 'Downloads a user backup' do
get download_backup_path(backup)
expect(response).to redirect_to(backup_dump_url)
end
def backup_dump_url
full_asset_url(backup.dump.url)
end
end
end

View File

@@ -48,7 +48,7 @@ RSpec.describe PostStatusService, type: :service do
expect(status.params['text']).to eq 'Hi future!'
expect(status.params['media_ids']).to eq [media.id]
expect(media.reload.status).to be_nil
expect(Status.where(text: 'Hi future!').exists?).to be_falsey
expect(Status.where(text: 'Hi future!')).to_not exist
end
it 'does not change statuses count' do