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 AccountsHelper, type: :helper do
RSpec.describe AccountsHelper do
def set_not_embedded_view
params[:controller] = "not_#{StatusesHelper::EMBEDDED_CONTROLLER}"
params[:action] = "not_#{StatusesHelper::EMBEDDED_ACTION}"

View File

@@ -2,11 +2,11 @@
require 'rails_helper'
RSpec.describe Admin::AccountModerationNotesHelper, type: :helper do
RSpec.describe Admin::AccountModerationNotesHelper do
include AccountsHelper
describe '#admin_account_link_to' do
context 'account is nil' do
context 'when Account is nil' do
let(:account) { nil }
it 'returns nil' do
@@ -30,7 +30,7 @@ RSpec.describe Admin::AccountModerationNotesHelper, type: :helper do
end
describe '#admin_account_inline_link_to' do
context 'account is nil' do
context 'when Account is nil' do
let(:account) { nil }
it 'returns nil' do

View File

@@ -2,5 +2,5 @@
require 'rails_helper'
RSpec.describe Admin::ActionLogsHelper, type: :helper do
RSpec.describe Admin::ActionLogsHelper do
end

View File

@@ -124,6 +124,164 @@ describe ApplicationHelper do
end
end
describe 'available_sign_up_path' do
context 'when registrations are closed' do
before do
without_partial_double_verification do
allow(Setting).to receive(:registrations_mode).and_return('none')
end
end
it 'redirects to joinmastodon site' do
expect(helper.available_sign_up_path).to match(/joinmastodon.org/)
end
end
context 'when in omniauth only mode' do
around do |example|
ClimateControl.modify OMNIAUTH_ONLY: 'true' do
example.run
end
end
it 'redirects to joinmastodon site' do
expect(helper.available_sign_up_path).to match(/joinmastodon.org/)
end
end
context 'when registrations are allowed' do
it 'returns a link to the registration page' do
expect(helper.available_sign_up_path).to eq(new_user_registration_path)
end
end
end
describe 'omniauth_only?' do
context 'when env var is set to true' do
around do |example|
ClimateControl.modify OMNIAUTH_ONLY: 'true' do
example.run
end
end
it 'returns true' do
expect(helper).to be_omniauth_only
end
end
context 'when env var is not set' do
around do |example|
ClimateControl.modify OMNIAUTH_ONLY: nil do
example.run
end
end
it 'returns false' do
expect(helper).to_not be_omniauth_only
end
end
end
describe 'quote_wrap' do
it 'indents and quote wraps text' do
text = <<~TEXT
Hello this is a nice message for you to quote.
Be careful because it has two lines.
TEXT
expect(helper.quote_wrap(text)).to eq <<~EXPECTED.strip
> Hello this is a nice message for you to quote.
> Be careful because it has two lines.
EXPECTED
end
end
describe 'storage_host' do
context 'when S3 alias is present' do
around do |example|
ClimateControl.modify S3_ALIAS_HOST: 's3.alias' do
example.run
end
end
it 'returns true' do
expect(helper.storage_host).to eq('https://s3.alias')
end
end
context 'when S3 cloudfront is present' do
around do |example|
ClimateControl.modify S3_CLOUDFRONT_HOST: 's3.cloudfront' do
example.run
end
end
it 'returns true' do
expect(helper.storage_host).to eq('https://s3.cloudfront')
end
end
context 'when neither env value is present' do
it 'returns false' do
expect(helper.storage_host).to eq('https:')
end
end
end
describe 'storage_host?' do
context 'when S3 alias is present' do
around do |example|
ClimateControl.modify S3_ALIAS_HOST: 's3.alias' do
example.run
end
end
it 'returns true' do
expect(helper.storage_host?).to be true
end
end
context 'when S3 cloudfront is present' do
around do |example|
ClimateControl.modify S3_CLOUDFRONT_HOST: 's3.cloudfront' do
example.run
end
end
it 'returns true' do
expect(helper.storage_host?).to be true
end
end
context 'when neither env value is present' do
it 'returns false' do
expect(helper.storage_host?).to be false
end
end
end
describe 'visibility_icon' do
it 'returns a globe icon for a public visible status' do
result = helper.visibility_icon Status.new(visibility: 'public')
expect(result).to match(/globe/)
end
it 'returns an unlock icon for a unlisted visible status' do
result = helper.visibility_icon Status.new(visibility: 'unlisted')
expect(result).to match(/unlock/)
end
it 'returns a lock icon for a private visible status' do
result = helper.visibility_icon Status.new(visibility: 'private')
expect(result).to match(/lock/)
end
it 'returns an at icon for a direct visible status' do
result = helper.visibility_icon Status.new(visibility: 'direct')
expect(result).to match(/at/)
end
end
describe 'title' do
around do |example|
site_title = Setting.site_title

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
describe FlashesHelper, type: :helper do
describe FlashesHelper do
describe 'user_facing_flashes' do
it 'returns user facing flashes' do
flash[:alert] = 'an alert'

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
describe FormattingHelper, type: :helper do
describe FormattingHelper do
include Devise::Test::ControllerHelpers
describe '#rss_status_content_format' do

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe HomeHelper, type: :helper do
RSpec.describe HomeHelper do
describe 'default_props' do
it 'returns default properties according to the context' do
expect(helper.default_props).to eq locale: I18n.locale

View File

@@ -22,14 +22,14 @@ describe JsonLdHelper do
end
describe '#first_of_value' do
context 'value.is_a?(Array)' do
context 'when value.is_a?(Array)' do
it 'returns value.first' do
value = ['a']
expect(helper.first_of_value(value)).to be 'a'
end
end
context '!value.is_a?(Array)' do
context 'with !value.is_a?(Array)' do
it 'returns value' do
value = 'a'
expect(helper.first_of_value(value)).to be 'a'
@@ -38,14 +38,14 @@ describe JsonLdHelper do
end
describe '#supported_context?' do
context "!json.nil? && equals_or_includes?(json['@context'], ActivityPub::TagManager::CONTEXT)" do
context 'when json is present and in an activitypub tagmanager context' do
it 'returns true' do
json = { '@context' => ActivityPub::TagManager::CONTEXT }.as_json
expect(helper.supported_context?(json)).to be true
end
end
context 'else' do
context 'when not in activitypub tagmanager context' do
it 'returns false' do
json = nil
expect(helper.supported_context?(json)).to be false
@@ -90,7 +90,7 @@ describe JsonLdHelper do
end
end
context 'compaction and forwarding' do
context 'with compaction and forwarding' do
let(:json) do
{
'@context' => [

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe RoutingHelper, type: :helper do
RSpec.describe RoutingHelper do
describe '.full_asset_url' do
around do |example|
use_s3 = Rails.configuration.x.use_s3
@@ -24,7 +24,7 @@ RSpec.describe RoutingHelper, type: :helper do
end
end
context 'Do not use S3' do
context 'when not using S3' do
before do
Rails.configuration.x.use_s3 = false
end
@@ -32,7 +32,7 @@ RSpec.describe RoutingHelper, type: :helper do
it_behaves_like 'returns full path URL'
end
context 'Use S3' do
context 'when using S3' do
before do
Rails.configuration.x.use_s3 = true
end