Merge remote-tracking branch 'parent/main' into upstream-20240310
This commit is contained in:
commit
5979c0ea1d
345 changed files with 4304 additions and 2540 deletions
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::RelationshipsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
it 'returns http success' do
|
||||
get :index, params: { account_id: account.id }
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::SiteUploadsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
let(:site_upload) { Fabricate(:site_upload, var: 'thumbnail') }
|
||||
|
||||
it 'returns http success' do
|
||||
delete :destroy, params: { id: site_upload.id }
|
||||
|
||||
expect(response).to redirect_to(admin_settings_path)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::TermsOfService::DistributionsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
let(:terms_of_service) { Fabricate(:terms_of_service, notification_sent_at: nil) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
it 'returns http success' do
|
||||
post :create, params: { terms_of_service_id: terms_of_service.id }
|
||||
|
||||
expect(response).to redirect_to(admin_terms_of_service_index_path)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,66 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::TermsOfService::DraftsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
subject { put :update, params: params }
|
||||
|
||||
let!(:terms) { Fabricate :terms_of_service, published_at: nil }
|
||||
|
||||
context 'with publishing params' do
|
||||
let(:params) { { terms_of_service: { text: 'new' }, action_type: 'publish' } }
|
||||
|
||||
it 'publishes the record' do
|
||||
expect { subject }
|
||||
.to change(Admin::ActionLog, :count).by(1)
|
||||
|
||||
expect(response)
|
||||
.to redirect_to(admin_terms_of_service_index_path)
|
||||
expect(terms.reload.published_at)
|
||||
.to_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'with non publishing params' do
|
||||
let(:params) { { terms_of_service: { text: 'new' }, action_type: 'save_draft' } }
|
||||
|
||||
it 'updates but does not publish the record' do
|
||||
expect { subject }
|
||||
.to_not change(Admin::ActionLog, :count)
|
||||
|
||||
expect(response)
|
||||
.to redirect_to(admin_terms_of_service_draft_path)
|
||||
expect(terms.reload.published_at)
|
||||
.to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
let(:params) { { terms_of_service: { text: '' }, action_type: 'save_draft' } }
|
||||
|
||||
it 'does not update the record' do
|
||||
subject
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,66 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::TermsOfService::GeneratesController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
subject { post :create, params: params }
|
||||
|
||||
context 'with valid params' do
|
||||
let(:params) do
|
||||
{
|
||||
terms_of_service_generator: {
|
||||
admin_email: 'test@host.example',
|
||||
arbitration_address: '123 Main Street',
|
||||
arbitration_website: 'https://host.example',
|
||||
dmca_address: '123 DMCA Ave',
|
||||
dmca_email: 'dmca@host.example',
|
||||
domain: 'host.example',
|
||||
jurisdiction: 'Europe',
|
||||
choice_of_law: 'New York',
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
it 'saves new record' do
|
||||
expect { subject }
|
||||
.to change(TermsOfService, :count).by(1)
|
||||
expect(response)
|
||||
.to redirect_to(admin_terms_of_service_draft_path)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
let(:params) do
|
||||
{
|
||||
terms_of_service_generator: {
|
||||
admin_email: 'what the',
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
it 'does not save new record' do
|
||||
expect { subject }
|
||||
.to_not change(TermsOfService, :count)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::TermsOfService::PreviewsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
let(:terms_of_service) { Fabricate(:terms_of_service, notification_sent_at: nil) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show, params: { terms_of_service_id: terms_of_service.id }
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::TermsOfService::TestsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
let(:terms_of_service) { Fabricate(:terms_of_service, notification_sent_at: nil) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
it 'returns http success' do
|
||||
post :create, params: { terms_of_service_id: terms_of_service.id }
|
||||
|
||||
expect(response).to redirect_to(admin_terms_of_service_preview_path(terms_of_service))
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::TermsOfServiceController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'returns http success' do
|
||||
get :index
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::Trends::Links::PreviewCardProvidersController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'returns http success' do
|
||||
get :index
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::Trends::LinksController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'returns http success' do
|
||||
get :index
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::Trends::StatusesController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'returns http success' do
|
||||
get :index
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::Trends::TagsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'returns http success' do
|
||||
get :index
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::Webhooks::SecretsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'POST #rotate' do
|
||||
let(:webhook) { Fabricate(:webhook) }
|
||||
|
||||
it 'returns http success' do
|
||||
post :rotate, params: { webhook_id: webhook.id }
|
||||
|
||||
expect(response).to redirect_to(admin_webhook_path(webhook))
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Settings::SessionsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:session_activation) { Fabricate(:session_activation, user: user) }
|
||||
|
||||
before { sign_in user, scope: :user }
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
subject { delete :destroy, params: { id: id } }
|
||||
|
||||
context 'when session activation exists' do
|
||||
let(:id) { session_activation.id }
|
||||
|
||||
it 'destroys session activation' do
|
||||
expect(subject).to redirect_to edit_user_registration_path
|
||||
expect(SessionActivation.find_by(id: id)).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when session activation does not exist' do
|
||||
let(:id) { session_activation.id + 1000 }
|
||||
|
||||
it 'destroys session activation' do
|
||||
expect(subject).to have_http_status 404
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -5,4 +5,5 @@ Fabricator(:terms_of_service) do
|
|||
changelog { Faker::Lorem.paragraph }
|
||||
published_at { Time.zone.now }
|
||||
notification_sent_at { Time.zone.now }
|
||||
effective_date { Faker::Date.unique.forward }
|
||||
end
|
||||
|
|
30
spec/lib/mastodon/feature_spec.rb
Normal file
30
spec/lib/mastodon/feature_spec.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Mastodon::Feature do
|
||||
around do |example|
|
||||
original_value = Rails.configuration.x.mastodon.experimental_features
|
||||
Rails.configuration.x.mastodon.experimental_features = 'fasp,fetch_all_replies'
|
||||
example.run
|
||||
Rails.configuration.x.mastodon.experimental_features = original_value
|
||||
end
|
||||
|
||||
describe '::fasp_enabled?' do
|
||||
subject { described_class.fasp_enabled? }
|
||||
|
||||
it { is_expected.to be true }
|
||||
end
|
||||
|
||||
describe '::fetch_all_replies_enabled?' do
|
||||
subject { described_class.fetch_all_replies_enabled? }
|
||||
|
||||
it { is_expected.to be true }
|
||||
end
|
||||
|
||||
describe '::unspecified_feature_enabled?' do
|
||||
subject { described_class.unspecified_feature_enabled? }
|
||||
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
end
|
|
@ -317,4 +317,16 @@ RSpec.describe UserMailer do
|
|||
.and(have_body_text(I18n.t('user_mailer.terms_of_service_changed.changelog')))
|
||||
end
|
||||
end
|
||||
|
||||
describe '#announcement_published' do
|
||||
let(:announcement) { Fabricate :announcement }
|
||||
let(:mail) { described_class.announcement_published(receiver, announcement) }
|
||||
|
||||
it 'renders announcement_published mail' do
|
||||
expect(mail)
|
||||
.to be_present
|
||||
.and(have_subject(I18n.t('user_mailer.announcement_published.subject')))
|
||||
.and(have_body_text(I18n.t('user_mailer.announcement_published.description', domain: Rails.configuration.x.local_domain)))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -193,4 +193,57 @@ RSpec.describe 'Media' do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE /api/v1/media/:id' do
|
||||
subject do
|
||||
delete "/api/v1/media/#{media.id}", headers: headers
|
||||
end
|
||||
|
||||
context 'when media is not attached to a status' do
|
||||
let(:media) { Fabricate(:media_attachment, account: user.account, status: nil) }
|
||||
|
||||
it 'returns http empty response' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(MediaAttachment.where(id: media.id)).to_not exist
|
||||
end
|
||||
end
|
||||
|
||||
context 'when media is attached to a status' do
|
||||
let(:media) { Fabricate(:media_attachment, account: user.account, status: Fabricate.build(:status)) }
|
||||
|
||||
it 'returns http unprocessable entity' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match(
|
||||
a_hash_including(
|
||||
error: 'Media attachment is currently used by a status'
|
||||
)
|
||||
)
|
||||
|
||||
expect(MediaAttachment.where(id: media.id)).to exist
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the media belongs to somebody else' do
|
||||
let(:media) { Fabricate(:media_attachment, status: nil) }
|
||||
|
||||
it 'returns http not found' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(MediaAttachment.where(id: media.id)).to exist
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -346,13 +346,30 @@ RSpec.describe '/api/v1/statuses' do
|
|||
|
||||
it_behaves_like 'forbidden for wrong scope', 'read read:statuses'
|
||||
|
||||
it 'removes the status', :aggregate_failures do
|
||||
it 'discards the status and schedules removal as a redraft', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(Status.find_by(id: status.id)).to be_nil
|
||||
expect(RemovalWorker).to have_enqueued_sidekiq_job(status.id, { 'redraft' => true })
|
||||
end
|
||||
|
||||
context 'when called with truthy delete_media' do
|
||||
subject do
|
||||
delete "/api/v1/statuses/#{status.id}?delete_media=true", headers: headers
|
||||
end
|
||||
|
||||
it 'discards the status and schedules removal without the redraft flag', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(Status.find_by(id: status.id)).to be_nil
|
||||
expect(RemovalWorker).to have_enqueued_sidekiq_job(status.id, { 'redraft' => false })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
20
spec/requests/settings/sessions_spec.rb
Normal file
20
spec/requests/settings/sessions_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Settings Sessions' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'DELETE /settings/sessions/:id' do
|
||||
context 'when session activation does not exist' do
|
||||
it 'returns not found' do
|
||||
delete settings_session_path(123_456_789)
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
66
spec/requests/status_show_page_spec.rb
Normal file
66
spec/requests/status_show_page_spec.rb
Normal file
|
@ -0,0 +1,66 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Statuses' do
|
||||
describe 'GET /@:account_username/:id' do
|
||||
include AccountsHelper
|
||||
|
||||
def site_hostname
|
||||
Rails.configuration.x.web_domain || Rails.configuration.x.local_domain
|
||||
end
|
||||
|
||||
it 'has valid opengraph tags' do
|
||||
account = Fabricate(:account, username: 'alice', display_name: 'Alice')
|
||||
status = Fabricate(:status, account: account, text: 'Hello World')
|
||||
|
||||
get "/@#{account.username}/#{status.id}"
|
||||
|
||||
expect(head_link_icons.size).to eq(3) # Three favicons with sizes
|
||||
|
||||
expect(head_meta_content('og:title')).to match "#{display_name(account)} (#{acct(account)})"
|
||||
expect(head_meta_content('og:type')).to eq 'article'
|
||||
expect(head_meta_content('og:published_time')).to eq status.created_at.iso8601
|
||||
expect(head_meta_content('og:url')).to eq short_account_status_url(account_username: account.username, id: status.id)
|
||||
expect(head_meta_exists('og:locale')).to be false
|
||||
end
|
||||
|
||||
it 'has og:locale opengraph tag if the status has is written in a given language' do
|
||||
status_text = "Una prova d'estatus català"
|
||||
account = Fabricate(:account, username: 'alice', display_name: 'Alice')
|
||||
status = Fabricate(:status, account: account, text: status_text, language: 'ca')
|
||||
|
||||
get "/@#{account.username}/#{status.id}"
|
||||
|
||||
expect(head_meta_content('og:title')).to match "#{display_name(account)} (#{acct(account)})"
|
||||
expect(head_meta_content('og:type')).to eq 'article'
|
||||
expect(head_meta_content('og:published_time')).to eq status.created_at.iso8601
|
||||
expect(head_meta_content('og:url')).to eq short_account_status_url(account_username: account.username, id: status.id)
|
||||
|
||||
expect(head_meta_exists('og:locale')).to be true
|
||||
expect(head_meta_content('og:locale')).to eq 'ca'
|
||||
expect(head_meta_content('og:description')).to eq status_text
|
||||
end
|
||||
|
||||
def head_link_icons
|
||||
response
|
||||
.parsed_body
|
||||
.search('html head link[rel=icon]')
|
||||
end
|
||||
|
||||
def head_meta_content(property)
|
||||
response
|
||||
.parsed_body
|
||||
.search("html head meta[property='#{property}']")
|
||||
.attr('content')
|
||||
.text
|
||||
end
|
||||
|
||||
def head_meta_exists(property)
|
||||
!response
|
||||
.parsed_body
|
||||
.search("html head meta[property='#{property}']")
|
||||
.empty?
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,10 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module SystemHelpers
|
||||
def admin_user
|
||||
Fabricate(:admin_user)
|
||||
end
|
||||
|
||||
def submit_button
|
||||
I18n.t('generic.save_changes')
|
||||
end
|
||||
|
|
28
spec/system/admin/announcements/distributions_spec.rb
Normal file
28
spec/system/admin/announcements/distributions_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Announcement Mail Distributions' do
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
let(:announcement) { Fabricate(:announcement, notification_sent_at: nil) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'Sending an announcement notification', :inline_jobs do
|
||||
it 'marks the announcement as notified and sends the email' do
|
||||
visit admin_announcement_preview_path(announcement)
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.announcements.preview.title'))
|
||||
|
||||
emails = capture_emails do
|
||||
expect { click_on I18n.t('admin.terms_of_service.preview.send_to_all', count: 1, display_count: 1) }
|
||||
.to(change { announcement.reload.notification_sent_at })
|
||||
end
|
||||
expect(emails.first)
|
||||
.to be_present
|
||||
.and(deliver_to(user.email))
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.announcements.title'))
|
||||
end
|
||||
end
|
||||
end
|
19
spec/system/admin/announcements/previews_spec.rb
Normal file
19
spec/system/admin/announcements/previews_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Announcements Mail Previews' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
let(:announcement) { Fabricate(:announcement, notification_sent_at: nil) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
describe 'Viewing Announcements Mail previews' do
|
||||
it 'shows the Announcement Mail preview page' do
|
||||
visit admin_announcement_preview_path(announcement)
|
||||
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.announcements.preview.title'))
|
||||
end
|
||||
end
|
||||
end
|
25
spec/system/admin/announcements/tests_spec.rb
Normal file
25
spec/system/admin/announcements/tests_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin TermsOfService Tests' do
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
let(:announcement) { Fabricate(:announcement, notification_sent_at: nil) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'Sending test Announcement email', :inline_jobs do
|
||||
it 'generates the test email' do
|
||||
visit admin_announcement_preview_path(announcement)
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.announcements.preview.title'))
|
||||
|
||||
emails = capture_emails { click_on I18n.t('admin.terms_of_service.preview.send_preview', email: user.email) }
|
||||
expect(emails.first)
|
||||
.to be_present
|
||||
.and(deliver_to(user.email))
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.announcements.title'))
|
||||
end
|
||||
end
|
||||
end
|
|
@ -117,7 +117,7 @@ RSpec.describe 'Admin::Announcements' do
|
|||
end
|
||||
|
||||
def text_label
|
||||
I18n.t('simple_form.labels.announcement.text')
|
||||
form_label('announcement.text')
|
||||
end
|
||||
|
||||
def admin_user
|
||||
|
|
|
@ -57,7 +57,7 @@ RSpec.describe 'Admin Invites' do
|
|||
end
|
||||
|
||||
def max_use_field
|
||||
I18n.t('simple_form.labels.defaults.max_uses')
|
||||
form_label('defaults.max_uses')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
20
spec/system/admin/relationships_spec.rb
Normal file
20
spec/system/admin/relationships_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Relationships' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
describe 'Viewing account relationships page' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
it 'shows page with relationships for account' do
|
||||
visit admin_account_relationships_path(account.id)
|
||||
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.relationships.title', acct: account.pretty_acct))
|
||||
end
|
||||
end
|
||||
end
|
|
@ -65,7 +65,7 @@ RSpec.describe 'Admin Rules' do
|
|||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('generic.save_changes')
|
||||
click_on(submit_button)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,9 +3,14 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Settings::About' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
it 'Saves changes to about settings' do
|
||||
sign_in admin_user
|
||||
visit admin_settings_about_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.settings.about.title'))
|
||||
|
||||
fill_in extended_description_field,
|
||||
with: 'new site description'
|
||||
|
|
|
@ -3,9 +3,14 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Settings::Appearance' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
it 'Saves changes to appearance settings' do
|
||||
sign_in admin_user
|
||||
visit admin_settings_appearance_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.settings.appearance.title'))
|
||||
|
||||
fill_in custom_css_field,
|
||||
with: 'html { display: inline; }'
|
||||
|
|
|
@ -3,9 +3,14 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Settings::Branding' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
it 'Saves changes to branding settings' do
|
||||
sign_in admin_user
|
||||
visit admin_settings_branding_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.settings.branding.title'))
|
||||
|
||||
fill_in short_description_field,
|
||||
with: 'new key value'
|
||||
|
|
|
@ -3,9 +3,14 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Settings::ContentRetention' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
it 'Saves changes to content retention settings' do
|
||||
sign_in admin_user
|
||||
visit admin_settings_content_retention_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.settings.content_retention.title'))
|
||||
|
||||
fill_in media_cache_retention_period_field,
|
||||
with: '2'
|
||||
|
|
|
@ -3,9 +3,14 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Settings::Discovery' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
it 'Saves changes to discovery settings' do
|
||||
sign_in admin_user
|
||||
visit admin_settings_discovery_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.settings.discovery.title'))
|
||||
|
||||
check trends_box
|
||||
|
||||
|
|
|
@ -3,9 +3,14 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Settings::Registrations' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
it 'Saves changes to registrations settings' do
|
||||
sign_in admin_user
|
||||
visit admin_settings_registrations_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.settings.registrations.title'))
|
||||
|
||||
select open_mode_option,
|
||||
from: registrations_mode_field
|
||||
|
|
27
spec/system/admin/site_uploads_spec.rb
Normal file
27
spec/system/admin/site_uploads_spec.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin SiteUploads' do
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'Removing a site upload' do
|
||||
let!(:site_upload) { Fabricate(:site_upload, var: 'thumbnail') }
|
||||
|
||||
it 'removes the upload and redirects' do
|
||||
visit admin_settings_branding_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.settings.branding.title'))
|
||||
|
||||
expect { click_on I18n.t('admin.site_uploads.delete') }
|
||||
.to change(SiteUpload, :count).by(-1)
|
||||
expect { site_upload.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(page)
|
||||
.to have_content(I18n.t('admin.site_uploads.destroyed_msg'))
|
||||
.and have_title(I18n.t('admin.settings.branding.title'))
|
||||
end
|
||||
end
|
||||
end
|
|
@ -28,7 +28,7 @@ RSpec.describe 'Admin Tags' do
|
|||
end
|
||||
|
||||
def display_name_field
|
||||
I18n.t('simple_form.labels.defaults.display_name')
|
||||
form_label('defaults.display_name')
|
||||
end
|
||||
|
||||
def match_error_text
|
||||
|
|
28
spec/system/admin/terms_of_service/distributions_spec.rb
Normal file
28
spec/system/admin/terms_of_service/distributions_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin TermsOfService Distributions' do
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
let(:terms_of_service) { Fabricate(:terms_of_service, notification_sent_at: nil) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'Sending a TOS change notification', :inline_jobs do
|
||||
it 'marks the TOS as notified and sends the email' do
|
||||
visit admin_terms_of_service_preview_path(terms_of_service)
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.terms_of_service.preview.title'))
|
||||
|
||||
emails = capture_emails do
|
||||
expect { click_on I18n.t('admin.terms_of_service.preview.send_to_all', count: 1, display_count: 1) }
|
||||
.to(change { terms_of_service.reload.notification_sent_at })
|
||||
end
|
||||
expect(emails.first)
|
||||
.to be_present
|
||||
.and(deliver_to(user.email))
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.terms_of_service.title'))
|
||||
end
|
||||
end
|
||||
end
|
41
spec/system/admin/terms_of_service/drafts_spec.rb
Normal file
41
spec/system/admin/terms_of_service/drafts_spec.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin TermsOfService Drafts' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
describe 'Managing TOS drafts' do
|
||||
let!(:terms) { Fabricate :terms_of_service, published_at: nil }
|
||||
|
||||
it 'saves and publishes TOS drafts' do
|
||||
visit admin_terms_of_service_draft_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.terms_of_service.title'))
|
||||
|
||||
# Invalid submission
|
||||
expect { click_on I18n.t('admin.terms_of_service.save_draft') }
|
||||
.to_not(change { terms.reload.published_at })
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.terms_of_service.title'))
|
||||
|
||||
# Valid submission with draft button
|
||||
fill_in 'terms_of_service_text', with: 'new'
|
||||
expect { click_on I18n.t('admin.terms_of_service.save_draft') }
|
||||
.to not_change { terms.reload.published_at }.from(nil)
|
||||
.and not_change(Admin::ActionLog, :count)
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.terms_of_service.title'))
|
||||
|
||||
# Valid with publish button
|
||||
fill_in 'terms_of_service_text', with: 'newer'
|
||||
expect { click_on I18n.t('admin.terms_of_service.publish') }
|
||||
.to change { terms.reload.published_at }.from(nil)
|
||||
.and change(Admin::ActionLog, :count)
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.terms_of_service.title'))
|
||||
end
|
||||
end
|
||||
end
|
44
spec/system/admin/terms_of_service/generates_spec.rb
Normal file
44
spec/system/admin/terms_of_service/generates_spec.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin TermsOfService Generates' do
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
describe 'Generating a TOS policy' do
|
||||
it 'saves a new TOS from values' do
|
||||
visit admin_terms_of_service_generate_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.terms_of_service.generates.title'))
|
||||
|
||||
# Invalid form submission
|
||||
fill_in 'terms_of_service_generator_admin_email', with: 'what the'
|
||||
expect { submit_form }
|
||||
.to_not change(TermsOfService, :count)
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.terms_of_service.generates.title'))
|
||||
|
||||
# Valid submission
|
||||
fill_in 'terms_of_service_generator_admin_email', with: 'test@host.example'
|
||||
fill_in 'terms_of_service_generator_arbitration_address', with: '123 Main Street'
|
||||
fill_in 'terms_of_service_generator_arbitration_website', with: 'https://host.example'
|
||||
fill_in 'terms_of_service_generator_dmca_address', with: '123 DMCA Ave'
|
||||
fill_in 'terms_of_service_generator_dmca_email', with: 'dmca@host.example'
|
||||
fill_in 'terms_of_service_generator_domain', with: 'host.example'
|
||||
fill_in 'terms_of_service_generator_jurisdiction', with: 'Europe'
|
||||
fill_in 'terms_of_service_generator_choice_of_law', with: 'New York'
|
||||
fill_in 'terms_of_service_generator_min_age', with: '16'
|
||||
|
||||
expect { submit_form }
|
||||
.to change(TermsOfService, :count).by(1)
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.terms_of_service.title'))
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('admin.terms_of_service.generates.action')
|
||||
end
|
||||
end
|
||||
end
|
19
spec/system/admin/terms_of_service/previews_spec.rb
Normal file
19
spec/system/admin/terms_of_service/previews_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin TermsOfService Previews' do
|
||||
let(:terms_of_service) { Fabricate(:terms_of_service, notification_sent_at: nil) }
|
||||
let(:admin_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(admin_user) }
|
||||
|
||||
describe 'Viewing TOS previews' do
|
||||
it 'shows the TOS preview page' do
|
||||
visit admin_terms_of_service_preview_path(terms_of_service)
|
||||
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.terms_of_service.preview.title'))
|
||||
end
|
||||
end
|
||||
end
|
25
spec/system/admin/terms_of_service/tests_spec.rb
Normal file
25
spec/system/admin/terms_of_service/tests_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin TermsOfService Tests' do
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
let(:terms_of_service) { Fabricate(:terms_of_service, notification_sent_at: nil) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'Sending test TOS email', :inline_jobs do
|
||||
it 'generates the test email' do
|
||||
visit admin_terms_of_service_preview_path(terms_of_service)
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.terms_of_service.preview.title'))
|
||||
|
||||
emails = capture_emails { click_on I18n.t('admin.terms_of_service.preview.send_preview', email: user.email) }
|
||||
expect(emails.first)
|
||||
.to be_present
|
||||
.and(deliver_to(user.email))
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.terms_of_service.preview.title'))
|
||||
end
|
||||
end
|
||||
end
|
|
@ -11,6 +11,8 @@ RSpec.describe 'Admin::Trends::Links::PreviewCardProviders' do
|
|||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
visit admin_trends_links_preview_card_providers_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.trends.preview_card_providers.title'))
|
||||
|
||||
click_on button_for_allow
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ RSpec.describe 'Admin::Trends::Links' do
|
|||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
visit admin_trends_links_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.trends.links.title'))
|
||||
|
||||
click_on button_for_allow
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ RSpec.describe 'Admin::Trends::Statuses' do
|
|||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
visit admin_trends_statuses_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.trends.statuses.title'))
|
||||
|
||||
click_on button_for_allow
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ RSpec.describe 'Admin::Trends::Tags' do
|
|||
context 'without selecting any records' do
|
||||
it 'displays a notice about selection' do
|
||||
visit admin_trends_tags_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.trends.tags.title'))
|
||||
|
||||
click_on button_for_allow
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ RSpec.describe 'Admin Warning Presets' do
|
|||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('generic.save_changes')
|
||||
click_on(submit_button)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -81,7 +81,20 @@ RSpec.describe 'Admin Webhooks' do
|
|||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('generic.save_changes')
|
||||
click_on(submit_button)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Rotate a webhook secret' do
|
||||
let!(:webhook) { Fabricate :webhook, events: [Webhook::EVENTS.first] }
|
||||
|
||||
it 'rotates secret and returns to page' do
|
||||
visit admin_webhook_path(webhook)
|
||||
|
||||
expect { click_on I18n.t('admin.webhooks.rotate_secret') }
|
||||
.to(change { webhook.reload.secret })
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.webhooks.title'))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -108,6 +108,6 @@ RSpec.describe 'Filters' do
|
|||
end
|
||||
|
||||
def filter_title_field
|
||||
I18n.t('simple_form.labels.defaults.title')
|
||||
form_label('defaults.title')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,9 +74,9 @@ RSpec.describe 'Invites' do
|
|||
|
||||
def fill_invite_form
|
||||
select I18n.t('invites.max_uses', count: 100),
|
||||
from: I18n.t('simple_form.labels.defaults.max_uses')
|
||||
from: form_label('defaults.max_uses')
|
||||
select I18n.t("invites.expires_in.#{30.minutes.to_i}"),
|
||||
from: I18n.t('simple_form.labels.defaults.expires_in')
|
||||
check I18n.t('simple_form.labels.defaults.autofollow')
|
||||
from: form_label('defaults.expires_in')
|
||||
check form_label('defaults.autofollow')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -96,7 +96,7 @@ RSpec.describe 'Settings applications page' do
|
|||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('generic.save_changes')
|
||||
click_on(submit_button)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -33,18 +33,18 @@ RSpec.describe 'Settings preferences appearance page' do
|
|||
end
|
||||
|
||||
def confirm_delete_field
|
||||
I18n.t('simple_form.labels.defaults.setting_delete_modal')
|
||||
form_label('defaults.setting_delete_modal')
|
||||
end
|
||||
|
||||
def confirm_reblog_field
|
||||
I18n.t('simple_form.labels.defaults.setting_boost_modal')
|
||||
form_label('defaults.setting_boost_modal')
|
||||
end
|
||||
|
||||
def theme_selection_field
|
||||
I18n.t('simple_form.labels.defaults.setting_theme')
|
||||
form_label('defaults.setting_theme')
|
||||
end
|
||||
|
||||
def advanced_layout_field
|
||||
I18n.t('simple_form.labels.defaults.setting_advanced_layout')
|
||||
form_label('defaults.setting_advanced_layout')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,6 +22,6 @@ RSpec.describe 'Settings preferences notifications page' do
|
|||
end
|
||||
|
||||
def notifications_follow_field
|
||||
I18n.t('simple_form.labels.notification_emails.follow')
|
||||
form_label('notification_emails.follow')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ RSpec.describe 'Settings preferences other page' do
|
|||
end
|
||||
|
||||
def mark_sensitive_field
|
||||
I18n.t('simple_form.labels.defaults.setting_default_sensitive')
|
||||
form_label('defaults.setting_default_sensitive')
|
||||
end
|
||||
|
||||
def language_field(key)
|
||||
|
|
|
@ -27,7 +27,7 @@ RSpec.describe 'Settings Privacy' do
|
|||
.to change { user.account.reload.discoverable }.to(true)
|
||||
expect(page)
|
||||
.to have_content(I18n.t('privacy.title'))
|
||||
.and have_content(I18n.t('generic.changes_saved_msg'))
|
||||
.and have_content(success_message)
|
||||
expect(ActivityPub::UpdateDistributionWorker)
|
||||
.to have_received(:perform_async).with(user.account.id)
|
||||
end
|
||||
|
|
|
@ -28,10 +28,10 @@ RSpec.describe 'Settings profile page' do
|
|||
end
|
||||
|
||||
def display_name_field
|
||||
I18n.t('simple_form.labels.defaults.display_name')
|
||||
form_label('defaults.display_name')
|
||||
end
|
||||
|
||||
def avatar_field
|
||||
I18n.t('simple_form.labels.defaults.avatar')
|
||||
form_label('defaults.avatar')
|
||||
end
|
||||
end
|
||||
|
|
25
spec/system/settings/sessions_spec.rb
Normal file
25
spec/system/settings/sessions_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Settings Sessions' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let!(:session_activation) { Fabricate(:session_activation, user: user) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'deleting a session' do
|
||||
it 'deletes listed session activation from the auth page' do
|
||||
visit edit_user_registration_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('settings.account_settings'))
|
||||
|
||||
expect { click_on(I18n.t('sessions.revoke')) }
|
||||
.to change(SessionActivation, :count).by(-1)
|
||||
expect { session_activation.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(page)
|
||||
.to have_content(I18n.t('sessions.revoke_success'))
|
||||
end
|
||||
end
|
||||
end
|
|
@ -44,6 +44,6 @@ RSpec.describe 'Settings verification page' do
|
|||
end
|
||||
|
||||
def attribution_field
|
||||
I18n.t('simple_form.labels.account.attribution_domains')
|
||||
form_label('account.attribution_domains')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,6 +30,22 @@ RSpec.describe NoteLengthValidator do
|
|||
expect(account.errors).to have_received(:add)
|
||||
end
|
||||
|
||||
it 'counts multi byte emoji as single character' do
|
||||
text = '✨' * 500
|
||||
account = instance_double(Account, note: text, errors: activemodel_errors)
|
||||
|
||||
subject.validate_each(account, 'note', text)
|
||||
expect(account.errors).to_not have_received(:add)
|
||||
end
|
||||
|
||||
it 'counts ZWJ sequence emoji as single character' do
|
||||
text = '🏳️⚧️' * 500
|
||||
account = instance_double(Account, note: text, errors: activemodel_errors)
|
||||
|
||||
subject.validate_each(account, 'note', text)
|
||||
expect(account.errors).to_not have_received(:add)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def starting_string
|
||||
|
|
|
@ -41,5 +41,31 @@ RSpec.describe PollOptionsValidator do
|
|||
expect(errors).to have_received(:add)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'character length of poll options' do
|
||||
context 'when poll has acceptable length options' do
|
||||
let(:options) { %w(test this) }
|
||||
|
||||
it 'has no errors' do
|
||||
expect(errors).to_not have_received(:add)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when poll has multibyte and ZWJ emoji options' do
|
||||
let(:options) { ['✨' * described_class::MAX_OPTION_CHARS, '🏳️⚧️' * described_class::MAX_OPTION_CHARS] }
|
||||
|
||||
it 'has no errors' do
|
||||
expect(errors).to_not have_received(:add)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when poll has options that are too long' do
|
||||
let(:options) { ['ok', 'a' * (described_class::MAX_OPTION_CHARS**2)] }
|
||||
|
||||
it 'has errors' do
|
||||
expect(errors).to have_received(:add)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -80,6 +80,22 @@ RSpec.describe StatusLengthValidator do
|
|||
subject.validate(status)
|
||||
expect(status.errors).to have_received(:add)
|
||||
end
|
||||
|
||||
it 'counts multi byte emoji as single character' do
|
||||
text = '✨' * 500
|
||||
status = status_double(text: text)
|
||||
|
||||
subject.validate(status)
|
||||
expect(status.errors).to_not have_received(:add)
|
||||
end
|
||||
|
||||
it 'counts ZWJ sequence emoji as single character' do
|
||||
text = '🏳️⚧️' * 500
|
||||
status = status_double(text: text)
|
||||
|
||||
subject.validate(status)
|
||||
expect(status.errors).to_not have_received(:add)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::DistributeAnnouncementNotificationWorker do
|
||||
let(:worker) { described_class.new }
|
||||
|
||||
describe '#perform' do
|
||||
context 'with missing record' do
|
||||
it 'runs without error' do
|
||||
expect { worker.perform(nil) }.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
context 'with valid announcement' do
|
||||
let(:announcement) { Fabricate(:announcement) }
|
||||
let!(:user) { Fabricate :user, confirmed_at: 3.days.ago }
|
||||
|
||||
it 'sends the announcement via email', :inline_jobs do
|
||||
emails = capture_emails { worker.perform(announcement.id) }
|
||||
|
||||
expect(emails.size)
|
||||
.to eq(1)
|
||||
expect(emails.first)
|
||||
.to have_attributes(
|
||||
to: [user.email],
|
||||
subject: I18n.t('user_mailer.announcement_published.subject')
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue