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

Conflicts:
- `app/services/backup_service.rb`:
  Upstream refactored activity serialization while glitch-soc passed an extra argument.
  Followed upstream's refactor, keeping our extra argument.
This commit is contained in:
Claire committed 2026-02-05 12:43:12 +01:00
commit 59e02a628d
108 files changed
+1228 -995

No files matched your search

@@ -1,64 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::ConfirmationsController do
render_views
before do
sign_in Fabricate(:admin_user), scope: :user
end
describe 'POST #create' do
it 'confirms the user' do
user = Fabricate(:user, confirmed_at: nil)
post :create, params: { account_id: user.account.id }
expect(response).to redirect_to(admin_accounts_path)
expect(user.reload).to be_confirmed
end
it 'raises an error when there is no account' do
post :create, params: { account_id: 'fake' }
expect(response).to have_http_status(404)
end
it 'raises an error when there is no user' do
account = Fabricate(:account, user: nil)
post :create, params: { account_id: account.id }
expect(response).to have_http_status(404)
end
end
describe 'POST #resend' do
subject { post :resend, params: { account_id: user.account.id } }
let!(:user) { Fabricate(:user, confirmed_at: confirmed_at) }
before do
allow(UserMailer).to receive(:confirmation_instructions) { instance_double(ActionMailer::MessageDelivery, deliver_later: nil) }
end
context 'when email is not confirmed' do
let(:confirmed_at) { nil }
it 'resends confirmation mail' do
expect(subject).to redirect_to admin_accounts_path
expect(flash[:notice]).to eq I18n.t('admin.accounts.resend_confirmation.success')
expect(UserMailer).to have_received(:confirmation_instructions).once
end
end
context 'when email is confirmed' do
let(:confirmed_at) { Time.zone.now }
it 'does not resend confirmation mail' do
expect(subject).to redirect_to admin_accounts_path
expect(flash[:error]).to eq I18n.t('admin.accounts.resend_confirmation.already_confirmed')
expect(UserMailer).to_not have_received(:confirmation_instructions)
end
end
end
end
@@ -70,7 +70,7 @@ RSpec.describe Auth::SessionsController do
end
it 'shows a login error and does not log the user in' do
expect(flash[:alert]).to match I18n.t('devise.failure.invalid', authentication_keys: I18n.t('activerecord.attributes.user.email'))
expect(flash[:alert]).to match(/#{failure_message_invalid_email}/i)
expect(controller.current_user).to be_nil
end
@@ -163,7 +163,7 @@ RSpec.describe Auth::SessionsController do
end
it 'shows a login error and does not log the user in' do
expect(flash[:alert]).to match I18n.t('devise.failure.invalid', authentication_keys: I18n.t('activerecord.attributes.user.email'))
expect(flash[:alert]).to match(/#{failure_message_invalid_email}/i)
expect(controller.current_user).to be_nil
end
@@ -420,5 +420,9 @@ RSpec.describe Auth::SessionsController do
end
end
end
def failure_message_invalid_email
I18n.t('devise.failure.invalid', authentication_keys: I18n.t('activerecord.attributes.user.email'))
end
end
end
+56
View File
@@ -0,0 +1,56 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin Confirmations' do
before { sign_in Fabricate(:admin_user) }
describe 'POST /admin/accounts/:account_id/confirmation' do
context 'when account does not exist' do
let(:account_id) { 'fake' }
it 'raises an error' do
post admin_account_confirmation_path(account_id:)
expect(response)
.to have_http_status(404)
end
end
context 'when account does not have a user' do
let(:account) { Fabricate :account, user: nil }
it 'raises an error' do
post admin_account_confirmation_path(account_id: account.id)
expect(response)
.to have_http_status(404)
end
end
end
describe 'POST /admin/accounts/:account_id/confirmation/resend' do
subject { post resend_admin_account_confirmation_path(account_id: user.account.id) }
let(:user) { Fabricate(:user, confirmed_at: confirmed_at) }
context 'when email is confirmed' do
let(:confirmed_at) { Time.zone.now }
it 'does not resend confirmation mail' do
emails = capture_emails { subject }
expect(emails)
.to be_empty
expect(response)
.to redirect_to admin_accounts_path
follow_redirect!
expect(response.body)
.to include(I18n.t('admin.accounts.resend_confirmation.already_confirmed'))
end
end
end
end
@@ -1,102 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::ActivitySerializer do
subject { serialized_record_json(presenter, described_class, adapter: ActivityPub::Adapter) }
let(:tag_manager) { ActivityPub::TagManager.instance }
let(:status) { Fabricate(:status, created_at: Time.utc(2026, 0o1, 27, 15, 29, 31)) }
context 'with a new status' do
let(:presenter) { ActivityPub::ActivityPresenter.from_status(status) }
it 'serializes to the expected json' do
expect(subject).to include({
'id' => tag_manager.activity_uri_for(status),
'type' => 'Create',
'actor' => tag_manager.uri_for(status.account),
'published' => '2026-01-27T15:29:31Z',
'to' => ['https://www.w3.org/ns/activitystreams#Public'],
'cc' => [a_string_matching(/followers$/)],
'object' => a_hash_including(
'id' => tag_manager.uri_for(status)
),
})
expect(subject).to_not have_key('target')
end
end
context 'with a new reblog' do
let(:reblog) { Fabricate(:status, reblog: status, created_at: Time.utc(2026, 0o1, 27, 16, 21, 44)) }
let(:presenter) { ActivityPub::ActivityPresenter.from_status(reblog) }
it 'serializes to the expected json' do
expect(subject).to include({
'id' => tag_manager.activity_uri_for(reblog),
'type' => 'Announce',
'actor' => tag_manager.uri_for(reblog.account),
'published' => '2026-01-27T16:21:44Z',
'to' => ['https://www.w3.org/ns/activitystreams#Public'],
'cc' => [tag_manager.uri_for(status.account), a_string_matching(/followers$/)],
'object' => tag_manager.uri_for(status),
})
expect(subject).to_not have_key('target')
end
context 'when inlining of private local status is allowed' do
let(:status) { Fabricate(:status, visibility: :private, created_at: Time.utc(2026, 0o1, 27, 15, 29, 31)) }
let(:reblog) { Fabricate(:status, reblog: status, account: status.account, created_at: Time.utc(2026, 0o1, 27, 16, 21, 44)) }
let(:presenter) { ActivityPub::ActivityPresenter.from_status(reblog, allow_inlining: true) }
it 'serializes to the expected json' do
expect(subject).to include({
'id' => tag_manager.activity_uri_for(reblog),
'type' => 'Announce',
'actor' => tag_manager.uri_for(reblog.account),
'published' => '2026-01-27T16:21:44Z',
'to' => ['https://www.w3.org/ns/activitystreams#Public'],
'cc' => [tag_manager.uri_for(status.account), a_string_matching(/followers$/)],
'object' => a_hash_including(
'id' => tag_manager.uri_for(status)
),
})
expect(subject).to_not have_key('target')
end
end
end
context 'with a custom presenter for a status `Update`' do
let(:status) { Fabricate(:status, edited_at: Time.utc(2026, 0o1, 27, 15, 29, 31)) }
let(:presenter) do
ActivityPub::ActivityPresenter.new(
id: 'https://localhost/status/1#updates/1769527771',
type: 'Update',
actor: 'https://localhost/actor/1',
published: status.edited_at,
to: ['https://www.w3.org/ns/activitystreams#Public'],
cc: ['https://localhost/actor/1/followers'],
virtual_object: status
)
end
it 'serializes to the expected json' do
expect(subject).to include({
'id' => 'https://localhost/status/1#updates/1769527771',
'type' => 'Update',
'actor' => 'https://localhost/actor/1',
'published' => '2026-01-27T15:29:31Z',
'to' => ['https://www.w3.org/ns/activitystreams#Public'],
'cc' => ['https://localhost/actor/1/followers'],
'object' => a_hash_including(
'id' => tag_manager.uri_for(status)
),
})
expect(subject).to_not have_key('target')
end
end
end
@@ -0,0 +1,26 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::AddFeaturedCollectionSerializer do
subject { serialized_record_json(object, described_class, adapter: ActivityPub::Adapter) }
let(:tag_manager) { ActivityPub::TagManager.instance }
let(:object) { Fabricate(:collection) }
it 'serializes to the expected json' do
expect(subject).to include({
'type' => 'Add',
'actor' => tag_manager.uri_for(object.account),
'target' => a_string_matching(%r{/featured_collections$}),
'object' => a_hash_including({
'type' => 'FeaturedCollection',
}),
})
expect(subject).to_not have_key('id')
expect(subject).to_not have_key('published')
expect(subject).to_not have_key('to')
expect(subject).to_not have_key('cc')
end
end
@@ -0,0 +1,26 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::AddHashtagSerializer do
subject { serialized_record_json(object, described_class, adapter: ActivityPub::Adapter) }
let(:tag_manager) { ActivityPub::TagManager.instance }
let(:object) { Fabricate(:featured_tag) }
it 'serializes to the expected json' do
expect(subject).to include({
'type' => 'Add',
'actor' => tag_manager.uri_for(object.account),
'target' => a_string_matching(%r{/featured$}),
'object' => a_hash_including({
'type' => 'Hashtag',
}),
})
expect(subject).to_not have_key('id')
expect(subject).to_not have_key('published')
expect(subject).to_not have_key('to')
expect(subject).to_not have_key('cc')
end
end
@@ -0,0 +1,24 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::AddNoteSerializer do
subject { serialized_record_json(object, described_class, adapter: ActivityPub::Adapter) }
let(:tag_manager) { ActivityPub::TagManager.instance }
let(:object) { Fabricate(:status) }
it 'serializes to the expected json' do
expect(subject).to include({
'type' => 'Add',
'actor' => tag_manager.uri_for(object.account),
'target' => a_string_matching(%r{/featured$}),
'object' => tag_manager.uri_for(object),
})
expect(subject).to_not have_key('id')
expect(subject).to_not have_key('published')
expect(subject).to_not have_key('to')
expect(subject).to_not have_key('cc')
end
end
@@ -1,119 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::AddSerializer do
describe '.serializer_for' do
subject { described_class.serializer_for(model, {}) }
context 'with a Status model' do
let(:model) { Status.new }
it { is_expected.to eq(described_class::UriSerializer) }
end
context 'with a FeaturedTag model' do
let(:model) { FeaturedTag.new }
it { is_expected.to eq(ActivityPub::HashtagSerializer) }
end
context 'with a Collection model' do
let(:model) { Collection.new }
it { is_expected.to eq(ActivityPub::FeaturedCollectionSerializer) }
end
context 'with an Array' do
let(:model) { [] }
it { is_expected.to eq(ActiveModel::Serializer::CollectionSerializer) }
end
end
describe '#target' do
subject { described_class.new(object).target }
context 'when object is a Status' do
let(:object) { Fabricate(:status) }
it { is_expected.to match(%r{/#{object.account_id}/collections/featured$}) }
end
context 'when object is a FeaturedTag' do
let(:object) { Fabricate(:featured_tag) }
it { is_expected.to match(%r{/#{object.account_id}/collections/featured$}) }
end
context 'when object is a Collection' do
let(:object) { Fabricate(:collection) }
it { is_expected.to match(%r{/#{object.account_id}/featured_collections$}) }
end
end
describe 'Serialization' do
subject { serialized_record_json(object, described_class, adapter: ActivityPub::Adapter) }
let(:tag_manager) { ActivityPub::TagManager.instance }
context 'with a status' do
let(:object) { Fabricate(:status) }
it 'serializes to the expected json' do
expect(subject).to include({
'type' => 'Add',
'actor' => tag_manager.uri_for(object.account),
'target' => a_string_matching(%r{/featured$}),
'object' => tag_manager.uri_for(object),
})
expect(subject).to_not have_key('id')
expect(subject).to_not have_key('published')
expect(subject).to_not have_key('to')
expect(subject).to_not have_key('cc')
end
end
context 'with a featured tag' do
let(:object) { Fabricate(:featured_tag) }
it 'serializes to the expected json' do
expect(subject).to include({
'type' => 'Add',
'actor' => tag_manager.uri_for(object.account),
'target' => a_string_matching(%r{/featured$}),
'object' => a_hash_including({
'type' => 'Hashtag',
}),
})
expect(subject).to_not have_key('id')
expect(subject).to_not have_key('published')
expect(subject).to_not have_key('to')
expect(subject).to_not have_key('cc')
end
end
context 'with a collection' do
let(:object) { Fabricate(:collection) }
it 'serializes to the expected json' do
expect(subject).to include({
'type' => 'Add',
'actor' => tag_manager.uri_for(object.account),
'target' => a_string_matching(%r{/featured_collections$}),
'object' => a_hash_including({
'type' => 'FeaturedCollection',
}),
})
expect(subject).to_not have_key('id')
expect(subject).to_not have_key('published')
expect(subject).to_not have_key('to')
expect(subject).to_not have_key('cc')
end
end
end
end
@@ -0,0 +1,79 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::AnnounceNoteSerializer do
subject { serialized_record_json(reblog, described_class, adapter: ActivityPub::Adapter, options:) }
let(:tag_manager) { ActivityPub::TagManager.instance }
let(:status) { Fabricate(:status, created_at: Time.utc(2026, 1, 27, 15, 29, 31)) }
let(:reblog) { Fabricate(:status, reblog: status, created_at: Time.utc(2026, 1, 27, 16, 21, 44)) }
let(:options) { {} }
it 'serializes to the expected json' do
expect(subject).to include({
'id' => tag_manager.activity_uri_for(reblog),
'type' => 'Announce',
'actor' => tag_manager.uri_for(reblog.account),
'published' => '2026-01-27T16:21:44Z',
'to' => ['https://www.w3.org/ns/activitystreams#Public'],
'cc' => [tag_manager.uri_for(status.account), a_string_matching(/followers$/)],
'object' => tag_manager.uri_for(status),
})
expect(subject).to_not have_key('target')
end
context 'when status is local and private' do
let(:status) { Fabricate(:status, visibility: :private, created_at: Time.utc(2026, 1, 27, 15, 29, 31)) }
let(:reblog) { Fabricate(:status, reblog: status, account: status.account, created_at: Time.utc(2026, 1, 27, 16, 21, 44)) }
context 'when inlining of private local status is allowed' do
shared_examples 'serialization with inlining' do
it 'serializes to the expected json' do
expect(subject).to include({
'id' => tag_manager.activity_uri_for(reblog),
'type' => 'Announce',
'actor' => tag_manager.uri_for(reblog.account),
'published' => '2026-01-27T16:21:44Z',
'to' => ['https://www.w3.org/ns/activitystreams#Public'],
'cc' => [tag_manager.uri_for(status.account), a_string_matching(/followers$/)],
'object' => a_hash_including(
'id' => tag_manager.uri_for(status)
),
})
expect(subject).to_not have_key('target')
end
end
context 'with `allow_inlining` explicitly set to `true`' do
let(:options) { { allow_inlining: true } }
it_behaves_like 'serialization with inlining'
end
context 'with `allow_inlining` unset' do
let(:options) { {} }
it_behaves_like 'serialization with inlining'
end
end
context 'when inlining is not allowed' do
let(:options) { { allow_inlining: false } }
it 'serializes to the expected json' do
expect(subject).to include({
'id' => tag_manager.activity_uri_for(reblog),
'type' => 'Announce',
'actor' => tag_manager.uri_for(reblog.account),
'published' => '2026-01-27T16:21:44Z',
'to' => ['https://www.w3.org/ns/activitystreams#Public'],
'cc' => [tag_manager.uri_for(status.account), a_string_matching(/followers$/)],
'object' => tag_manager.uri_for(status),
})
end
end
end
end
@@ -0,0 +1,26 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::CreateNoteSerializer do
subject { serialized_record_json(status, described_class, adapter: ActivityPub::Adapter) }
let(:tag_manager) { ActivityPub::TagManager.instance }
let(:status) { Fabricate(:status, created_at: Time.utc(2026, 1, 27, 15, 29, 31)) }
it 'serializes to the expected json' do
expect(subject).to include({
'id' => tag_manager.activity_uri_for(status),
'type' => 'Create',
'actor' => tag_manager.uri_for(status.account),
'published' => '2026-01-27T15:29:31Z',
'to' => ['https://www.w3.org/ns/activitystreams#Public'],
'cc' => [a_string_matching(/followers$/)],
'object' => a_hash_including(
'id' => tag_manager.uri_for(status)
),
})
expect(subject).to_not have_key('target')
end
end
@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ActivityPub::DeleteSerializer do
RSpec.describe ActivityPub::DeleteNoteSerializer do
subject { serialized_record_json(status, described_class, adapter: ActivityPub::Adapter) }
let(:tag_manager) { ActivityPub::TagManager.instance }
@@ -0,0 +1,24 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::RemoveFeaturedCollectionSerializer do
subject { serialized_record_json(object, described_class, adapter: ActivityPub::Adapter) }
let(:tag_manager) { ActivityPub::TagManager.instance }
let(:object) { Fabricate(:collection) }
it 'serializes to the expected json' do
expect(subject).to include({
'type' => 'Remove',
'actor' => tag_manager.uri_for(object.account),
'target' => a_string_matching(%r{/featured_collections$}),
'object' => tag_manager.uri_for(object),
})
expect(subject).to_not have_key('id')
expect(subject).to_not have_key('published')
expect(subject).to_not have_key('to')
expect(subject).to_not have_key('cc')
end
end
@@ -0,0 +1,26 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::RemoveHashtagSerializer do
subject { serialized_record_json(object, described_class, adapter: ActivityPub::Adapter) }
let(:tag_manager) { ActivityPub::TagManager.instance }
let(:object) { Fabricate(:featured_tag) }
it 'serializes to the expected json' do
expect(subject).to include({
'type' => 'Remove',
'actor' => tag_manager.uri_for(object.account),
'target' => a_string_matching(%r{/featured$}),
'object' => a_hash_including({
'type' => 'Hashtag',
}),
})
expect(subject).to_not have_key('id')
expect(subject).to_not have_key('published')
expect(subject).to_not have_key('to')
expect(subject).to_not have_key('cc')
end
end
@@ -0,0 +1,24 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::RemoveNoteSerializer do
subject { serialized_record_json(object, described_class, adapter: ActivityPub::Adapter) }
let(:tag_manager) { ActivityPub::TagManager.instance }
let(:object) { Fabricate(:status) }
it 'serializes to the expected json' do
expect(subject).to include({
'type' => 'Remove',
'actor' => tag_manager.uri_for(object.account),
'target' => a_string_matching(%r{/featured$}),
'object' => tag_manager.uri_for(object),
})
expect(subject).to_not have_key('id')
expect(subject).to_not have_key('published')
expect(subject).to_not have_key('to')
expect(subject).to_not have_key('cc')
end
end
@@ -1,71 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::RemoveSerializer do
describe '.serializer_for' do
subject { described_class.serializer_for(model, {}) }
context 'with a Status model' do
let(:model) { Status.new }
it { is_expected.to eq(described_class::UriSerializer) }
end
context 'with a FeaturedTag model' do
let(:model) { FeaturedTag.new }
it { is_expected.to eq(ActivityPub::HashtagSerializer) }
end
context 'with an Array' do
let(:model) { [] }
it { is_expected.to eq(ActiveModel::Serializer::CollectionSerializer) }
end
end
describe 'Serialization' do
subject { serialized_record_json(object, described_class, adapter: ActivityPub::Adapter) }
let(:tag_manager) { ActivityPub::TagManager.instance }
context 'with a status' do
let(:object) { Fabricate(:status) }
it 'serializes to the expected json' do
expect(subject).to include({
'type' => 'Remove',
'actor' => tag_manager.uri_for(object.account),
'target' => a_string_matching(%r{/featured$}),
'object' => tag_manager.uri_for(object),
})
expect(subject).to_not have_key('id')
expect(subject).to_not have_key('published')
expect(subject).to_not have_key('to')
expect(subject).to_not have_key('cc')
end
end
context 'with a featured tag' do
let(:object) { Fabricate(:featured_tag) }
it 'serializes to the expected json' do
expect(subject).to include({
'type' => 'Remove',
'actor' => tag_manager.uri_for(object.account),
'target' => a_string_matching(%r{/featured$}),
'object' => a_hash_including({
'type' => 'Hashtag',
}),
})
expect(subject).to_not have_key('id')
expect(subject).to_not have_key('published')
expect(subject).to_not have_key('to')
expect(subject).to_not have_key('cc')
end
end
end
end
@@ -26,4 +26,17 @@ RSpec.describe ActivityPub::UndoAnnounceSerializer do
expect(subject).to_not have_key('cc')
expect(subject).to_not have_key('target')
end
context 'when status is local and private' do
let(:status) { Fabricate(:status, visibility: :private) }
let(:reblog) { Fabricate(:status, reblog: status, account: status.account) }
it 'does not inline the status' do
expect(subject).to include({
'object' => a_hash_including({
'object' => tag_manager.uri_for(status),
}),
})
end
end
end
@@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ActivityPub::UpdateSerializer do
RSpec.describe ActivityPub::UpdateActorSerializer do
subject { serialized_record_json(account, described_class, adapter: ActivityPub::Adapter) }
let(:tag_manager) { ActivityPub::TagManager.instance }
@@ -0,0 +1,26 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::UpdateNoteSerializer do
subject { serialized_record_json(status, described_class, adapter: ActivityPub::Adapter) }
let(:tag_manager) { ActivityPub::TagManager.instance }
let(:status) { Fabricate(:status, edited_at: Time.utc(2026, 1, 27, 15, 29, 31)) }
it 'serializes to the expected json' do
expect(subject).to include({
'id' => "#{tag_manager.uri_for(status)}#updates/1769527771",
'type' => 'Update',
'actor' => tag_manager.uri_for(status.account),
'published' => '2026-01-27T15:29:31Z',
'to' => ['https://www.w3.org/ns/activitystreams#Public'],
'cc' => [a_string_matching(%r{/followers$})],
'object' => a_hash_including(
'id' => tag_manager.uri_for(status)
),
})
expect(subject).to_not have_key('target')
end
end
@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe DeleteCollectionService do
subject { described_class.new }
let!(:collection) { Fabricate(:collection) }
describe '#call' do
it 'destroys the collection' do
expect { subject.call(collection) }.to change(Collection, :count).by(-1)
end
it 'federates a `Remove` activity', feature: :collections_federation do
subject.call(collection)
expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job
end
end
end
+54
View File
@@ -0,0 +1,54 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin Confirmations' do
before { sign_in Fabricate(:admin_user) }
describe 'Confirming a user' do
let!(:user) { Fabricate :user, confirmed_at: nil }
it 'changes user to confirmed and returns to accounts page' do
# Go to accounts listing page
visit admin_accounts_path
expect(page)
.to have_title(I18n.t('admin.accounts.title'))
# Go to account page
click_on user.account.username
# Click to confirm
expect { click_on I18n.t('admin.accounts.confirm') }
.to change(Admin::ActionLog.where(action: 'confirm'), :count).by(1)
expect(page)
.to have_title(I18n.t('admin.accounts.title'))
expect(user.reload)
.to be_confirmed
end
end
describe 'Resending a confirmation email', :inline_jobs do
let!(:user) { Fabricate(:user, confirmed_at: confirmed_at) }
context 'when email is not confirmed' do
let(:confirmed_at) { nil }
it 'resends the confirmation mail' do
visit admin_account_path(id: user.account.id)
emails = capture_emails { resend_confirmation }
expect(page)
.to have_title(I18n.t('admin.accounts.title'))
.and have_content(I18n.t('admin.accounts.resend_confirmation.success'))
expect(emails.first)
.to be_present
.and deliver_to(user.email)
end
end
def resend_confirmation
click_on I18n.t('admin.accounts.resend_confirmation.send')
end
end
end
+3 -3
View File
@@ -25,7 +25,7 @@ RSpec.describe 'Log in' do
it 'A invalid email and password user is not able to log in' do
fill_in_auth_details('invalid_email', 'invalid_password')
expect(subject).to have_css('.flash-message', text: failure_message('invalid'))
expect(subject).to have_css('.flash-message', text: /#{failure_message_invalid}/i)
end
context 'when confirmed at is nil' do
@@ -38,8 +38,8 @@ RSpec.describe 'Log in' do
end
end
def failure_message(message)
def failure_message_invalid
keys = User.authentication_keys.map { |key| User.human_attribute_name(key) }
I18n.t("devise.failure.#{message}", authentication_keys: keys.join('support.array.words_connector'))
I18n.t('devise.failure.invalid', authentication_keys: keys.join('support.array.words_connector'))
end
end
@@ -51,5 +51,46 @@ RSpec.describe ActivityPub::DistributionWorker do
end
end
end
context 'with a reblog' do
before do
follower.follow!(reblog.account)
end
context 'when the reblogged status is not private' do
let(:status) { Fabricate(:status) }
let(:reblog) { Fabricate(:status, reblog: status) }
it 'delivers an activity without inlining the status' do
expected_json = {
type: 'Announce',
object: ActivityPub::TagManager.instance.uri_for(status),
}
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(expected_json), reblog.account.id, 'http://example.com', anything]]) do
subject.perform(reblog.id)
end
end
end
context 'when the reblogged status is private' do
let(:status) { Fabricate(:status, visibility: :private) }
let(:reblog) { Fabricate(:status, reblog: status, account: status.account) }
it 'delivers an activity that inlines the status' do
expected_json = {
type: 'Announce',
object: a_hash_including({
id: ActivityPub::TagManager.instance.uri_for(status),
type: 'Note',
}),
}
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(expected_json), reblog.account.id, 'http://example.com', anything]]) do
subject.perform(reblog.id)
end
end
end
end
end
end