Merge commit 'df6086d4027910fb160d531b4fe7ffdec26b0cd7' into glitch-soc/merge-upstream
This commit is contained in:
commit
e91ede5be6
40 files changed
+351
-244
No files matched your search
@@ -3,10 +3,6 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe Api::BaseController do
|
||||
before do
|
||||
stub_const('FakeService', Class.new)
|
||||
end
|
||||
|
||||
controller do
|
||||
def success
|
||||
head 200
|
||||
@@ -72,36 +68,4 @@ describe Api::BaseController do
|
||||
expect(response).to have_http_status(403)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'error handling' do
|
||||
before do
|
||||
routes.draw { get 'failure' => 'api/base#failure' }
|
||||
end
|
||||
|
||||
{
|
||||
ActiveRecord::RecordInvalid => 422,
|
||||
ActiveRecord::RecordNotFound => 404,
|
||||
ActiveRecord::RecordNotUnique => 422,
|
||||
Date::Error => 422,
|
||||
HTTP::Error => 503,
|
||||
Mastodon::InvalidParameterError => 400,
|
||||
Mastodon::NotPermittedError => 403,
|
||||
Mastodon::RaceConditionError => 503,
|
||||
Mastodon::RateLimitExceededError => 429,
|
||||
Mastodon::UnexpectedResponseError => 503,
|
||||
Mastodon::ValidationError => 422,
|
||||
OpenSSL::SSL::SSLError => 503,
|
||||
Seahorse::Client::NetworkingError => 503,
|
||||
Stoplight::Error::RedLight => 503,
|
||||
}.each do |error, code|
|
||||
it "Handles error class of #{error}" do
|
||||
allow(FakeService).to receive(:new).and_raise(error)
|
||||
|
||||
get :failure
|
||||
|
||||
expect(response).to have_http_status(code)
|
||||
expect(FakeService).to have_received(:new)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,51 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Api::ErrorHandling do
|
||||
before do
|
||||
stub_const('FakeService', Class.new)
|
||||
end
|
||||
|
||||
controller(Api::BaseController) do
|
||||
def failure
|
||||
FakeService.new
|
||||
end
|
||||
end
|
||||
|
||||
describe 'error handling' do
|
||||
before do
|
||||
routes.draw { get 'failure' => 'api/base#failure' }
|
||||
end
|
||||
|
||||
{
|
||||
ActiveRecord::RecordInvalid => 422,
|
||||
ActiveRecord::RecordNotFound => 404,
|
||||
ActiveRecord::RecordNotUnique => 422,
|
||||
Date::Error => 422,
|
||||
HTTP::Error => 503,
|
||||
Mastodon::InvalidParameterError => 400,
|
||||
Mastodon::NotPermittedError => 403,
|
||||
Mastodon::RaceConditionError => 503,
|
||||
Mastodon::RateLimitExceededError => 429,
|
||||
Mastodon::UnexpectedResponseError => 503,
|
||||
Mastodon::ValidationError => 422,
|
||||
OpenSSL::SSL::SSLError => 503,
|
||||
Seahorse::Client::NetworkingError => 503,
|
||||
Stoplight::Error::RedLight => 503,
|
||||
}.each do |error, code|
|
||||
it "Handles error class of #{error}" do
|
||||
allow(FakeService)
|
||||
.to receive(:new)
|
||||
.and_raise(error)
|
||||
|
||||
get :failure
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(code)
|
||||
expect(FakeService)
|
||||
.to have_received(:new)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
+25
-32
@@ -61,15 +61,11 @@ describe 'Using OAuth from an external app' do
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Failing to log-in presents the form again
|
||||
fill_in 'user_email', with: email
|
||||
fill_in 'user_password', with: 'wrong password'
|
||||
click_on I18n.t('auth.login')
|
||||
fill_in_auth_details(email, 'wrong password')
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Logging in redirects to an authorization page
|
||||
fill_in 'user_email', with: email
|
||||
fill_in 'user_password', with: password
|
||||
click_on I18n.t('auth.login')
|
||||
fill_in_auth_details(email, password)
|
||||
expect(page).to have_content(I18n.t('doorkeeper.authorizations.buttons.authorize'))
|
||||
|
||||
# Upon authorizing, it redirects to the apps' callback URL
|
||||
@@ -88,15 +84,11 @@ describe 'Using OAuth from an external app' do
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Failing to log-in presents the form again
|
||||
fill_in 'user_email', with: email
|
||||
fill_in 'user_password', with: 'wrong password'
|
||||
click_on I18n.t('auth.login')
|
||||
fill_in_auth_details(email, 'wrong password')
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Logging in redirects to an authorization page
|
||||
fill_in 'user_email', with: email
|
||||
fill_in 'user_password', with: password
|
||||
click_on I18n.t('auth.login')
|
||||
fill_in_auth_details(email, password)
|
||||
expect(page).to have_content(I18n.t('doorkeeper.authorizations.buttons.authorize'))
|
||||
|
||||
# Upon denying, it redirects to the apps' callback URL
|
||||
@@ -118,25 +110,19 @@ describe 'Using OAuth from an external app' do
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Failing to log-in presents the form again
|
||||
fill_in 'user_email', with: email
|
||||
fill_in 'user_password', with: 'wrong password'
|
||||
click_on I18n.t('auth.login')
|
||||
fill_in_auth_details(email, 'wrong password')
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Logging in redirects to a two-factor authentication page
|
||||
fill_in 'user_email', with: email
|
||||
fill_in 'user_password', with: password
|
||||
click_on I18n.t('auth.login')
|
||||
fill_in_auth_details(email, password)
|
||||
expect(page).to have_content(I18n.t('simple_form.hints.sessions.otp'))
|
||||
|
||||
# Filling in an incorrect two-factor authentication code presents the form again
|
||||
fill_in 'user_otp_attempt', with: 'wrong'
|
||||
click_on I18n.t('auth.login')
|
||||
fill_in_otp_details('wrong')
|
||||
expect(page).to have_content(I18n.t('simple_form.hints.sessions.otp'))
|
||||
|
||||
# Filling in the correct TOTP code redirects to an app authorization page
|
||||
fill_in 'user_otp_attempt', with: user.current_otp
|
||||
click_on I18n.t('auth.login')
|
||||
fill_in_otp_details(user.current_otp)
|
||||
expect(page).to have_content(I18n.t('doorkeeper.authorizations.buttons.authorize'))
|
||||
|
||||
# Upon authorizing, it redirects to the apps' callback URL
|
||||
@@ -155,25 +141,19 @@ describe 'Using OAuth from an external app' do
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Failing to log-in presents the form again
|
||||
fill_in 'user_email', with: email
|
||||
fill_in 'user_password', with: 'wrong password'
|
||||
click_on I18n.t('auth.login')
|
||||
fill_in_auth_details(email, 'wrong password')
|
||||
expect(page).to have_content(I18n.t('auth.login'))
|
||||
|
||||
# Logging in redirects to a two-factor authentication page
|
||||
fill_in 'user_email', with: email
|
||||
fill_in 'user_password', with: password
|
||||
click_on I18n.t('auth.login')
|
||||
fill_in_auth_details(email, password)
|
||||
expect(page).to have_content(I18n.t('simple_form.hints.sessions.otp'))
|
||||
|
||||
# Filling in an incorrect two-factor authentication code presents the form again
|
||||
fill_in 'user_otp_attempt', with: 'wrong'
|
||||
click_on I18n.t('auth.login')
|
||||
fill_in_otp_details('wrong')
|
||||
expect(page).to have_content(I18n.t('simple_form.hints.sessions.otp'))
|
||||
|
||||
# Filling in the correct TOTP code redirects to an app authorization page
|
||||
fill_in 'user_otp_attempt', with: user.current_otp
|
||||
click_on I18n.t('auth.login')
|
||||
fill_in_otp_details(user.current_otp)
|
||||
expect(page).to have_content(I18n.t('doorkeeper.authorizations.buttons.authorize'))
|
||||
|
||||
# Upon denying, it redirects to the apps' callback URL
|
||||
@@ -185,6 +165,19 @@ describe 'Using OAuth from an external app' do
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def fill_in_auth_details(email, password)
|
||||
fill_in 'user_email', with: email
|
||||
fill_in 'user_password', with: password
|
||||
click_on I18n.t('auth.login')
|
||||
end
|
||||
|
||||
def fill_in_otp_details(value)
|
||||
fill_in 'user_otp_attempt', with: value
|
||||
click_on I18n.t('auth.login')
|
||||
end
|
||||
|
||||
# TODO: external auth
|
||||
end
|
||||
end
|
||||
@@ -15,6 +15,23 @@ describe Mastodon::CLI::Domains do
|
||||
describe '#purge' do
|
||||
let(:action) { :purge }
|
||||
|
||||
context 'with invalid limited federation mode argument' do
|
||||
let(:arguments) { ['example.host'] }
|
||||
let(:options) { { limited_federation_mode: true } }
|
||||
|
||||
it 'warns about usage and exits' do
|
||||
expect { subject }
|
||||
.to raise_error(Thor::Error, /DOMAIN parameter not supported/)
|
||||
end
|
||||
end
|
||||
|
||||
context 'without a domains argument' do
|
||||
it 'warns about usage and exits' do
|
||||
expect { subject }
|
||||
.to raise_error(Thor::Error, 'No domain(s) given')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with accounts from the domain' do
|
||||
let(:domain) { 'host.example' }
|
||||
let!(:account) { Fabricate(:account, domain: domain) }
|
||||
|
||||
@@ -13,7 +13,26 @@ RSpec.describe Vacuum::ImportsVacuum do
|
||||
|
||||
describe '#perform' do
|
||||
it 'cleans up the expected imports' do
|
||||
expect { subject.perform }.to change { BulkImport.pluck(:id) }.from([old_unconfirmed, new_unconfirmed, recent_ongoing, recent_finished, old_finished].map(&:id)).to([new_unconfirmed, recent_ongoing, recent_finished].map(&:id))
|
||||
expect { subject.perform }
|
||||
.to change { ordered_bulk_imports.pluck(:id) }
|
||||
.from(original_import_ids)
|
||||
.to(remaining_import_ids)
|
||||
end
|
||||
|
||||
def ordered_bulk_imports
|
||||
BulkImport.order(id: :asc)
|
||||
end
|
||||
|
||||
def original_import_ids
|
||||
[old_unconfirmed, new_unconfirmed, recent_ongoing, recent_finished, old_finished].map(&:id)
|
||||
end
|
||||
|
||||
def vacuumed_import_ids
|
||||
[old_unconfirmed, old_finished].map(&:id)
|
||||
end
|
||||
|
||||
def remaining_import_ids
|
||||
original_import_ids - vacuumed_import_ids
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -21,7 +21,7 @@ describe Account::StatusesSearch, :sidekiq_inline do
|
||||
account.indexable = true
|
||||
account.save!
|
||||
|
||||
expect(PublicStatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.where(visibility: :public).count)
|
||||
expect(PublicStatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.public_visibility.count)
|
||||
expect(StatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.count)
|
||||
end
|
||||
end
|
||||
@@ -32,7 +32,7 @@ describe Account::StatusesSearch, :sidekiq_inline do
|
||||
|
||||
context 'when picking an indexable account' do
|
||||
it 'has statuses in the PublicStatusesIndex' do
|
||||
expect(PublicStatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.where(visibility: :public).count)
|
||||
expect(PublicStatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.public_visibility.count)
|
||||
end
|
||||
|
||||
it 'has statuses in the StatusesIndex' do
|
||||
|
||||
Reference in new issue
Block a user