Merge commit 'f877aa9d70d0d600961989b8e97c0e0ce3ac1db6' into glitch-soc/merge-upstream
Conflicts: - `.github/dependabot.yml`: Upstream made changes, but we had removed it. Discarded upstream changes. - `.rubocop_todo.yml`: Upstream regenerated the file, we had some glitch-soc-specific ignores. - `app/models/account_statuses_filter.rb`: Minor upstream code style change where glitch-soc had slightly different code due to handling of local-only posts. Updated to match upstream's code style. - `app/models/status.rb`: Upstream moved ActiveRecord callback definitions, glitch-soc had an extra one. Moved the definitions as upstream did. - `app/services/backup_service.rb`: Upstream rewrote a lot of the backup service, glitch-soc had changes because of exporting local-only posts. Took upstream changes and added back code to deal with local-only posts. - `config/routes.rb`: Upstream split the file into different files, while glitch-soc had a few extra routes. Extra routes added to `config/routes/settings.rb`, `config/routes/api.rb` and `config/routes/admin.rb` - `db/schema.rb`: Upstream has new migrations, while glitch-soc had an extra migration. Updated the expected serial number to match upstream's. - `lib/mastodon/version.rb`: Upstream added support to set version tags from environment variables, while glitch-soc has an extra `+glitch` tag. Changed the code to support upstream's feature but prepending a `+glitch`. - `spec/lib/activitypub/activity/create_spec.rb`: Minor code style change upstream, while glitch-soc has extra tests due to `directMessage` handling. Applied upstream's changes while keeping glitch-soc's extra tests. - `spec/models/concerns/account_interactions_spec.rb`: Minor code style change upstream, while glitch-soc has extra tests. Applied upstream's changes while keeping glitch-soc's extra tests.
This commit is contained in:
@@ -50,7 +50,7 @@ describe Settings::ApplicationsController do
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'success (passed scopes as a String)' do
|
||||
context 'when success (passed scopes as a String)' do
|
||||
def call_create
|
||||
post :create, params: {
|
||||
doorkeeper_application: {
|
||||
@@ -72,7 +72,7 @@ describe Settings::ApplicationsController do
|
||||
end
|
||||
end
|
||||
|
||||
context 'success (passed scopes as an Array)' do
|
||||
context 'when success (passed scopes as an Array)' do
|
||||
def call_create
|
||||
post :create, params: {
|
||||
doorkeeper_application: {
|
||||
@@ -94,7 +94,7 @@ describe Settings::ApplicationsController do
|
||||
end
|
||||
end
|
||||
|
||||
context 'failure' do
|
||||
context 'with failure request' do
|
||||
before do
|
||||
post :create, params: {
|
||||
doorkeeper_application: {
|
||||
@@ -117,7 +117,7 @@ describe Settings::ApplicationsController do
|
||||
end
|
||||
|
||||
describe 'PATCH #update' do
|
||||
context 'success' do
|
||||
context 'when success' do
|
||||
let(:opts) do
|
||||
{
|
||||
website: 'https://foo.bar/',
|
||||
@@ -142,7 +142,7 @@ describe Settings::ApplicationsController do
|
||||
end
|
||||
end
|
||||
|
||||
context 'failure' do
|
||||
context 'with failure request' do
|
||||
before do
|
||||
patch :update, params: {
|
||||
id: app.id,
|
||||
|
@@ -2,16 +2,25 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Settings::ImportsController, type: :controller do
|
||||
RSpec.describe Settings::ImportsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
sign_in Fabricate(:user), scope: :user
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
describe 'GET #index' do
|
||||
let!(:import) { Fabricate(:bulk_import, account: user.account) }
|
||||
let!(:other_import) { Fabricate(:bulk_import) }
|
||||
|
||||
before do
|
||||
get :show
|
||||
get :index
|
||||
end
|
||||
|
||||
it 'assigns the expected imports' do
|
||||
expect(assigns(:recent_imports)).to eq [import]
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
@@ -23,31 +32,288 @@ RSpec.describe Settings::ImportsController, type: :controller do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
it 'redirects to settings path with successful following import' do
|
||||
service = double(call: nil)
|
||||
allow(ResolveAccountService).to receive(:new).and_return(service)
|
||||
post :create, params: {
|
||||
import: {
|
||||
type: 'following',
|
||||
data: fixture_file_upload('imports.txt'),
|
||||
},
|
||||
}
|
||||
|
||||
expect(response).to redirect_to(settings_import_path)
|
||||
describe 'GET #show' do
|
||||
before do
|
||||
get :show, params: { id: bulk_import.id }
|
||||
end
|
||||
|
||||
it 'redirects to settings path with successful blocking import' do
|
||||
service = double(call: nil)
|
||||
allow(ResolveAccountService).to receive(:new).and_return(service)
|
||||
post :create, params: {
|
||||
import: {
|
||||
type: 'blocking',
|
||||
data: fixture_file_upload('imports.txt'),
|
||||
},
|
||||
}
|
||||
context 'with someone else\'s import' do
|
||||
let(:bulk_import) { Fabricate(:bulk_import, state: :unconfirmed) }
|
||||
|
||||
expect(response).to redirect_to(settings_import_path)
|
||||
it 'returns http not found' do
|
||||
expect(response).to have_http_status(404)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an already-confirmed import' do
|
||||
let(:bulk_import) { Fabricate(:bulk_import, account: user.account, state: :in_progress) }
|
||||
|
||||
it 'returns http not found' do
|
||||
expect(response).to have_http_status(404)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an unconfirmed import' do
|
||||
let(:bulk_import) { Fabricate(:bulk_import, account: user.account, state: :unconfirmed) }
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #confirm' do
|
||||
subject { post :confirm, params: { id: bulk_import.id } }
|
||||
|
||||
before do
|
||||
allow(BulkImportWorker).to receive(:perform_async)
|
||||
end
|
||||
|
||||
context 'with someone else\'s import' do
|
||||
let(:bulk_import) { Fabricate(:bulk_import, state: :unconfirmed) }
|
||||
|
||||
it 'does not change the import\'s state' do
|
||||
expect { subject }.to_not(change { bulk_import.reload.state })
|
||||
end
|
||||
|
||||
it 'does not fire the import worker' do
|
||||
subject
|
||||
expect(BulkImportWorker).to_not have_received(:perform_async)
|
||||
end
|
||||
|
||||
it 'returns http not found' do
|
||||
subject
|
||||
expect(response).to have_http_status(404)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an already-confirmed import' do
|
||||
let(:bulk_import) { Fabricate(:bulk_import, account: user.account, state: :in_progress) }
|
||||
|
||||
it 'does not change the import\'s state' do
|
||||
expect { subject }.to_not(change { bulk_import.reload.state })
|
||||
end
|
||||
|
||||
it 'does not fire the import worker' do
|
||||
subject
|
||||
expect(BulkImportWorker).to_not have_received(:perform_async)
|
||||
end
|
||||
|
||||
it 'returns http not found' do
|
||||
subject
|
||||
expect(response).to have_http_status(404)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an unconfirmed import' do
|
||||
let(:bulk_import) { Fabricate(:bulk_import, account: user.account, state: :unconfirmed) }
|
||||
|
||||
it 'changes the import\'s state to scheduled' do
|
||||
expect { subject }.to change { bulk_import.reload.state.to_sym }.from(:unconfirmed).to(:scheduled)
|
||||
end
|
||||
|
||||
it 'fires the import worker on the expected import' do
|
||||
subject
|
||||
expect(BulkImportWorker).to have_received(:perform_async).with(bulk_import.id)
|
||||
end
|
||||
|
||||
it 'redirects to imports path' do
|
||||
subject
|
||||
expect(response).to redirect_to(settings_imports_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
subject { delete :destroy, params: { id: bulk_import.id } }
|
||||
|
||||
context 'with someone else\'s import' do
|
||||
let(:bulk_import) { Fabricate(:bulk_import, state: :unconfirmed) }
|
||||
|
||||
it 'does not delete the import' do
|
||||
expect { subject }.to_not(change { BulkImport.exists?(bulk_import.id) })
|
||||
end
|
||||
|
||||
it 'returns http not found' do
|
||||
subject
|
||||
expect(response).to have_http_status(404)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an already-confirmed import' do
|
||||
let(:bulk_import) { Fabricate(:bulk_import, account: user.account, state: :in_progress) }
|
||||
|
||||
it 'does not delete the import' do
|
||||
expect { subject }.to_not(change { BulkImport.exists?(bulk_import.id) })
|
||||
end
|
||||
|
||||
it 'returns http not found' do
|
||||
subject
|
||||
expect(response).to have_http_status(404)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an unconfirmed import' do
|
||||
let(:bulk_import) { Fabricate(:bulk_import, account: user.account, state: :unconfirmed) }
|
||||
|
||||
it 'deletes the import' do
|
||||
expect { subject }.to change { BulkImport.exists?(bulk_import.id) }.from(true).to(false)
|
||||
end
|
||||
|
||||
it 'redirects to imports path' do
|
||||
subject
|
||||
expect(response).to redirect_to(settings_imports_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #failures' do
|
||||
subject { get :failures, params: { id: bulk_import.id }, format: :csv }
|
||||
|
||||
shared_examples 'export failed rows' do |expected_contents|
|
||||
let(:bulk_import) { Fabricate(:bulk_import, account: user.account, type: import_type, state: :finished) }
|
||||
|
||||
before do
|
||||
bulk_import.update(total_items: bulk_import.rows.count, processed_items: bulk_import.rows.count, imported_items: 0)
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
subject
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns expected contents' do
|
||||
subject
|
||||
expect(response.body).to eq expected_contents
|
||||
end
|
||||
end
|
||||
|
||||
context 'with follows' do
|
||||
let(:import_type) { 'following' }
|
||||
|
||||
let!(:rows) do
|
||||
[
|
||||
{ 'acct' => 'foo@bar' },
|
||||
{ 'acct' => 'user@bar', 'show_reblogs' => false, 'notify' => true, 'languages' => ['fr', 'de'] },
|
||||
].map { |data| Fabricate(:bulk_import_row, bulk_import: bulk_import, data: data) }
|
||||
end
|
||||
|
||||
include_examples 'export failed rows', "Account address,Show boosts,Notify on new posts,Languages\nfoo@bar,true,false,\nuser@bar,false,true,\"fr, de\"\n"
|
||||
end
|
||||
|
||||
context 'with blocks' do
|
||||
let(:import_type) { 'blocking' }
|
||||
|
||||
let!(:rows) do
|
||||
[
|
||||
{ 'acct' => 'foo@bar' },
|
||||
{ 'acct' => 'user@bar' },
|
||||
].map { |data| Fabricate(:bulk_import_row, bulk_import: bulk_import, data: data) }
|
||||
end
|
||||
|
||||
include_examples 'export failed rows', "foo@bar\nuser@bar\n"
|
||||
end
|
||||
|
||||
context 'with mutes' do
|
||||
let(:import_type) { 'muting' }
|
||||
|
||||
let!(:rows) do
|
||||
[
|
||||
{ 'acct' => 'foo@bar' },
|
||||
{ 'acct' => 'user@bar', 'hide_notifications' => false },
|
||||
].map { |data| Fabricate(:bulk_import_row, bulk_import: bulk_import, data: data) }
|
||||
end
|
||||
|
||||
include_examples 'export failed rows', "Account address,Hide notifications\nfoo@bar,true\nuser@bar,false\n"
|
||||
end
|
||||
|
||||
context 'with domain blocks' do
|
||||
let(:import_type) { 'domain_blocking' }
|
||||
|
||||
let!(:rows) do
|
||||
[
|
||||
{ 'domain' => 'bad.domain' },
|
||||
{ 'domain' => 'evil.domain' },
|
||||
].map { |data| Fabricate(:bulk_import_row, bulk_import: bulk_import, data: data) }
|
||||
end
|
||||
|
||||
include_examples 'export failed rows', "bad.domain\nevil.domain\n"
|
||||
end
|
||||
|
||||
context 'with bookmarks' do
|
||||
let(:import_type) { 'bookmarks' }
|
||||
|
||||
let!(:rows) do
|
||||
[
|
||||
{ 'uri' => 'https://foo.com/1' },
|
||||
{ 'uri' => 'https://foo.com/2' },
|
||||
].map { |data| Fabricate(:bulk_import_row, bulk_import: bulk_import, data: data) }
|
||||
end
|
||||
|
||||
include_examples 'export failed rows', "https://foo.com/1\nhttps://foo.com/2\n"
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
subject do
|
||||
post :create, params: {
|
||||
form_import: {
|
||||
type: import_type,
|
||||
mode: import_mode,
|
||||
data: fixture_file_upload(import_file),
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples 'successful import' do |type, file, mode|
|
||||
let(:import_type) { type }
|
||||
let(:import_file) { file }
|
||||
let(:import_mode) { mode }
|
||||
|
||||
it 'creates an unconfirmed bulk_import with expected type' do
|
||||
expect { subject }.to change { user.account.bulk_imports.pluck(:state, :type) }.from([]).to([['unconfirmed', import_type]])
|
||||
end
|
||||
|
||||
it 'redirects to confirmation page for the import' do
|
||||
subject
|
||||
expect(response).to redirect_to(settings_import_path(user.account.bulk_imports.first))
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'unsuccessful import' do |type, file, mode|
|
||||
let(:import_type) { type }
|
||||
let(:import_file) { file }
|
||||
let(:import_mode) { mode }
|
||||
|
||||
it 'does not creates an unconfirmed bulk_import' do
|
||||
expect { subject }.to_not(change { user.account.bulk_imports.count })
|
||||
end
|
||||
|
||||
it 'sets error to the import' do
|
||||
subject
|
||||
expect(assigns(:import).errors).to_not be_empty
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like 'successful import', 'following', 'imports.txt', 'merge'
|
||||
it_behaves_like 'successful import', 'following', 'imports.txt', 'overwrite'
|
||||
it_behaves_like 'successful import', 'blocking', 'imports.txt', 'merge'
|
||||
it_behaves_like 'successful import', 'blocking', 'imports.txt', 'overwrite'
|
||||
it_behaves_like 'successful import', 'muting', 'imports.txt', 'merge'
|
||||
it_behaves_like 'successful import', 'muting', 'imports.txt', 'overwrite'
|
||||
it_behaves_like 'successful import', 'domain_blocking', 'domain_blocks.csv', 'merge'
|
||||
it_behaves_like 'successful import', 'domain_blocking', 'domain_blocks.csv', 'overwrite'
|
||||
it_behaves_like 'successful import', 'bookmarks', 'bookmark-imports.txt', 'merge'
|
||||
it_behaves_like 'successful import', 'bookmarks', 'bookmark-imports.txt', 'overwrite'
|
||||
|
||||
it_behaves_like 'unsuccessful import', 'following', 'domain_blocks.csv', 'merge'
|
||||
it_behaves_like 'unsuccessful import', 'following', 'domain_blocks.csv', 'overwrite'
|
||||
it_behaves_like 'unsuccessful import', 'blocking', 'domain_blocks.csv', 'merge'
|
||||
it_behaves_like 'unsuccessful import', 'blocking', 'domain_blocks.csv', 'overwrite'
|
||||
it_behaves_like 'unsuccessful import', 'muting', 'domain_blocks.csv', 'merge'
|
||||
it_behaves_like 'unsuccessful import', 'muting', 'domain_blocks.csv', 'overwrite'
|
||||
|
||||
it_behaves_like 'unsuccessful import', 'following', 'empty.csv', 'merge'
|
||||
it_behaves_like 'unsuccessful import', 'following', 'empty.csv', 'overwrite'
|
||||
end
|
||||
end
|
||||
|
@@ -31,5 +31,11 @@ describe Settings::Preferences::AppearanceController do
|
||||
|
||||
expect(response).to redirect_to(settings_preferences_appearance_path)
|
||||
end
|
||||
|
||||
it 'renders show on failure' do
|
||||
put :update, params: { user: { locale: 'fake option' } }
|
||||
|
||||
expect(response).to render_template('preferences/appearance/show')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::Preferences::BaseController do
|
||||
describe 'after_update_redirect_path' do
|
||||
it 'raises error when called' do
|
||||
expect { described_class.new.send(:after_update_redirect_path) }.to raise_error(/Override/)
|
||||
end
|
||||
end
|
||||
end
|
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Settings::ProfilesController, type: :controller do
|
||||
RSpec.describe Settings::ProfilesController do
|
||||
render_views
|
||||
|
||||
let!(:user) { Fabricate(:user) }
|
||||
|
@@ -275,7 +275,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
|
||||
end
|
||||
|
||||
context 'when user have not enabled webauthn' do
|
||||
context 'creation succeeds' do
|
||||
context 'when creation succeeds' do
|
||||
it 'creates a webauthn credential' do
|
||||
@controller.session[:webauthn_challenge] = challenge
|
||||
|
||||
|
Reference in New Issue
Block a user