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:
Claire
2023-05-08 19:05:55 +02:00
429 changed files with 6138 additions and 3323 deletions

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::Accounts::PinsController, type: :controller do
RSpec.describe Api::V1::Accounts::PinsController do
let(:john) { Fabricate(:user) }
let(:kevin) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: john.id, scopes: 'write:accounts') }

View File

@@ -21,7 +21,7 @@ describe Api::V1::Accounts::RelationshipsController do
lewis.follow!(user.account)
end
context 'provided only one ID' do
context 'when provided only one ID' do
before do
get :index, params: { id: simon.id }
end
@@ -39,7 +39,7 @@ describe Api::V1::Accounts::RelationshipsController do
end
end
context 'provided multiple IDs' do
context 'when provided multiple IDs' do
before do
get :index, params: { id: [simon.id, lewis.id] }
end

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::Accounts::SearchController, type: :controller do
RSpec.describe Api::V1::Accounts::SearchController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::AccountsController, type: :controller do
RSpec.describe Api::V1::AccountsController do
render_views
let(:user) { Fabricate(:user) }
@@ -30,7 +30,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
post :create, params: { username: 'test', password: '12345678', email: 'hello@world.tld', agreement: agreement }
end
context 'given truthy agreement' do
context 'when given truthy agreement' do
let(:agreement) { 'true' }
it 'returns http success' do
@@ -48,7 +48,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
end
end
context 'given no agreement' do
context 'when given no agreement' do
it 'returns http unprocessable entity' do
expect(response).to have_http_status(422)
end
@@ -121,7 +121,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
end
end
context 'modifying follow options' do
context 'when modifying follow options' do
let(:locked) { false }
before do

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::Admin::AccountActionsController, type: :controller do
RSpec.describe Api::V1::Admin::AccountActionsController do
render_views
let(:role) { UserRole.find_by(name: 'Moderator') }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::Admin::AccountsController, type: :controller do
RSpec.describe Api::V1::Admin::AccountsController do
render_views
let(:role) { UserRole.find_by(name: 'Moderator') }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::Admin::DomainAllowsController, type: :controller do
RSpec.describe Api::V1::Admin::DomainAllowsController do
render_views
let(:role) { UserRole.find_by(name: 'Admin') }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::Admin::DomainBlocksController, type: :controller do
RSpec.describe Api::V1::Admin::DomainBlocksController do
render_views
let(:role) { UserRole.find_by(name: 'Admin') }
@@ -84,7 +84,7 @@ RSpec.describe Api::V1::Admin::DomainBlocksController, type: :controller do
BlockDomainService.new.call(domain_block)
end
context 'downgrading a domain suspension to silence' do
context 'when downgrading a domain suspension to silence' do
let(:original_severity) { 'suspend' }
let(:new_severity) { 'silence' }
@@ -101,7 +101,7 @@ RSpec.describe Api::V1::Admin::DomainBlocksController, type: :controller do
end
end
context 'upgrading a domain silence to suspend' do
context 'when upgrading a domain silence to suspend' do
let(:original_severity) { 'silence' }
let(:new_severity) { 'suspend' }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::Admin::ReportsController, type: :controller do
RSpec.describe Api::V1::Admin::ReportsController do
render_views
let(:role) { UserRole.find_by(name: 'Moderator') }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::Announcements::ReactionsController, type: :controller do
RSpec.describe Api::V1::Announcements::ReactionsController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::AnnouncementsController, type: :controller do
RSpec.describe Api::V1::AnnouncementsController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::AppsController, type: :controller do
RSpec.describe Api::V1::AppsController do
render_views
describe 'POST #create' do

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::BlocksController, type: :controller do
RSpec.describe Api::V1::BlocksController do
render_views
let(:user) { Fabricate(:user) }
@@ -13,13 +13,13 @@ RSpec.describe Api::V1::BlocksController, type: :controller do
describe 'GET #index' do
it 'limits according to limit parameter' do
2.times.map { Fabricate(:block, account: user.account) }
Array.new(2) { Fabricate(:block, account: user.account) }
get :index, params: { limit: 1 }
expect(body_as_json.size).to eq 1
end
it 'queries blocks in range according to max_id' do
blocks = 2.times.map { Fabricate(:block, account: user.account) }
blocks = Array.new(2) { Fabricate(:block, account: user.account) }
get :index, params: { max_id: blocks[1] }
@@ -28,7 +28,7 @@ RSpec.describe Api::V1::BlocksController, type: :controller do
end
it 'queries blocks in range according to since_id' do
blocks = 2.times.map { Fabricate(:block, account: user.account) }
blocks = Array.new(2) { Fabricate(:block, account: user.account) }
get :index, params: { since_id: blocks[0] }
@@ -37,7 +37,7 @@ RSpec.describe Api::V1::BlocksController, type: :controller do
end
it 'sets pagination header for next path' do
blocks = 2.times.map { Fabricate(:block, account: user.account) }
blocks = Array.new(2) { Fabricate(:block, account: user.account) }
get :index, params: { limit: 1, since_id: blocks[0] }
expect(response.headers['Link'].find_link(%w(rel next)).href).to eq api_v1_blocks_url(limit: 1, max_id: blocks[1])
end

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::BookmarksController, type: :controller do
RSpec.describe Api::V1::BookmarksController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::ConversationsController, type: :controller do
RSpec.describe Api::V1::ConversationsController do
render_views
let!(:user) { Fabricate(:user, account_attributes: { username: 'alice' }) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::CustomEmojisController, type: :controller do
RSpec.describe Api::V1::CustomEmojisController do
render_views
describe 'GET #index' do

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::DomainBlocksController, type: :controller do
RSpec.describe Api::V1::DomainBlocksController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::Emails::ConfirmationsController, type: :controller do
RSpec.describe Api::V1::Emails::ConfirmationsController do
let(:confirmed_at) { nil }
let(:user) { Fabricate(:user, confirmed_at: confirmed_at) }
let(:app) { Fabricate(:application) }
@@ -15,14 +15,14 @@ RSpec.describe Api::V1::Emails::ConfirmationsController, type: :controller do
allow(controller).to receive(:doorkeeper_token) { token }
end
context 'from a random app' do
context 'when from a random app' do
it 'returns http forbidden' do
post :create
expect(response).to have_http_status(403)
end
end
context 'from an app that created the account' do
context 'when from an app that created the account' do
before do
user.update(created_by_application: token.application)
end
@@ -35,7 +35,7 @@ RSpec.describe Api::V1::Emails::ConfirmationsController, type: :controller do
expect(response).to have_http_status(403)
end
context 'but user changed e-mail and has not confirmed it' do
context 'with user changed e-mail and has not confirmed it' do
before do
user.update(email: 'foo@bar.com')
end

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::EndorsementsController, type: :controller do
RSpec.describe Api::V1::EndorsementsController do
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::FavouritesController, type: :controller do
RSpec.describe Api::V1::FavouritesController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::FiltersController, type: :controller do
RSpec.describe Api::V1::FiltersController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::FollowRequestsController, type: :controller do
RSpec.describe Api::V1::FollowRequestsController do
render_views
let(:user) { Fabricate(:user, account_attributes: { locked: true }) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::FollowedTagsController, type: :controller do
RSpec.describe Api::V1::FollowedTagsController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,14 +2,14 @@
require 'rails_helper'
RSpec.describe Api::V1::Instances::ActivityController, type: :controller do
RSpec.describe Api::V1::Instances::ActivityController do
describe 'GET #show' do
it 'returns 200' do
get :show
expect(response).to have_http_status(200)
end
context '!Setting.activity_api_enabled' do
context 'with !Setting.activity_api_enabled' do
it 'returns 404' do
Setting.activity_api_enabled = false

View File

@@ -2,14 +2,14 @@
require 'rails_helper'
RSpec.describe Api::V1::Instances::PeersController, type: :controller do
RSpec.describe Api::V1::Instances::PeersController do
describe 'GET #index' do
it 'returns 200' do
get :index
expect(response).to have_http_status(200)
end
context '!Setting.peers_api_enabled' do
context 'with !Setting.peers_api_enabled' do
it 'returns 404' do
Setting.peers_api_enabled = false

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::InstancesController, type: :controller do
RSpec.describe Api::V1::InstancesController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -29,17 +29,48 @@ describe Api::V1::Lists::AccountsController do
let(:scopes) { 'write:lists' }
let(:bob) { Fabricate(:account, username: 'bob') }
before do
user.account.follow!(bob)
post :create, params: { list_id: list.id, account_ids: [bob.id] }
context 'when the added account is followed' do
before do
user.account.follow!(bob)
post :create, params: { list_id: list.id, account_ids: [bob.id] }
end
it 'returns http success' do
expect(response).to have_http_status(200)
end
it 'adds account to the list' do
expect(list.accounts.include?(bob)).to be true
end
end
it 'returns http success' do
expect(response).to have_http_status(200)
context 'when the added account has been sent a follow request' do
before do
user.account.follow_requests.create!(target_account: bob)
post :create, params: { list_id: list.id, account_ids: [bob.id] }
end
it 'returns http success' do
expect(response).to have_http_status(200)
end
it 'adds account to the list' do
expect(list.accounts.include?(bob)).to be true
end
end
it 'adds account to the list' do
expect(list.accounts.include?(bob)).to be true
context 'when the added account is not followed' do
before do
post :create, params: { list_id: list.id, account_ids: [bob.id] }
end
it 'returns http not found' do
expect(response).to have_http_status(404)
end
it 'does not add the account to the list' do
expect(list.accounts.include?(bob)).to be false
end
end
end

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::ListsController, type: :controller do
RSpec.describe Api::V1::ListsController do
render_views
let!(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::MarkersController, type: :controller do
RSpec.describe Api::V1::MarkersController do
render_views
let!(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::MediaController, type: :controller do
RSpec.describe Api::V1::MediaController do
render_views
let(:user) { Fabricate(:user) }
@@ -37,7 +37,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do
end
end
context 'image/jpeg' do
context 'with image/jpeg' do
before do
post :create, params: { file: fixture_file_upload('attachment.jpg', 'image/jpeg') }
end
@@ -59,7 +59,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do
end
end
context 'image/gif' do
context 'with image/gif' do
before do
post :create, params: { file: fixture_file_upload('attachment.gif', 'image/gif') }
end
@@ -81,7 +81,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do
end
end
context 'video/webm' do
context 'with video/webm' do
before do
post :create, params: { file: fixture_file_upload('attachment.webm', 'video/webm') }
end

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::MutesController, type: :controller do
RSpec.describe Api::V1::MutesController do
render_views
let(:user) { Fabricate(:user) }
@@ -13,13 +13,13 @@ RSpec.describe Api::V1::MutesController, type: :controller do
describe 'GET #index' do
it 'limits according to limit parameter' do
2.times.map { Fabricate(:mute, account: user.account) }
Array.new(2) { Fabricate(:mute, account: user.account) }
get :index, params: { limit: 1 }
expect(body_as_json.size).to eq 1
end
it 'queries mutes in range according to max_id' do
mutes = 2.times.map { Fabricate(:mute, account: user.account) }
mutes = Array.new(2) { Fabricate(:mute, account: user.account) }
get :index, params: { max_id: mutes[1] }
@@ -28,7 +28,7 @@ RSpec.describe Api::V1::MutesController, type: :controller do
end
it 'queries mutes in range according to since_id' do
mutes = 2.times.map { Fabricate(:mute, account: user.account) }
mutes = Array.new(2) { Fabricate(:mute, account: user.account) }
get :index, params: { since_id: mutes[0] }
@@ -37,7 +37,7 @@ RSpec.describe Api::V1::MutesController, type: :controller do
end
it 'sets pagination header for next path' do
mutes = 2.times.map { Fabricate(:mute, account: user.account) }
mutes = Array.new(2) { Fabricate(:mute, account: user.account) }
get :index, params: { limit: 1, since_id: mutes[0] }
expect(response.headers['Link'].find_link(%w(rel next)).href).to eq api_v1_mutes_url(limit: 1, max_id: mutes[1])
end

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::NotificationsController, type: :controller do
RSpec.describe Api::V1::NotificationsController do
render_views
let(:user) { Fabricate(:user, account_attributes: { username: 'alice' }) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::Polls::VotesController, type: :controller do
RSpec.describe Api::V1::Polls::VotesController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::PollsController, type: :controller do
RSpec.describe Api::V1::PollsController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::ReportsController, type: :controller do
RSpec.describe Api::V1::ReportsController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::Statuses::FavouritedByAccountsController, type: :controller do
RSpec.describe Api::V1::Statuses::FavouritedByAccountsController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::Statuses::RebloggedByAccountsController, type: :controller do
RSpec.describe Api::V1::Statuses::RebloggedByAccountsController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::StatusesController, type: :controller do
RSpec.describe Api::V1::StatusesController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::SuggestionsController, type: :controller do
RSpec.describe Api::V1::SuggestionsController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::TagsController, type: :controller do
RSpec.describe Api::V1::TagsController do
render_views
let(:user) { Fabricate(:user) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe Api::V1::Trends::TagsController, type: :controller do
RSpec.describe Api::V1::Trends::TagsController do
render_views
describe 'GET #index' do