Merge remote-tracking branch 'parent/main' into upstream-20240926
This commit is contained in:
commit
c905714459
517 changed files with 4284 additions and 3891 deletions
|
@ -1,19 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::ClaimsController do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'without signature' do
|
||||
before do
|
||||
post :create, params: { account_username: account.username }, body: '{}'
|
||||
end
|
||||
|
||||
it 'returns http not authorized' do
|
||||
expect(response).to have_http_status(401)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -69,9 +69,10 @@ RSpec.describe ActivityPub::OutboxesController do
|
|||
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
orderedItems: be_an(Array).and(have_attributes(size: 2))
|
||||
orderedItems: be_an(Array)
|
||||
.and(have_attributes(size: 2))
|
||||
.and(all(satisfy { |item| targets_public_collection?(item) }))
|
||||
)
|
||||
expect(response.parsed_body[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true
|
||||
end
|
||||
|
||||
context 'when account is permanently suspended' do
|
||||
|
@ -113,9 +114,10 @@ RSpec.describe ActivityPub::OutboxesController do
|
|||
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
orderedItems: be_an(Array).and(have_attributes(size: 2))
|
||||
orderedItems: be_an(Array)
|
||||
.and(have_attributes(size: 2))
|
||||
.and(all(satisfy { |item| targets_public_collection?(item) }))
|
||||
)
|
||||
expect(response.parsed_body[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -132,9 +134,10 @@ RSpec.describe ActivityPub::OutboxesController do
|
|||
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
orderedItems: be_an(Array).and(have_attributes(size: 3))
|
||||
orderedItems: be_an(Array)
|
||||
.and(have_attributes(size: 3))
|
||||
.and(all(satisfy { |item| targets_public_collection?(item) || targets_followers_collection?(item, account) }))
|
||||
)
|
||||
expect(response.parsed_body[:orderedItems].all? { |item| targets_public_collection?(item) || targets_followers_collection?(item, account) }).to be true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -451,44 +451,4 @@ RSpec.describe Auth::SessionsController do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #webauthn_options' do
|
||||
subject { get :webauthn_options, session: { attempt_user_id: user.id } }
|
||||
|
||||
let!(:user) do
|
||||
Fabricate(:user, email: 'x@y.com', password: 'abcdefgh', otp_required_for_login: true, otp_secret: User.generate_otp_secret(32))
|
||||
end
|
||||
|
||||
context 'with WebAuthn and OTP enabled as second factor' do
|
||||
let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http'}://#{Rails.configuration.x.web_domain}" }
|
||||
|
||||
let(:fake_client) { WebAuthn::FakeClient.new(domain) }
|
||||
|
||||
before do
|
||||
user.update(webauthn_id: WebAuthn.generate_user_id)
|
||||
public_key_credential = WebAuthn::Credential.from_create(fake_client.create)
|
||||
user.webauthn_credentials.create(
|
||||
nickname: 'SecurityKeyNickname',
|
||||
external_id: public_key_credential.id,
|
||||
public_key: public_key_credential.public_key,
|
||||
sign_count: '1000'
|
||||
)
|
||||
post :create, params: { user: { email: user.email, password: user.password } }
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status 200
|
||||
end
|
||||
end
|
||||
|
||||
context 'when WebAuthn not enabled' do
|
||||
it 'returns http unauthorized' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status 401
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,13 +10,6 @@ RSpec.describe Oauth::AuthorizationsController do
|
|||
get :new, params: { client_id: app.uid, response_type: 'code', redirect_uri: 'http://localhost/', scope: 'read' }
|
||||
end
|
||||
|
||||
shared_examples 'stores location for user' do
|
||||
it 'stores location for user' do
|
||||
subject
|
||||
expect(controller.stored_location_for(:user)).to eq "/oauth/authorize?client_id=#{app.uid}&redirect_uri=http%3A%2F%2Flocalhost%2F&response_type=code&scope=read"
|
||||
end
|
||||
end
|
||||
|
||||
context 'when signed in' do
|
||||
let!(:user) { Fabricate(:user) }
|
||||
|
||||
|
@ -24,18 +17,17 @@ RSpec.describe Oauth::AuthorizationsController do
|
|||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success and private cache control headers' do
|
||||
subject
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns private cache control headers' do
|
||||
subject
|
||||
expect(response.headers['Cache-Control']).to include('private, no-store')
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.headers['Cache-Control'])
|
||||
.to include('private, no-store')
|
||||
expect(controller.stored_location_for(:user))
|
||||
.to eq authorize_path_for(app)
|
||||
end
|
||||
|
||||
include_examples 'stores location for user'
|
||||
|
||||
context 'when app is already authorized' do
|
||||
before do
|
||||
Doorkeeper::AccessToken.find_or_create_for(
|
||||
|
@ -52,10 +44,12 @@ RSpec.describe Oauth::AuthorizationsController do
|
|||
expect(response).to redirect_to(/\A#{app.redirect_uri}/)
|
||||
end
|
||||
|
||||
it 'does not redirect to callback with force_login=true' do
|
||||
get :new, params: { client_id: app.uid, response_type: 'code', redirect_uri: 'http://localhost/', scope: 'read', force_login: 'true' }
|
||||
context 'with `force_login` param true' do
|
||||
subject do
|
||||
get :new, params: { client_id: app.uid, response_type: 'code', redirect_uri: 'http://localhost/', scope: 'read', force_login: 'true' }
|
||||
end
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
it { is_expected.to have_http_status(:success) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -63,10 +57,16 @@ RSpec.describe Oauth::AuthorizationsController do
|
|||
context 'when not signed in' do
|
||||
it 'redirects' do
|
||||
subject
|
||||
expect(response).to redirect_to '/auth/sign_in'
|
||||
end
|
||||
|
||||
include_examples 'stores location for user'
|
||||
expect(response)
|
||||
.to redirect_to '/auth/sign_in'
|
||||
expect(controller.stored_location_for(:user))
|
||||
.to eq authorize_path_for(app)
|
||||
end
|
||||
end
|
||||
|
||||
def authorize_path_for(app)
|
||||
"/oauth/authorize?client_id=#{app.uid}&redirect_uri=http%3A%2F%2Flocalhost%2F&response_type=code&scope=read"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,38 +10,31 @@ RSpec.describe Oauth::AuthorizedApplicationsController do
|
|||
get :index
|
||||
end
|
||||
|
||||
shared_examples 'stores location for user' do
|
||||
it 'stores location for user' do
|
||||
subject
|
||||
expect(controller.stored_location_for(:user)).to eq '/oauth/authorized_applications'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when signed in' do
|
||||
before do
|
||||
sign_in Fabricate(:user), scope: :user
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success with private cache control headers' do
|
||||
subject
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.headers['Cache-Control'])
|
||||
.to include('private, no-store')
|
||||
expect(controller.stored_location_for(:user))
|
||||
.to eq '/oauth/authorized_applications'
|
||||
end
|
||||
|
||||
it 'returns private cache control headers' do
|
||||
subject
|
||||
expect(response.headers['Cache-Control']).to include('private, no-store')
|
||||
end
|
||||
|
||||
include_examples 'stores location for user'
|
||||
end
|
||||
|
||||
context 'when not signed in' do
|
||||
it 'redirects' do
|
||||
subject
|
||||
expect(response).to redirect_to '/auth/sign_in'
|
||||
end
|
||||
|
||||
include_examples 'stores location for user'
|
||||
expect(response)
|
||||
.to redirect_to '/auth/sign_in'
|
||||
expect(controller.stored_location_for(:user))
|
||||
.to eq '/oauth/authorized_applications'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -55,23 +48,19 @@ RSpec.describe Oauth::AuthorizedApplicationsController do
|
|||
before do
|
||||
sign_in user, scope: :user
|
||||
allow(redis).to receive(:pipelined).and_yield(redis_pipeline_stub)
|
||||
end
|
||||
|
||||
it 'revokes access tokens for the application and removes subscriptions and sends kill payload to streaming' do
|
||||
post :destroy, params: { id: application.id }
|
||||
end
|
||||
|
||||
it 'revokes access tokens for the application' do
|
||||
expect(Doorkeeper::AccessToken.where(application: application).first.revoked_at).to_not be_nil
|
||||
end
|
||||
|
||||
it 'removes subscriptions for the application\'s access tokens' do
|
||||
expect(Web::PushSubscription.where(user: user).count).to eq 0
|
||||
end
|
||||
|
||||
it 'removes the web_push_subscription' do
|
||||
expect { web_push_subscription.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
it 'sends a session kill payload to the streaming server' do
|
||||
expect(redis_pipeline_stub).to have_received(:publish).with("timeline:access_token:#{access_token.id}", '{"event":"kill"}')
|
||||
expect(Doorkeeper::AccessToken.where(application: application).first.revoked_at)
|
||||
.to_not be_nil
|
||||
expect(Web::PushSubscription.where(user: user).count)
|
||||
.to eq(0)
|
||||
expect { web_push_subscription.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(redis_pipeline_stub)
|
||||
.to have_received(:publish).with("timeline:access_token:#{access_token.id}", '{"event":"kill"}')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,20 +9,15 @@ RSpec.describe Oauth::TokensController do
|
|||
let!(:access_token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, application: application) }
|
||||
let!(:web_push_subscription) { Fabricate(:web_push_subscription, user: user, access_token: access_token) }
|
||||
|
||||
before do
|
||||
it 'revokes the token and removes subscriptions' do
|
||||
post :revoke, params: { client_id: application.uid, token: access_token.token }
|
||||
end
|
||||
|
||||
it 'revokes the token' do
|
||||
expect(access_token.reload.revoked_at).to_not be_nil
|
||||
end
|
||||
|
||||
it 'removes web push subscription for token' do
|
||||
expect(Web::PushSubscription.where(access_token: access_token).count).to eq 0
|
||||
end
|
||||
|
||||
it 'removes the web_push_subscription' do
|
||||
expect { web_push_subscription.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(access_token.reload.revoked_at)
|
||||
.to_not be_nil
|
||||
expect(Web::PushSubscription.where(access_token: access_token).count)
|
||||
.to eq(0)
|
||||
expect { web_push_subscription.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,178 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Settings::ApplicationsController do
|
||||
render_views
|
||||
|
||||
let!(:user) { Fabricate(:user) }
|
||||
let!(:app) { Fabricate(:application, owner: user) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
before do
|
||||
Fabricate(:application)
|
||||
get :index
|
||||
end
|
||||
|
||||
it 'returns http success with private cache control headers', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.headers['Cache-Control']).to include('private, no-store')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show, params: { id: app.id }
|
||||
expect(response).to have_http_status(200)
|
||||
expect(assigns[:application]).to eql(app)
|
||||
end
|
||||
|
||||
it 'returns 404 if you dont own app' do
|
||||
app.update!(owner: nil)
|
||||
|
||||
get :show, params: { id: app.id }
|
||||
expect(response).to have_http_status 404
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
it 'returns http success' do
|
||||
get :new
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'when success (passed scopes as a String)' do
|
||||
subject do
|
||||
post :create, params: {
|
||||
doorkeeper_application: {
|
||||
name: 'My New App',
|
||||
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
|
||||
website: 'http://google.com',
|
||||
scopes: 'read write follow',
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
it 'creates an entry in the database', :aggregate_failures do
|
||||
expect { subject }.to change(Doorkeeper::Application, :count)
|
||||
expect(response).to redirect_to(settings_applications_path)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when success (passed scopes as an Array)' do
|
||||
subject do
|
||||
post :create, params: {
|
||||
doorkeeper_application: {
|
||||
name: 'My New App',
|
||||
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
|
||||
website: 'http://google.com',
|
||||
scopes: %w(read write follow),
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
it 'creates an entry in the database', :aggregate_failures do
|
||||
expect { subject }.to change(Doorkeeper::Application, :count)
|
||||
expect(response).to redirect_to(settings_applications_path)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with failure request' do
|
||||
before do
|
||||
post :create, params: {
|
||||
doorkeeper_application: {
|
||||
name: '',
|
||||
redirect_uri: '',
|
||||
website: '',
|
||||
scopes: [],
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
it 'returns http success and renders form', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response).to render_template(:new)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PATCH #update' do
|
||||
context 'when success' do
|
||||
subject do
|
||||
patch :update, params: {
|
||||
id: app.id,
|
||||
doorkeeper_application: opts,
|
||||
}
|
||||
response
|
||||
end
|
||||
|
||||
let(:opts) do
|
||||
{
|
||||
website: 'https://foo.bar/',
|
||||
}
|
||||
end
|
||||
|
||||
it 'updates existing application' do
|
||||
subject
|
||||
|
||||
expect(app.reload.website).to eql(opts[:website])
|
||||
expect(response).to redirect_to(settings_application_path(app))
|
||||
end
|
||||
end
|
||||
|
||||
context 'with failure request' do
|
||||
before do
|
||||
patch :update, params: {
|
||||
id: app.id,
|
||||
doorkeeper_application: {
|
||||
name: '',
|
||||
redirect_uri: '',
|
||||
website: '',
|
||||
scopes: [],
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
it 'returns http success and renders form', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response).to render_template(:show)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'destroy' do
|
||||
let(:redis_pipeline_stub) { instance_double(Redis::Namespace, publish: nil) }
|
||||
let!(:access_token) { Fabricate(:accessible_access_token, application: app) }
|
||||
|
||||
before do
|
||||
allow(redis).to receive(:pipelined).and_yield(redis_pipeline_stub)
|
||||
post :destroy, params: { id: app.id }
|
||||
end
|
||||
|
||||
it 'redirects back to applications page removes the app' do
|
||||
expect(response).to redirect_to(settings_applications_path)
|
||||
expect(Doorkeeper::Application.find_by(id: app.id)).to be_nil
|
||||
end
|
||||
|
||||
it 'sends a session kill payload to the streaming server' do
|
||||
expect(redis_pipeline_stub).to have_received(:publish).with("timeline:access_token:#{access_token.id}", '{"event":"kill"}')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'regenerate' do
|
||||
let(:token) { user.token_for_app(app) }
|
||||
|
||||
it 'creates new token' do
|
||||
expect(token).to_not be_nil
|
||||
post :regenerate, params: { id: app.id }
|
||||
|
||||
expect(user.token_for_app(app)).to_not eql(token)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,47 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Settings::ExportsController do
|
||||
render_views
|
||||
|
||||
describe 'GET #show' do
|
||||
context 'when signed in' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
get :show
|
||||
end
|
||||
|
||||
it 'returns http success with private cache control headers', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.headers['Cache-Control']).to include('private, no-store')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when not signed in' do
|
||||
it 'redirects' do
|
||||
get :show
|
||||
expect(response).to redirect_to '/auth/sign_in'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
before do
|
||||
sign_in Fabricate(:user), scope: :user
|
||||
end
|
||||
|
||||
it 'redirects to settings_export_path' do
|
||||
post :create
|
||||
expect(response).to redirect_to(settings_export_path)
|
||||
end
|
||||
|
||||
it 'queues BackupWorker job by 1' do
|
||||
expect do
|
||||
post :create
|
||||
end.to change(BackupWorker.jobs, :size).by(1)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -5,16 +5,10 @@ require 'rails_helper'
|
|||
RSpec.describe Settings::FeaturedTagsController do
|
||||
render_views
|
||||
|
||||
shared_examples 'authenticate user' do
|
||||
it 'redirects to sign_in page' do
|
||||
expect(subject).to redirect_to new_user_session_path
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user is not signed in' do
|
||||
subject { post :create }
|
||||
|
||||
it_behaves_like 'authenticate user'
|
||||
it { is_expected.to redirect_to new_user_session_path }
|
||||
end
|
||||
|
||||
context 'when user is signed in' do
|
||||
|
|
|
@ -5,17 +5,11 @@ require 'rails_helper'
|
|||
RSpec.describe Settings::MigrationsController do
|
||||
render_views
|
||||
|
||||
shared_examples 'authenticate user' do
|
||||
it 'redirects to sign_in page' do
|
||||
expect(subject).to redirect_to new_user_session_path
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
context 'when user is not sign in' do
|
||||
subject { get :show }
|
||||
|
||||
it_behaves_like 'authenticate user'
|
||||
it { is_expected.to redirect_to new_user_session_path }
|
||||
end
|
||||
|
||||
context 'when user is sign in' do
|
||||
|
@ -49,7 +43,7 @@ RSpec.describe Settings::MigrationsController do
|
|||
context 'when user is not sign in' do
|
||||
subject { post :create }
|
||||
|
||||
it_behaves_like 'authenticate user'
|
||||
it { is_expected.to redirect_to new_user_session_path }
|
||||
end
|
||||
|
||||
context 'when user is signed in' do
|
||||
|
|
|
@ -63,7 +63,7 @@ RSpec.describe StatusesController do
|
|||
expect(response.headers).to include(
|
||||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Cache-Control' => include('public'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
expect(response.body).to include status.text
|
||||
end
|
||||
|
@ -79,7 +79,7 @@ RSpec.describe StatusesController do
|
|||
|
||||
expect(response.headers).to include(
|
||||
'Content-Type' => include('application/activity+json'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
expect(response.parsed_body)
|
||||
.to include(content: include(status.text))
|
||||
|
@ -168,7 +168,7 @@ RSpec.describe StatusesController do
|
|||
expect(response.headers).to include(
|
||||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Cache-Control' => include('private'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
expect(response.body).to include status.text
|
||||
end
|
||||
|
@ -184,7 +184,7 @@ RSpec.describe StatusesController do
|
|||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Cache-Control' => include('private'),
|
||||
'Content-Type' => include('application/activity+json'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
expect(response.parsed_body)
|
||||
.to include(content: include(status.text))
|
||||
|
@ -212,7 +212,7 @@ RSpec.describe StatusesController do
|
|||
expect(response.headers).to include(
|
||||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Cache-Control' => include('private'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
expect(response.body).to include status.text
|
||||
end
|
||||
|
@ -228,7 +228,7 @@ RSpec.describe StatusesController do
|
|||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Cache-Control' => include('private'),
|
||||
'Content-Type' => include('application/activity+json'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
expect(response.parsed_body)
|
||||
.to include(content: include(status.text))
|
||||
|
@ -278,7 +278,7 @@ RSpec.describe StatusesController do
|
|||
expect(response.headers).to include(
|
||||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Cache-Control' => include('private'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
expect(response.body).to include status.text
|
||||
end
|
||||
|
@ -294,7 +294,7 @@ RSpec.describe StatusesController do
|
|||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Cache-Control' => include('private'),
|
||||
'Content-Type' => include('application/activity+json'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
expect(response.parsed_body)
|
||||
.to include(content: include(status.text))
|
||||
|
@ -370,7 +370,7 @@ RSpec.describe StatusesController do
|
|||
expect(response.headers).to include(
|
||||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Cache-Control' => include('private'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
expect(response.body).to include status.text
|
||||
end
|
||||
|
@ -385,7 +385,7 @@ RSpec.describe StatusesController do
|
|||
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
||||
expect(response.headers).to include(
|
||||
'Content-Type' => include('application/activity+json'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
expect(response.parsed_body)
|
||||
.to include(content: include(status.text))
|
||||
|
@ -412,7 +412,7 @@ RSpec.describe StatusesController do
|
|||
expect(response.headers).to include(
|
||||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Cache-Control' => include('private'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
expect(response.body).to include status.text
|
||||
end
|
||||
|
@ -428,7 +428,7 @@ RSpec.describe StatusesController do
|
|||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Cache-Control' => include('private'),
|
||||
'Content-Type' => include('application/activity+json'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
|
||||
expect(response.parsed_body)
|
||||
|
@ -479,7 +479,7 @@ RSpec.describe StatusesController do
|
|||
expect(response.headers).to include(
|
||||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Cache-Control' => include('private'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
expect(response.body).to include status.text
|
||||
end
|
||||
|
@ -495,7 +495,7 @@ RSpec.describe StatusesController do
|
|||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Cache-Control' => include('private'),
|
||||
'Content-Type' => include('application/activity+json'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
expect(response.parsed_body)
|
||||
.to include(content: include(status.text))
|
||||
|
@ -779,7 +779,7 @@ RSpec.describe StatusesController do
|
|||
expect(response.headers).to include(
|
||||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Cache-Control' => include('public'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
'Link' => include('activity+json')
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:device) do
|
||||
access_token { Fabricate.build(:access_token) }
|
||||
account { Fabricate.build(:account) }
|
||||
device_id { Faker::Number.number(digits: 5) }
|
||||
name { Faker::App.name }
|
||||
fingerprint_key { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) }
|
||||
identity_key { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) }
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:encrypted_message) do
|
||||
device { Fabricate.build(:device) }
|
||||
from_account { Fabricate.build(:account) }
|
||||
from_device_id { Faker::Number.number(digits: 5) }
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:one_time_key) do
|
||||
device { Fabricate.build(:device) }
|
||||
key_id { Faker::Alphanumeric.alphanumeric(number: 10) }
|
||||
key { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) }
|
||||
|
||||
signature do |attrs|
|
||||
signing_key = Ed25519::SigningKey.generate
|
||||
attrs[:device].update(fingerprint_key: Base64.strict_encode64(signing_key.verify_key.to_bytes))
|
||||
Base64.strict_encode64(signing_key.sign(attrs[:key]))
|
||||
end
|
||||
end
|
|
@ -1,3 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:system_key)
|
|
@ -2329,64 +2329,6 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with an encrypted message' do
|
||||
subject { described_class.new(json, sender, delivery: true, delivered_to_account_id: recipient.id) }
|
||||
|
||||
let(:recipient) { Fabricate(:account) }
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
type: 'EncryptedMessage',
|
||||
attributedTo: {
|
||||
type: 'Device',
|
||||
deviceId: '1234',
|
||||
},
|
||||
to: {
|
||||
type: 'Device',
|
||||
deviceId: target_device.device_id,
|
||||
},
|
||||
messageType: 1,
|
||||
cipherText: 'Foo',
|
||||
messageFranking: 'Baz678',
|
||||
digest: {
|
||||
digestAlgorithm: 'Bar456',
|
||||
digestValue: 'Foo123',
|
||||
},
|
||||
}
|
||||
end
|
||||
let(:target_device) { Fabricate(:device, account: recipient) }
|
||||
|
||||
before do
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'creates an encrypted message' do
|
||||
encrypted_message = target_device.encrypted_messages.reload.first
|
||||
|
||||
expect(encrypted_message)
|
||||
.to be_present
|
||||
.and have_attributes(
|
||||
from_device_id: eq('1234'),
|
||||
from_account: eq(sender),
|
||||
type: eq(1),
|
||||
body: eq('Foo'),
|
||||
digest: eq('Foo123')
|
||||
)
|
||||
end
|
||||
|
||||
it 'creates a message franking' do
|
||||
encrypted_message = target_device.encrypted_messages.reload.first
|
||||
message_franking = encrypted_message.message_franking
|
||||
|
||||
crypt = ActiveSupport::MessageEncryptor.new(SystemKey.current_key, serializer: Oj)
|
||||
json = crypt.decrypt_and_verify(message_franking)
|
||||
|
||||
expect(json['source_account_id']).to eq sender.id
|
||||
expect(json['target_account_id']).to eq recipient.id
|
||||
expect(json['original_franking']).to eq 'Baz678'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when sender is in remote pending' do
|
||||
subject { described_class.new(json, sender, delivery: true) }
|
||||
|
||||
|
|
|
@ -29,5 +29,20 @@ RSpec.describe PermalinkRedirector do
|
|||
redirector = described_class.new('@alice/123')
|
||||
expect(redirector.redirect_path).to eq 'https://example.com/status-123'
|
||||
end
|
||||
|
||||
it 'returns path for legacy status links with a query param' do
|
||||
redirector = described_class.new('statuses/123?foo=bar')
|
||||
expect(redirector.redirect_path).to eq 'https://example.com/status-123'
|
||||
end
|
||||
|
||||
it 'returns path for pretty status links with a query param' do
|
||||
redirector = described_class.new('@alice/123?foo=bar')
|
||||
expect(redirector.redirect_path).to eq 'https://example.com/status-123'
|
||||
end
|
||||
|
||||
it 'returns path for deck URLs with query params' do
|
||||
redirector = described_class.new('/deck/directory?local=true')
|
||||
expect(redirector.redirect_path).to eq '/directory?local=true'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,16 +7,13 @@ RSpec.describe ScopeTransformer do
|
|||
subject { described_class.new.apply(ScopeParser.new.parse(input)) }
|
||||
|
||||
shared_examples 'a scope' do |namespace, term, access|
|
||||
it 'parses the term' do
|
||||
expect(subject.term).to eq term
|
||||
end
|
||||
|
||||
it 'parses the namespace' do
|
||||
expect(subject.namespace).to eq namespace
|
||||
end
|
||||
|
||||
it 'parses the access' do
|
||||
expect(subject.access).to eq access
|
||||
it 'parses the attributes' do
|
||||
expect(subject)
|
||||
.to have_attributes(
|
||||
term: term,
|
||||
namespace: namespace,
|
||||
access: access
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Vacuum::SystemKeysVacuum do
|
||||
subject { described_class.new }
|
||||
|
||||
describe '#perform' do
|
||||
let!(:expired_system_key) { Fabricate(:system_key, created_at: (SystemKey::ROTATION_PERIOD * 4).ago) }
|
||||
let!(:current_system_key) { Fabricate(:system_key) }
|
||||
|
||||
before do
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'deletes the expired key' do
|
||||
expect { expired_system_key.reload }.to raise_error ActiveRecord::RecordNotFound
|
||||
end
|
||||
|
||||
it 'does not delete the current key' do
|
||||
expect { current_system_key.reload }.to_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,43 +3,28 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe NotificationMailer do
|
||||
shared_examples 'delivery to non functional user' do
|
||||
context 'when user is not functional' do
|
||||
before { receiver.update(confirmed_at: nil) }
|
||||
|
||||
it 'does not deliver mail' do
|
||||
emails = capture_emails { mail.deliver_now }
|
||||
expect(emails).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
let(:receiver) { Fabricate(:user, account_attributes: { username: 'alice' }) }
|
||||
let(:sender) { Fabricate(:account, username: 'bob') }
|
||||
let(:foreign_status) { Fabricate(:status, account: sender, text: 'The body of the foreign status') }
|
||||
let(:own_status) { Fabricate(:status, account: receiver.account, text: 'The body of the own status') }
|
||||
|
||||
shared_examples 'standard headers' do |type|
|
||||
it 'renders the email' do
|
||||
expect(mail)
|
||||
.to be_present
|
||||
.and(have_header('To', "#{receiver.account.username} <#{receiver.email}>"))
|
||||
.and(have_header('List-ID', "<#{type}.alice.cb6e6126.ngrok.io>"))
|
||||
.and(have_header('List-Unsubscribe', %r{<https://cb6e6126.ngrok.io/unsubscribe\?token=.+>}))
|
||||
.and(have_header('List-Unsubscribe', /&type=#{type}/))
|
||||
.and(have_header('List-Unsubscribe-Post', 'List-Unsubscribe=One-Click'))
|
||||
.and(deliver_to("#{receiver.account.username} <#{receiver.email}>"))
|
||||
.and(deliver_from('notifications@localhost'))
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'thread headers' do
|
||||
it 'renders the email with conversation thread headers' do
|
||||
conversation_header_regex = /<conversation-\d+.\d\d\d\d-\d\d-\d\d@cb6e6126.ngrok.io>/
|
||||
expect(mail)
|
||||
.to be_present
|
||||
.and(have_header('In-Reply-To', conversation_header_regex))
|
||||
.and(have_header('References', conversation_header_regex))
|
||||
end
|
||||
end
|
||||
|
||||
describe 'mention' do
|
||||
let(:mention) { Mention.create!(account: receiver.account, status: foreign_status) }
|
||||
let(:notification) { Notification.create!(account: receiver.account, activity: mention) }
|
||||
let(:mail) { prepared_mailer_for(receiver.account).mention }
|
||||
|
||||
include_examples 'localized subject', 'notification_mailer.mention.subject', name: 'bob'
|
||||
include_examples 'standard headers', 'mention'
|
||||
include_examples 'thread headers'
|
||||
|
||||
it 'renders the email' do
|
||||
expect(mail)
|
||||
|
@ -47,7 +32,11 @@ RSpec.describe NotificationMailer do
|
|||
.and(have_subject('You were mentioned by bob'))
|
||||
.and(have_body_text('You were mentioned by bob'))
|
||||
.and(have_body_text('The body of the foreign status'))
|
||||
.and have_thread_headers
|
||||
.and have_standard_headers('mention').for(receiver)
|
||||
end
|
||||
|
||||
include_examples 'delivery to non functional user'
|
||||
end
|
||||
|
||||
describe 'follow' do
|
||||
|
@ -56,14 +45,16 @@ RSpec.describe NotificationMailer do
|
|||
let(:mail) { prepared_mailer_for(receiver.account).follow }
|
||||
|
||||
include_examples 'localized subject', 'notification_mailer.follow.subject', name: 'bob'
|
||||
include_examples 'standard headers', 'follow'
|
||||
|
||||
it 'renders the email' do
|
||||
expect(mail)
|
||||
.to be_present
|
||||
.and(have_subject('bob is now following you'))
|
||||
.and(have_body_text('bob is now following you'))
|
||||
.and have_standard_headers('follow').for(receiver)
|
||||
end
|
||||
|
||||
include_examples 'delivery to non functional user'
|
||||
end
|
||||
|
||||
describe 'favourite' do
|
||||
|
@ -72,8 +63,6 @@ RSpec.describe NotificationMailer do
|
|||
let(:mail) { prepared_mailer_for(own_status.account).favourite }
|
||||
|
||||
include_examples 'localized subject', 'notification_mailer.favourite.subject', name: 'bob'
|
||||
include_examples 'standard headers', 'favourite'
|
||||
include_examples 'thread headers'
|
||||
|
||||
it 'renders the email' do
|
||||
expect(mail)
|
||||
|
@ -81,7 +70,11 @@ RSpec.describe NotificationMailer do
|
|||
.and(have_subject('bob favorited your post'))
|
||||
.and(have_body_text('Your post was favorited by bob'))
|
||||
.and(have_body_text('The body of the own status'))
|
||||
.and have_thread_headers
|
||||
.and have_standard_headers('favourite').for(receiver)
|
||||
end
|
||||
|
||||
include_examples 'delivery to non functional user'
|
||||
end
|
||||
|
||||
describe 'reblog' do
|
||||
|
@ -90,8 +83,6 @@ RSpec.describe NotificationMailer do
|
|||
let(:mail) { prepared_mailer_for(own_status.account).reblog }
|
||||
|
||||
include_examples 'localized subject', 'notification_mailer.reblog.subject', name: 'bob'
|
||||
include_examples 'standard headers', 'reblog'
|
||||
include_examples 'thread headers'
|
||||
|
||||
it 'renders the email' do
|
||||
expect(mail)
|
||||
|
@ -99,7 +90,11 @@ RSpec.describe NotificationMailer do
|
|||
.and(have_subject('bob boosted your post'))
|
||||
.and(have_body_text('Your post was boosted by bob'))
|
||||
.and(have_body_text('The body of the own status'))
|
||||
.and have_thread_headers
|
||||
.and have_standard_headers('reblog').for(receiver)
|
||||
end
|
||||
|
||||
include_examples 'delivery to non functional user'
|
||||
end
|
||||
|
||||
describe 'follow_request' do
|
||||
|
@ -108,14 +103,16 @@ RSpec.describe NotificationMailer do
|
|||
let(:mail) { prepared_mailer_for(receiver.account).follow_request }
|
||||
|
||||
include_examples 'localized subject', 'notification_mailer.follow_request.subject', name: 'bob'
|
||||
include_examples 'standard headers', 'follow_request'
|
||||
|
||||
it 'renders the email' do
|
||||
expect(mail)
|
||||
.to be_present
|
||||
.and(have_subject('Pending follower: bob'))
|
||||
.and(have_body_text('bob has requested to follow you'))
|
||||
.and have_standard_headers('follow_request').for(receiver)
|
||||
end
|
||||
|
||||
include_examples 'delivery to non functional user'
|
||||
end
|
||||
|
||||
private
|
||||
|
|
19
spec/models/account_deletion_request_spec.rb
Normal file
19
spec/models/account_deletion_request_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountDeletionRequest do
|
||||
describe 'Associations' do
|
||||
it { is_expected.to belong_to(:account).required }
|
||||
end
|
||||
|
||||
describe '#due_at' do
|
||||
before { stub_const 'AccountDeletionRequest::DELAY_TO_DELETION', 1.day }
|
||||
|
||||
it 'returns time from created at with delay added' do
|
||||
account_deletion_request = Fabricate :account_deletion_request, created_at: Date.current.at_midnight
|
||||
expect(account_deletion_request.due_at)
|
||||
.to be_within(0.1).of(Date.tomorrow.at_midnight)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -252,88 +252,83 @@ RSpec.describe Notification do
|
|||
]
|
||||
end
|
||||
|
||||
context 'with a preloaded target status' do
|
||||
it 'preloads mention' do
|
||||
expect(subject[0].type).to eq :mention
|
||||
expect(subject[0].association(:mention)).to be_loaded
|
||||
expect(subject[0].mention.association(:status)).to be_loaded
|
||||
context 'with a preloaded target status and a cached status' do
|
||||
it 'preloads association records and replaces association records' do
|
||||
expect(subject)
|
||||
.to contain_exactly(
|
||||
mention_attributes,
|
||||
status_attributes,
|
||||
reblog_attributes,
|
||||
follow_attributes,
|
||||
follow_request_attributes,
|
||||
favourite_attributes,
|
||||
poll_attributes
|
||||
)
|
||||
end
|
||||
|
||||
it 'preloads status' do
|
||||
expect(subject[1].type).to eq :status
|
||||
expect(subject[1].association(:status)).to be_loaded
|
||||
def mention_attributes
|
||||
have_attributes(
|
||||
type: :mention,
|
||||
target_status: eq(mention.status).and(have_loaded_association(:account)),
|
||||
mention: have_loaded_association(:status)
|
||||
).and(have_loaded_association(:mention))
|
||||
end
|
||||
|
||||
it 'preloads reblog' do
|
||||
expect(subject[2].type).to eq :reblog
|
||||
expect(subject[2].association(:status)).to be_loaded
|
||||
expect(subject[2].status.association(:reblog)).to be_loaded
|
||||
def status_attributes
|
||||
have_attributes(
|
||||
type: :status,
|
||||
target_status: eq(status).and(have_loaded_association(:account))
|
||||
).and(have_loaded_association(:status))
|
||||
end
|
||||
|
||||
it 'preloads follow as nil' do
|
||||
expect(subject[3].type).to eq :follow
|
||||
expect(subject[3].target_status).to be_nil
|
||||
def reblog_attributes
|
||||
have_attributes(
|
||||
type: :reblog,
|
||||
status: have_loaded_association(:reblog),
|
||||
target_status: eq(reblog.reblog).and(have_loaded_association(:account))
|
||||
).and(have_loaded_association(:status))
|
||||
end
|
||||
|
||||
it 'preloads follow_request as nill' do
|
||||
expect(subject[4].type).to eq :follow_request
|
||||
expect(subject[4].target_status).to be_nil
|
||||
def follow_attributes
|
||||
have_attributes(
|
||||
type: :follow,
|
||||
target_status: be_nil
|
||||
)
|
||||
end
|
||||
|
||||
it 'preloads favourite' do
|
||||
expect(subject[5].type).to eq :favourite
|
||||
expect(subject[5].association(:favourite)).to be_loaded
|
||||
expect(subject[5].favourite.association(:status)).to be_loaded
|
||||
def follow_request_attributes
|
||||
have_attributes(
|
||||
type: :follow_request,
|
||||
target_status: be_nil
|
||||
)
|
||||
end
|
||||
|
||||
it 'preloads poll' do
|
||||
expect(subject[6].type).to eq :poll
|
||||
expect(subject[6].association(:poll)).to be_loaded
|
||||
expect(subject[6].poll.association(:status)).to be_loaded
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a cached status' do
|
||||
it 'replaces mention' do
|
||||
expect(subject[0].type).to eq :mention
|
||||
expect(subject[0].target_status.association(:account)).to be_loaded
|
||||
expect(subject[0].target_status).to eq mention.status
|
||||
def favourite_attributes
|
||||
have_attributes(
|
||||
type: :favourite,
|
||||
favourite: have_loaded_association(:status),
|
||||
target_status: eq(favourite.status).and(have_loaded_association(:account))
|
||||
).and(have_loaded_association(:favourite))
|
||||
end
|
||||
|
||||
it 'replaces status' do
|
||||
expect(subject[1].type).to eq :status
|
||||
expect(subject[1].target_status.association(:account)).to be_loaded
|
||||
expect(subject[1].target_status).to eq status
|
||||
end
|
||||
|
||||
it 'replaces reblog' do
|
||||
expect(subject[2].type).to eq :reblog
|
||||
expect(subject[2].target_status.association(:account)).to be_loaded
|
||||
expect(subject[2].target_status).to eq reblog.reblog
|
||||
end
|
||||
|
||||
it 'replaces follow' do
|
||||
expect(subject[3].type).to eq :follow
|
||||
expect(subject[3].target_status).to be_nil
|
||||
end
|
||||
|
||||
it 'replaces follow_request' do
|
||||
expect(subject[4].type).to eq :follow_request
|
||||
expect(subject[4].target_status).to be_nil
|
||||
end
|
||||
|
||||
it 'replaces favourite' do
|
||||
expect(subject[5].type).to eq :favourite
|
||||
expect(subject[5].target_status.association(:account)).to be_loaded
|
||||
expect(subject[5].target_status).to eq favourite.status
|
||||
end
|
||||
|
||||
it 'replaces poll' do
|
||||
expect(subject[6].type).to eq :poll
|
||||
expect(subject[6].target_status.association(:account)).to be_loaded
|
||||
expect(subject[6].target_status).to eq poll.status
|
||||
def poll_attributes
|
||||
have_attributes(
|
||||
type: :poll,
|
||||
poll: have_loaded_association(:status),
|
||||
target_status: eq(poll.status).and(have_loaded_association(:account))
|
||||
).and(have_loaded_association(:poll))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
RSpec::Matchers.define :have_loaded_association do |association|
|
||||
match do |record|
|
||||
record.association(association).loaded?
|
||||
end
|
||||
|
||||
failure_message do |record|
|
||||
"expected #{record} to have loaded association #{association} but it did not."
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe OneTimeKey do
|
||||
describe 'validations' do
|
||||
context 'with an invalid signature' do
|
||||
let(:one_time_key) { Fabricate.build(:one_time_key, signature: 'wrong!') }
|
||||
|
||||
it 'is invalid' do
|
||||
expect(one_time_key).to_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an invalid key' do
|
||||
let(:one_time_key) { Fabricate.build(:one_time_key, key: 'wrong!') }
|
||||
|
||||
it 'is invalid' do
|
||||
expect(one_time_key).to_not be_valid
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -24,21 +24,5 @@ RSpec.describe PreviewCardProvider do
|
|||
expect(results).to eq([not_trendable_and_not_reviewed])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'reviewed' do
|
||||
it 'returns the relevant records' do
|
||||
results = described_class.reviewed
|
||||
|
||||
expect(results).to eq([trendable_and_reviewed])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'pending_review' do
|
||||
it 'returns the relevant records' do
|
||||
results = described_class.pending_review
|
||||
|
||||
expect(results).to eq([not_trendable_and_not_reviewed])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,6 +4,8 @@ require 'rails_helper'
|
|||
require 'devise_two_factor/spec_helpers'
|
||||
|
||||
RSpec.describe User do
|
||||
subject { described_class.new(account: account) }
|
||||
|
||||
let(:password) { 'abcd1234' }
|
||||
let(:account) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
|
@ -464,7 +466,9 @@ RSpec.describe User do
|
|||
end
|
||||
|
||||
describe '#reset_password!' do
|
||||
subject(:user) { Fabricate(:user, password: 'foobar12345') }
|
||||
subject(:user) { Fabricate(:user, password: original_password) }
|
||||
|
||||
let(:original_password) { 'foobar12345' }
|
||||
|
||||
let!(:session_activation) { Fabricate(:session_activation, user: user) }
|
||||
let!(:access_token) { Fabricate(:access_token, resource_owner_id: user.id) }
|
||||
|
@ -472,31 +476,40 @@ RSpec.describe User do
|
|||
|
||||
let(:redis_pipeline_stub) { instance_double(Redis::Namespace, publish: nil) }
|
||||
|
||||
before do
|
||||
allow(redis).to receive(:pipelined).and_yield(redis_pipeline_stub)
|
||||
user.reset_password!
|
||||
before { stub_redis }
|
||||
|
||||
it 'changes the password immediately and revokes related access' do
|
||||
expect { user.reset_password! }
|
||||
.to remove_activated_sessions
|
||||
.and remove_active_user_tokens
|
||||
.and remove_user_web_subscriptions
|
||||
|
||||
expect(user)
|
||||
.to_not be_external_or_valid_password(original_password)
|
||||
expect { session_activation.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect { web_push_subscription.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(redis_pipeline_stub)
|
||||
.to have_received(:publish).with("timeline:access_token:#{access_token.id}", Oj.dump(event: :kill)).once
|
||||
end
|
||||
|
||||
it 'changes the password immediately' do
|
||||
expect(user.external_or_valid_password?('foobar12345')).to be false
|
||||
def remove_activated_sessions
|
||||
change(user.session_activations, :count).to(0)
|
||||
end
|
||||
|
||||
it 'deactivates all sessions' do
|
||||
expect(user.session_activations.count).to eq 0
|
||||
expect { session_activation.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
def remove_active_user_tokens
|
||||
change { Doorkeeper::AccessToken.active_for(user).count }.to(0)
|
||||
end
|
||||
|
||||
it 'revokes all access tokens' do
|
||||
expect(Doorkeeper::AccessToken.active_for(user).count).to eq 0
|
||||
def remove_user_web_subscriptions
|
||||
change { Web::PushSubscription.where(user: user).or(Web::PushSubscription.where(access_token: access_token)).count }.to(0)
|
||||
end
|
||||
|
||||
it 'revokes streaming access for all access tokens' do
|
||||
expect(redis_pipeline_stub).to have_received(:publish).with("timeline:access_token:#{access_token.id}", Oj.dump(event: :kill)).once
|
||||
end
|
||||
|
||||
it 'removes push subscriptions' do
|
||||
expect(Web::PushSubscription.where(user: user).or(Web::PushSubscription.where(access_token: access_token)).count).to eq 0
|
||||
expect { web_push_subscription.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
def stub_redis
|
||||
allow(redis)
|
||||
.to receive(:pipelined)
|
||||
.and_yield(redis_pipeline_stub)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -46,21 +46,6 @@ RSpec.describe 'Accounts show response' do
|
|||
|
||||
describe 'GET to short username paths' do
|
||||
context 'with existing statuses' do
|
||||
let!(:status) { Fabricate(:status, account: account) }
|
||||
let!(:status_reply) { Fabricate(:status, account: account, thread: Fabricate(:status)) }
|
||||
let!(:status_self_reply) { Fabricate(:status, account: account, thread: status) }
|
||||
let!(:status_media) { Fabricate(:status, account: account) }
|
||||
let!(:status_pinned) { Fabricate(:status, account: account) }
|
||||
let!(:status_private) { Fabricate(:status, account: account, visibility: :private) }
|
||||
let!(:status_direct) { Fabricate(:status, account: account, visibility: :direct) }
|
||||
let!(:status_reblog) { Fabricate(:status, account: account, reblog: Fabricate(:status)) }
|
||||
|
||||
before do
|
||||
status_media.media_attachments << Fabricate(:media_attachment, account: account, type: :image)
|
||||
account.pinned_statuses << status_pinned
|
||||
account.pinned_statuses << status_private
|
||||
end
|
||||
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
|
@ -207,6 +192,21 @@ RSpec.describe 'Accounts show response' do
|
|||
context 'with RSS' do
|
||||
let(:format) { 'rss' }
|
||||
|
||||
let!(:status) { Fabricate(:status, account: account) }
|
||||
let!(:status_reply) { Fabricate(:status, account: account, thread: Fabricate(:status)) }
|
||||
let!(:status_self_reply) { Fabricate(:status, account: account, thread: status) }
|
||||
let!(:status_media) { Fabricate(:status, account: account) }
|
||||
let!(:status_pinned) { Fabricate(:status, account: account) }
|
||||
let!(:status_private) { Fabricate(:status, account: account, visibility: :private) }
|
||||
let!(:status_direct) { Fabricate(:status, account: account, visibility: :direct) }
|
||||
let!(:status_reblog) { Fabricate(:status, account: account, reblog: Fabricate(:status)) }
|
||||
|
||||
before do
|
||||
status_media.media_attachments << Fabricate(:media_attachment, account: account, type: :image)
|
||||
account.pinned_statuses << status_pinned
|
||||
account.pinned_statuses << status_private
|
||||
end
|
||||
|
||||
context 'with a normal account in an RSS request' do
|
||||
before do
|
||||
get short_account_path(username: account.username, format: format)
|
||||
|
|
|
@ -14,6 +14,8 @@ RSpec.describe 'API OEmbed' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.headers['Cache-Control'])
|
||||
.to include('private, no-store')
|
||||
end
|
||||
|
@ -27,6 +29,8 @@ RSpec.describe 'API OEmbed' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,8 @@ RSpec.describe 'credentials API' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to include({
|
||||
source: hash_including({
|
||||
discoverable: false,
|
||||
|
@ -36,6 +38,8 @@ RSpec.describe 'credentials API' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body).to include({
|
||||
locked: true,
|
||||
|
@ -75,6 +79,8 @@ RSpec.describe 'credentials API' do
|
|||
it 'returns http success' do
|
||||
subject
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -84,6 +90,8 @@ RSpec.describe 'credentials API' do
|
|||
it 'returns http unprocessable entity' do
|
||||
subject
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -92,6 +100,8 @@ RSpec.describe 'credentials API' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body).to include({
|
||||
source: hash_including({
|
||||
|
|
|
@ -14,6 +14,8 @@ RSpec.describe 'Accounts Familiar Followers API' do
|
|||
get '/api/v1/accounts/familiar_followers', params: { account_id: account.id, limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
|
||||
context 'when there are duplicate account IDs in the params' do
|
||||
|
|
|
@ -23,6 +23,8 @@ RSpec.describe 'account featured tags API' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to contain_exactly(a_hash_including({
|
||||
name: 'bar',
|
||||
url: "https://cb6e6126.ngrok.io/@#{account.username}/tagged/bar",
|
||||
|
@ -37,6 +39,8 @@ RSpec.describe 'account featured tags API' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to contain_exactly(a_hash_including({
|
||||
name: 'bar',
|
||||
url: "https://cb6e6126.ngrok.io/@#{account.pretty_acct}/tagged/bar",
|
||||
|
|
|
@ -21,8 +21,13 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
|
|||
get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.parsed_body.size).to eq 2
|
||||
expect([response.parsed_body[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: alice.id.to_s),
|
||||
hash_including(id: bob.id.to_s)
|
||||
)
|
||||
end
|
||||
|
||||
it 'does not return blocked users', :aggregate_failures do
|
||||
|
@ -30,8 +35,12 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
|
|||
get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.parsed_body.size).to eq 1
|
||||
expect(response.parsed_body[0][:id]).to eq alice.id.to_s
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: alice.id.to_s)
|
||||
)
|
||||
end
|
||||
|
||||
context 'when requesting user is blocked' do
|
||||
|
@ -52,8 +61,11 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
|
|||
account.mute!(bob)
|
||||
get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response.parsed_body.size).to eq 2
|
||||
expect([response.parsed_body[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: alice.id.to_s),
|
||||
hash_including(id: bob.id.to_s)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,8 +21,13 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
|
|||
get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.parsed_body.size).to eq 2
|
||||
expect([response.parsed_body[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: alice.id.to_s),
|
||||
hash_including(id: bob.id.to_s)
|
||||
)
|
||||
end
|
||||
|
||||
it 'does not return blocked users', :aggregate_failures do
|
||||
|
@ -30,8 +35,12 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
|
|||
get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.parsed_body.size).to eq 1
|
||||
expect(response.parsed_body[0][:id]).to eq alice.id.to_s
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: alice.id.to_s)
|
||||
)
|
||||
end
|
||||
|
||||
context 'when requesting user is blocked' do
|
||||
|
@ -52,8 +61,11 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
|
|||
account.mute!(bob)
|
||||
get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response.parsed_body.size).to eq 2
|
||||
expect([response.parsed_body[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: alice.id.to_s),
|
||||
hash_including(id: bob.id.to_s)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ RSpec.describe 'Accounts Identity Proofs API' do
|
|||
get "/api/v1/accounts/#{account.id}/identity_proofs", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,8 @@ RSpec.describe 'Accounts Lists API' do
|
|||
get "/api/v1/accounts/#{account.id}/lists", headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ RSpec.describe 'Accounts Lookup API' do
|
|||
get '/api/v1/accounts/lookup', params: { account_id: account.id, acct: account.acct }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,6 +22,8 @@ RSpec.describe 'Accounts Notes API' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(AccountNote.find_by(account_id: user.account.id, target_account_id: account.id).comment).to eq comment
|
||||
end
|
||||
end
|
||||
|
@ -33,6 +35,8 @@ RSpec.describe 'Accounts Notes API' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(AccountNote.where(account_id: user.account.id, target_account_id: account.id)).to_not exist
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,6 +21,8 @@ RSpec.describe 'Accounts Pins API' do
|
|||
subject
|
||||
end.to change { AccountPin.where(account: user.account, target_account: kevin.account).count }.by(1)
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -36,6 +38,8 @@ RSpec.describe 'Accounts Pins API' do
|
|||
subject
|
||||
end.to change { AccountPin.where(account: user.account, target_account: kevin.account).count }.by(-1)
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,6 +29,8 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
.and contain_exactly(
|
||||
|
@ -50,6 +52,8 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
.and have_attributes(
|
||||
|
@ -70,6 +74,8 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
.and have_attributes(
|
||||
|
@ -149,6 +155,8 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
|
@ -171,6 +179,8 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
|
|
|
@ -13,6 +13,8 @@ RSpec.describe 'Accounts Search API' do
|
|||
get '/api/v1/accounts/search', params: { q: 'query' }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,6 +19,8 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
prev: api_v1_account_statuses_url(limit: 1, min_id: status.id),
|
||||
next: api_v1_account_statuses_url(limit: 1, max_id: status.id)
|
||||
)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
|
||||
context 'with only media' do
|
||||
|
@ -26,6 +28,8 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
get "/api/v1/accounts/#{user.account.id}/statuses", params: { only_media: true }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,6 +45,8 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
it 'returns posts along with self replies', :aggregate_failures do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to have_attributes(size: 2)
|
||||
.and contain_exactly(
|
||||
|
@ -61,6 +67,8 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and include_pagination_headers(prev: api_v1_account_statuses_url(pinned: true, min_id: Status.first.id))
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -79,6 +87,8 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
prev: api_v1_account_statuses_url(pinned: true, min_id: Status.first.id),
|
||||
next: api_v1_account_statuses_url(pinned: true, max_id: Status.first.id)
|
||||
)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -96,6 +106,8 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
get "/api/v1/accounts/#{account.id}/statuses", params: { pinned: true }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
|
||||
context 'when user does not follow account' do
|
||||
|
@ -122,6 +134,8 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
a_hash_including(id: status.id.to_s),
|
||||
a_hash_including(id: private_status.id.to_s)
|
||||
)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,6 +17,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
get '/api/v1/accounts', headers: headers, params: { id: [account.id, other_account.id, 123_123] }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to contain_exactly(
|
||||
hash_including(id: account.id.to_s),
|
||||
hash_including(id: other_account.id.to_s)
|
||||
|
@ -32,6 +34,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
get "/api/v1/accounts/#{account.id}"
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:id]).to eq(account.id.to_s)
|
||||
end
|
||||
end
|
||||
|
@ -41,6 +45,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
get '/api/v1/accounts/1'
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:error]).to eq('Record not found')
|
||||
end
|
||||
end
|
||||
|
@ -57,6 +63,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:id]).to eq(account.id.to_s)
|
||||
end
|
||||
|
||||
|
@ -80,6 +88,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:access_token]).to_not be_blank
|
||||
|
||||
user = User.find_by(email: 'hello@world.tld')
|
||||
|
@ -93,6 +103,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -121,6 +133,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
|
@ -141,6 +155,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
|
@ -240,6 +256,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(user.account.following?(other_account)).to be false
|
||||
end
|
||||
|
||||
|
@ -262,6 +280,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(user.account.followed_by?(other_account)).to be false
|
||||
end
|
||||
|
||||
|
@ -284,6 +304,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(user.account.following?(other_account)).to be false
|
||||
expect(user.account.blocking?(other_account)).to be true
|
||||
end
|
||||
|
@ -307,6 +329,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(user.account.blocking?(other_account)).to be false
|
||||
end
|
||||
|
||||
|
@ -329,6 +353,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(user.account.following?(other_account)).to be true
|
||||
expect(user.account.muting?(other_account)).to be true
|
||||
expect(user.account.muting_notifications?(other_account)).to be true
|
||||
|
@ -353,6 +379,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(user.account.following?(other_account)).to be true
|
||||
expect(user.account.muting?(other_account)).to be true
|
||||
expect(user.account.muting_notifications?(other_account)).to be false
|
||||
|
@ -377,6 +405,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(user.account.following?(other_account)).to be true
|
||||
expect(user.account.muting?(other_account)).to be true
|
||||
expect(user.account.muting_notifications?(other_account)).to be true
|
||||
|
@ -401,6 +431,8 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(user.account.muting?(other_account)).to be false
|
||||
end
|
||||
|
||||
|
|
|
@ -61,6 +61,8 @@ RSpec.describe 'Account actions' do
|
|||
it 'disables the target account' do
|
||||
expect { subject }.to change { target_account.reload.user_disabled? }.from(false).to(true)
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -75,6 +77,8 @@ RSpec.describe 'Account actions' do
|
|||
it 'marks the target account as sensitive' do
|
||||
expect { subject }.to change { target_account.reload.sensitized? }.from(false).to(true)
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -89,6 +93,8 @@ RSpec.describe 'Account actions' do
|
|||
it 'marks the target account as silenced' do
|
||||
expect { subject }.to change { target_account.reload.silenced? }.from(false).to(true)
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -103,6 +109,8 @@ RSpec.describe 'Account actions' do
|
|||
it 'marks the target account as suspended' do
|
||||
expect { subject }.to change { target_account.reload.suspended? }.from(false).to(true)
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -115,6 +123,8 @@ RSpec.describe 'Account actions' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -125,6 +135,8 @@ RSpec.describe 'Account actions' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -135,6 +147,8 @@ RSpec.describe 'Account actions' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,6 +19,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.pluck(:id)).to match_array(expected_results.map { |a| a.id.to_s })
|
||||
end
|
||||
end
|
||||
|
@ -93,6 +95,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to eq(params[:limit])
|
||||
end
|
||||
end
|
||||
|
@ -112,6 +116,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match(
|
||||
a_hash_including(id: account.id.to_s, username: account.username, email: account.user.email)
|
||||
)
|
||||
|
@ -122,6 +128,8 @@ RSpec.describe 'Accounts' do
|
|||
get '/api/v1/admin/accounts/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -145,6 +153,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(account.reload.user_approved?).to be(true)
|
||||
end
|
||||
|
||||
|
@ -166,6 +176,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(403)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -174,6 +186,8 @@ RSpec.describe 'Accounts' do
|
|||
post '/api/v1/admin/accounts/-1/approve', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -193,15 +207,13 @@ RSpec.describe 'Accounts' do
|
|||
it_behaves_like 'forbidden for wrong scope', 'write write:accounts read admin:read'
|
||||
it_behaves_like 'forbidden for wrong role', ''
|
||||
|
||||
it 'removes the user successfully', :aggregate_failures do
|
||||
it 'removes the user successfully and logs action', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(User.where(id: account.user.id)).to_not exist
|
||||
end
|
||||
|
||||
it 'logs action', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(latest_admin_action_log)
|
||||
.to be_present
|
||||
|
@ -218,6 +230,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(403)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -226,6 +240,8 @@ RSpec.describe 'Accounts' do
|
|||
post '/api/v1/admin/accounts/-1/reject', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -248,6 +264,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(account.reload.user_disabled?).to be false
|
||||
end
|
||||
|
||||
|
@ -256,6 +274,8 @@ RSpec.describe 'Accounts' do
|
|||
post '/api/v1/admin/accounts/-1/enable', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -279,6 +299,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(account.reload.suspended?).to be false
|
||||
end
|
||||
end
|
||||
|
@ -288,6 +310,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(403)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -296,6 +320,8 @@ RSpec.describe 'Accounts' do
|
|||
post '/api/v1/admin/accounts/-1/unsuspend', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -318,6 +344,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(account.reload.sensitized?).to be false
|
||||
end
|
||||
|
||||
|
@ -326,6 +354,8 @@ RSpec.describe 'Accounts' do
|
|||
post '/api/v1/admin/accounts/-1/unsensitive', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -348,6 +378,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(account.reload.silenced?).to be false
|
||||
end
|
||||
|
||||
|
@ -356,6 +388,8 @@ RSpec.describe 'Accounts' do
|
|||
post '/api/v1/admin/accounts/-1/unsilence', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -380,6 +414,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(Admin::AccountDeletionWorker).to have_received(:perform_async).with(account.id).once
|
||||
end
|
||||
end
|
||||
|
@ -397,6 +433,8 @@ RSpec.describe 'Accounts' do
|
|||
delete '/api/v1/admin/accounts/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,17 +20,16 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
it_behaves_like 'forbidden for wrong role', ''
|
||||
it_behaves_like 'forbidden for wrong role', 'Moderator'
|
||||
|
||||
it 'returns http success' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
context 'when there is no canonical email block' do
|
||||
it 'returns an empty list' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body).to be_empty
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,7 +40,12 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
it 'returns the correct canonical email hashes' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body.pluck(:canonical_email_hash)).to match_array(expected_email_hashes)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.pluck(:canonical_email_hash))
|
||||
.to match_array(expected_email_hashes)
|
||||
end
|
||||
|
||||
context 'with limit param' do
|
||||
|
@ -96,6 +100,8 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
id: eq(canonical_email_block.id.to_s),
|
||||
|
@ -109,6 +115,8 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
get '/api/v1/admin/canonical_email_blocks/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -131,6 +139,8 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(400)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -142,6 +152,8 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.first[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
|
||||
end
|
||||
end
|
||||
|
@ -151,6 +163,8 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to be_empty
|
||||
end
|
||||
end
|
||||
|
@ -173,6 +187,8 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
|
||||
end
|
||||
|
||||
|
@ -183,6 +199,8 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -193,6 +211,8 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:canonical_email_hash]).to eq(params[:canonical_email_hash])
|
||||
end
|
||||
end
|
||||
|
@ -204,6 +224,8 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
|
||||
end
|
||||
end
|
||||
|
@ -217,6 +239,8 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -237,6 +261,8 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(CanonicalEmailBlock.find_by(id: canonical_email_block.id)).to be_nil
|
||||
end
|
||||
|
||||
|
@ -245,6 +271,8 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
delete '/api/v1/admin/canonical_email_blocks/0', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,8 @@ RSpec.describe 'Admin Dimensions' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(403)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -27,6 +29,9 @@ RSpec.describe 'Admin Dimensions' do
|
|||
expect(response)
|
||||
.to have_http_status(200)
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Array)
|
||||
end
|
||||
|
|
|
@ -20,16 +20,14 @@ RSpec.describe 'Domain Allows' do
|
|||
it_behaves_like 'forbidden for wrong role', ''
|
||||
it_behaves_like 'forbidden for wrong role', 'Moderator'
|
||||
|
||||
it 'returns http success' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
context 'when there is no allowed domains' do
|
||||
it 'returns an empty body' do
|
||||
subject
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to be_empty
|
||||
end
|
||||
end
|
||||
|
@ -49,7 +47,12 @@ RSpec.describe 'Domain Allows' do
|
|||
it 'returns the correct allowed domains' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body).to match_array(expected_response)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to match_array(expected_response)
|
||||
end
|
||||
|
||||
context 'with limit param' do
|
||||
|
@ -79,6 +82,8 @@ RSpec.describe 'Domain Allows' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:domain]).to eq domain_allow.domain
|
||||
end
|
||||
|
||||
|
@ -87,6 +92,8 @@ RSpec.describe 'Domain Allows' do
|
|||
get '/api/v1/admin/domain_allows/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -107,6 +114,8 @@ RSpec.describe 'Domain Allows' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:domain]).to eq 'foo.bar.com'
|
||||
expect(DomainAllow.find_by(domain: 'foo.bar.com')).to be_present
|
||||
end
|
||||
|
@ -119,6 +128,8 @@ RSpec.describe 'Domain Allows' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -129,6 +140,8 @@ RSpec.describe 'Domain Allows' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -160,6 +173,8 @@ RSpec.describe 'Domain Allows' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(DomainAllow.find_by(id: domain_allow.id)).to be_nil
|
||||
end
|
||||
|
||||
|
@ -168,6 +183,8 @@ RSpec.describe 'Domain Allows' do
|
|||
delete '/api/v1/admin/domain_allows/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,17 +20,16 @@ RSpec.describe 'Domain Blocks' do
|
|||
it_behaves_like 'forbidden for wrong role', ''
|
||||
it_behaves_like 'forbidden for wrong role', 'Moderator'
|
||||
|
||||
it 'returns http success' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
context 'when there are no domain blocks' do
|
||||
it 'returns an empty list' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body).to be_empty
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -73,7 +72,12 @@ RSpec.describe 'Domain Blocks' do
|
|||
it 'returns the expected domain blocks' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body).to match_array(expected_responde)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to match_array(expected_responde)
|
||||
end
|
||||
|
||||
context 'with limit param' do
|
||||
|
@ -126,6 +130,8 @@ RSpec.describe 'Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match(
|
||||
id: domain_block.id.to_s,
|
||||
domain: domain_block.domain,
|
||||
|
@ -154,6 +160,8 @@ RSpec.describe 'Domain Blocks' do
|
|||
get '/api/v1/admin/domain_blocks/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -173,6 +181,8 @@ RSpec.describe 'Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match a_hash_including(
|
||||
{
|
||||
domain: 'foo.bar.com',
|
||||
|
@ -194,6 +204,8 @@ RSpec.describe 'Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match a_hash_including(
|
||||
{
|
||||
domain: 'foo.bar.com',
|
||||
|
@ -214,6 +226,8 @@ RSpec.describe 'Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:existing_domain_block][:domain]).to eq('foo.bar.com')
|
||||
end
|
||||
end
|
||||
|
@ -227,6 +241,8 @@ RSpec.describe 'Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:existing_domain_block][:domain]).to eq('bar.com')
|
||||
end
|
||||
end
|
||||
|
@ -238,6 +254,8 @@ RSpec.describe 'Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -258,6 +276,8 @@ RSpec.describe 'Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match a_hash_including(
|
||||
{
|
||||
id: domain_block.id.to_s,
|
||||
|
@ -277,6 +297,8 @@ RSpec.describe 'Domain Blocks' do
|
|||
put '/api/v1/admin/domain_blocks/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -296,6 +318,8 @@ RSpec.describe 'Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(DomainBlock.find_by(id: domain_block.id)).to be_nil
|
||||
end
|
||||
|
||||
|
@ -304,6 +328,8 @@ RSpec.describe 'Domain Blocks' do
|
|||
delete '/api/v1/admin/domain_blocks/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,17 +21,16 @@ RSpec.describe 'Email Domain Blocks' do
|
|||
it_behaves_like 'forbidden for wrong role', ''
|
||||
it_behaves_like 'forbidden for wrong role', 'Moderator'
|
||||
|
||||
it 'returns http success' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
context 'when there is no email domain block' do
|
||||
it 'returns an empty list' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body).to be_empty
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -42,7 +41,12 @@ RSpec.describe 'Email Domain Blocks' do
|
|||
it 'return the correct blocked email domains' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body.pluck(:domain)).to match_array(blocked_email_domains)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.pluck(:domain))
|
||||
.to match_array(blocked_email_domains)
|
||||
end
|
||||
|
||||
context 'with limit param' do
|
||||
|
@ -97,6 +101,8 @@ RSpec.describe 'Email Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:domain]).to eq(email_domain_block.domain)
|
||||
end
|
||||
end
|
||||
|
@ -106,6 +112,8 @@ RSpec.describe 'Email Domain Blocks' do
|
|||
get '/api/v1/admin/email_domain_blocks/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -125,6 +133,8 @@ RSpec.describe 'Email Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:domain]).to eq(params[:domain])
|
||||
end
|
||||
|
||||
|
@ -135,6 +145,8 @@ RSpec.describe 'Email Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -145,6 +157,8 @@ RSpec.describe 'Email Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -157,6 +171,8 @@ RSpec.describe 'Email Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -176,6 +192,8 @@ RSpec.describe 'Email Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to be_empty
|
||||
expect(EmailDomainBlock.find_by(id: email_domain_block.id)).to be_nil
|
||||
end
|
||||
|
@ -185,6 +203,8 @@ RSpec.describe 'Email Domain Blocks' do
|
|||
delete '/api/v1/admin/email_domain_blocks/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,17 +20,16 @@ RSpec.describe 'IP Blocks' do
|
|||
it_behaves_like 'forbidden for wrong role', ''
|
||||
it_behaves_like 'forbidden for wrong role', 'Moderator'
|
||||
|
||||
it 'returns http success' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
context 'when there is no ip block' do
|
||||
it 'returns an empty body' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body).to be_empty
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -58,7 +57,12 @@ RSpec.describe 'IP Blocks' do
|
|||
it 'returns the correct blocked ips' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body).to match_array(expected_response)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to match_array(expected_response)
|
||||
end
|
||||
|
||||
context 'with limit param' do
|
||||
|
@ -88,6 +92,8 @@ RSpec.describe 'IP Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
|
@ -101,6 +107,8 @@ RSpec.describe 'IP Blocks' do
|
|||
get '/api/v1/admin/ip_blocks/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -120,6 +128,8 @@ RSpec.describe 'IP Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
ip: eq("#{params[:ip]}/32"),
|
||||
|
@ -135,6 +145,8 @@ RSpec.describe 'IP Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -145,6 +157,8 @@ RSpec.describe 'IP Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -157,6 +171,8 @@ RSpec.describe 'IP Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -167,6 +183,8 @@ RSpec.describe 'IP Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -185,6 +203,8 @@ RSpec.describe 'IP Blocks' do
|
|||
.and change_comment_value
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match(hash_including({
|
||||
ip: "#{ip_block.ip}/#{ip_block.ip.prefix}",
|
||||
severity: 'sign_up_requires_approval',
|
||||
|
@ -205,6 +225,8 @@ RSpec.describe 'IP Blocks' do
|
|||
put '/api/v1/admin/ip_blocks/-1', headers: headers, params: params
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -220,6 +242,8 @@ RSpec.describe 'IP Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to be_empty
|
||||
expect(IpBlock.find_by(id: ip_block.id)).to be_nil
|
||||
end
|
||||
|
@ -229,6 +253,8 @@ RSpec.describe 'IP Blocks' do
|
|||
delete '/api/v1/admin/ip_blocks/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,6 +32,8 @@ RSpec.describe 'Admin Measures' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(403)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -43,6 +45,8 @@ RSpec.describe 'Admin Measures' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Array)
|
||||
|
|
|
@ -19,17 +19,16 @@ RSpec.describe 'Reports' do
|
|||
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
||||
it_behaves_like 'forbidden for wrong role', ''
|
||||
|
||||
it 'returns http success' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
context 'when there are no reports' do
|
||||
it 'returns an empty list' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body).to be_empty
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -64,7 +63,12 @@ RSpec.describe 'Reports' do
|
|||
it 'returns all unresolved reports' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body).to match_array(expected_response)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to match_array(expected_response)
|
||||
end
|
||||
|
||||
context 'with resolved param' do
|
||||
|
@ -126,6 +130,8 @@ RSpec.describe 'Reports' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to include(
|
||||
{
|
||||
id: report.id.to_s,
|
||||
|
@ -156,6 +162,8 @@ RSpec.describe 'Reports' do
|
|||
.and create_an_action_log
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
report.reload
|
||||
|
||||
|
@ -190,6 +198,8 @@ RSpec.describe 'Reports' do
|
|||
.to change { report.reload.unresolved? }.from(true).to(false)
|
||||
.and create_an_action_log
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -208,6 +218,8 @@ RSpec.describe 'Reports' do
|
|||
.to change { report.reload.unresolved? }.from(false).to(true)
|
||||
.and create_an_action_log
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -226,6 +238,8 @@ RSpec.describe 'Reports' do
|
|||
.to change { report.reload.assigned_account_id }.from(nil).to(user.account.id)
|
||||
.and create_an_action_log
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -244,6 +258,8 @@ RSpec.describe 'Reports' do
|
|||
.to change { report.reload.assigned_account_id }.from(user.account.id).to(nil)
|
||||
.and create_an_action_log
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ RSpec.describe 'Admin Retention' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(403)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -26,6 +28,8 @@ RSpec.describe 'Admin Retention' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Array)
|
||||
|
|
|
@ -20,17 +20,16 @@ RSpec.describe 'Tags' do
|
|||
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
||||
it_behaves_like 'forbidden for wrong role', ''
|
||||
|
||||
it 'returns http success' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
context 'when there are no tags' do
|
||||
it 'returns an empty list' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body).to be_empty
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -46,6 +45,11 @@ RSpec.describe 'Tags' do
|
|||
|
||||
it 'returns the expected tags' do
|
||||
subject
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
tags.each do |tag|
|
||||
expect(response.parsed_body.find { |item| item[:id] == tag.id.to_s && item[:name] == tag.name }).to_not be_nil
|
||||
end
|
||||
|
@ -73,17 +77,18 @@ RSpec.describe 'Tags' do
|
|||
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
||||
it_behaves_like 'forbidden for wrong role', ''
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success and expected tag content' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
it 'returns expected tag content' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body[:id].to_i).to eq(tag.id)
|
||||
expect(response.parsed_body[:name]).to eq(tag.name)
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
id: tag.id.to_s,
|
||||
name: tag.name
|
||||
)
|
||||
end
|
||||
|
||||
context 'when the requested tag does not exist' do
|
||||
|
@ -91,6 +96,8 @@ RSpec.describe 'Tags' do
|
|||
get '/api/v1/admin/tags/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -107,17 +114,18 @@ RSpec.describe 'Tags' do
|
|||
it_behaves_like 'forbidden for wrong scope', 'admin:read'
|
||||
it_behaves_like 'forbidden for wrong role', ''
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success and updates tag' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
it 'returns updated tag' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body[:id].to_i).to eq(tag.id)
|
||||
expect(response.parsed_body[:name]).to eq(tag.name.upcase)
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
id: tag.id.to_s,
|
||||
name: tag.name.upcase
|
||||
)
|
||||
end
|
||||
|
||||
context 'when the updated display name is invalid' do
|
||||
|
@ -127,6 +135,8 @@ RSpec.describe 'Tags' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -135,6 +145,8 @@ RSpec.describe 'Tags' do
|
|||
get '/api/v1/admin/tags/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,8 @@ RSpec.describe 'Links' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -36,6 +38,8 @@ RSpec.describe 'Links' do
|
|||
.to change_link_trendable_to_true
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expects_correct_link_data
|
||||
end
|
||||
|
||||
|
@ -60,6 +64,8 @@ RSpec.describe 'Links' do
|
|||
post '/api/v1/admin/trends/links/-1/approve', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -70,6 +76,8 @@ RSpec.describe 'Links' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(403)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -89,6 +97,8 @@ RSpec.describe 'Links' do
|
|||
.to_not change_link_trendable
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
|
||||
def change_link_trendable
|
||||
|
@ -114,6 +124,8 @@ RSpec.describe 'Links' do
|
|||
post '/api/v1/admin/trends/links/-1/reject', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -124,6 +136,8 @@ RSpec.describe 'Links' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(403)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,6 +16,8 @@ RSpec.describe 'API V1 Admin Trends Links Preview Card Providers' do
|
|||
get '/api/v1/admin/trends/links/publishers', params: { account_id: account.id, limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,6 +31,8 @@ RSpec.describe 'API V1 Admin Trends Links Preview Card Providers' do
|
|||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -42,6 +46,8 @@ RSpec.describe 'API V1 Admin Trends Links Preview Card Providers' do
|
|||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,6 +16,8 @@ RSpec.describe 'API V1 Admin Trends Statuses' do
|
|||
get '/api/v1/admin/trends/statuses', params: { account_id: account.id, limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,6 +31,8 @@ RSpec.describe 'API V1 Admin Trends Statuses' do
|
|||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -42,6 +46,8 @@ RSpec.describe 'API V1 Admin Trends Statuses' do
|
|||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,6 +16,8 @@ RSpec.describe 'API V1 Admin Trends Tags' do
|
|||
get '/api/v1/admin/trends/tags', params: { account_id: account.id, limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,6 +31,8 @@ RSpec.describe 'API V1 Admin Trends Tags' do
|
|||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -42,6 +46,8 @@ RSpec.describe 'API V1 Admin Trends Tags' do
|
|||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,9 @@ RSpec.describe 'API V1 Announcements Reactions' do
|
|||
it 'returns http unauthorized' do
|
||||
put "/api/v1/announcements/#{announcement.id}/reactions/#{escaped_emoji}"
|
||||
|
||||
expect(response).to have_http_status 401
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -26,6 +28,8 @@ RSpec.describe 'API V1 Announcements Reactions' do
|
|||
|
||||
it 'creates reaction', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(announcement.announcement_reactions.find_by(name: '😂', account: user.account)).to_not be_nil
|
||||
end
|
||||
end
|
||||
|
@ -39,7 +43,9 @@ RSpec.describe 'API V1 Announcements Reactions' do
|
|||
context 'without token' do
|
||||
it 'returns http unauthorized' do
|
||||
delete "/api/v1/announcements/#{announcement.id}/reactions/#{escaped_emoji}"
|
||||
expect(response).to have_http_status 401
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -50,6 +56,8 @@ RSpec.describe 'API V1 Announcements Reactions' do
|
|||
|
||||
it 'creates reaction', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(announcement.announcement_reactions.find_by(name: '😂', account: user.account)).to be_nil
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,9 @@ RSpec.describe 'API V1 Announcements' do
|
|||
it 'returns http unprocessable entity' do
|
||||
get '/api/v1/announcements'
|
||||
|
||||
expect(response).to have_http_status 422
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -26,6 +28,8 @@ RSpec.describe 'API V1 Announcements' do
|
|||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -35,7 +39,9 @@ RSpec.describe 'API V1 Announcements' do
|
|||
it 'returns http unauthorized' do
|
||||
post "/api/v1/announcements/#{announcement.id}/dismiss"
|
||||
|
||||
expect(response).to have_http_status 401
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -48,6 +54,8 @@ RSpec.describe 'API V1 Announcements' do
|
|||
|
||||
it 'dismisses announcement', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(announcement.announcement_mutes.find_by(account: user.account)).to_not be_nil
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ RSpec.describe 'API V1 Annual Reports' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -33,6 +35,8 @@ RSpec.describe 'API V1 Annual Reports' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_present
|
||||
|
@ -51,6 +55,8 @@ RSpec.describe 'API V1 Annual Reports' do
|
|||
.to change { annual_report.reload.viewed? }.to(true)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,6 +17,8 @@ RSpec.describe 'Credentials' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body).to match(
|
||||
a_hash_including(
|
||||
|
@ -36,9 +38,12 @@ RSpec.describe 'Credentials' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body[:client_id]).to_not be_present
|
||||
expect(response.parsed_body[:client_secret]).to_not be_present
|
||||
expect(response.parsed_body)
|
||||
.to not_include(client_id: be_present)
|
||||
.and not_include(client_secret: be_present)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -47,14 +52,12 @@ RSpec.describe 'Credentials' do
|
|||
let(:token) { Fabricate(:accessible_access_token, application: application) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success and returns app information' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns the app information correctly' do
|
||||
subject
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body).to match(
|
||||
a_hash_including(
|
||||
|
@ -78,6 +81,8 @@ RSpec.describe 'Credentials' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -90,6 +95,8 @@ RSpec.describe 'Credentials' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
|
||||
it 'returns the error in the json response' do
|
||||
|
@ -108,14 +115,12 @@ RSpec.describe 'Credentials' do
|
|||
let(:token) { Fabricate(:accessible_access_token, application: application) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}-invalid" } }
|
||||
|
||||
it 'returns http authorization error' do
|
||||
it 'returns http authorization error with json error' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(401)
|
||||
end
|
||||
|
||||
it 'returns the error in the json response' do
|
||||
subject
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body).to match(
|
||||
a_hash_including(
|
||||
|
|
|
@ -28,6 +28,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
app = Doorkeeper::Application.find_by(name: client_name)
|
||||
|
||||
|
@ -59,6 +61,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(Doorkeeper::Application.find_by(name: client_name)).to be_present
|
||||
|
||||
expect(response.parsed_body)
|
||||
|
@ -76,6 +80,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
app = Doorkeeper::Application.find_by(name: client_name)
|
||||
|
||||
|
@ -96,6 +102,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -106,6 +114,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(Doorkeeper::Application.find_by(name: client_name).scopes.to_s).to eq 'read'
|
||||
end
|
||||
end
|
||||
|
@ -117,6 +127,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -127,6 +139,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -137,6 +151,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -148,6 +164,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -158,6 +176,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
app = Doorkeeper::Application.find_by(name: client_name)
|
||||
|
||||
|
@ -180,6 +200,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
app = Doorkeeper::Application.find_by(name: client_name)
|
||||
|
||||
|
@ -202,6 +224,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -212,6 +236,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -222,6 +248,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -232,6 +260,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -242,6 +272,8 @@ RSpec.describe 'Apps' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
app = Doorkeeper::Application.find_by(name: client_name)
|
||||
|
||||
|
|
|
@ -26,21 +26,20 @@ RSpec.describe 'Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match_array(expected_response)
|
||||
end
|
||||
|
||||
context 'with limit param' do
|
||||
let(:params) { { limit: 2 } }
|
||||
|
||||
it 'returns only the requested number of blocked accounts' do
|
||||
it 'returns only the requested number of blocked accounts and sets link header pagination' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body.size).to eq(params[:limit])
|
||||
end
|
||||
|
||||
it 'sets correct link header pagination' do
|
||||
subject
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response)
|
||||
.to include_pagination_headers(
|
||||
prev: api_v1_blocks_url(limit: params[:limit], since_id: blocks.last.id),
|
||||
|
|
|
@ -24,15 +24,12 @@ RSpec.describe 'Bookmarks' do
|
|||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write'
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success and the bookmarked statuses' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns the bookmarked statuses' do
|
||||
subject
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match_array(expected_response)
|
||||
end
|
||||
|
||||
|
@ -45,6 +42,8 @@ RSpec.describe 'Bookmarks' do
|
|||
expect(response.parsed_body.size)
|
||||
.to eq(params[:limit])
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response)
|
||||
.to include_pagination_headers(
|
||||
prev: api_v1_bookmarks_url(limit: params[:limit], min_id: bookmarks.last.id),
|
||||
|
@ -60,6 +59,8 @@ RSpec.describe 'Bookmarks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,6 +26,8 @@ RSpec.describe 'API V1 Conversations' do
|
|||
prev: api_v1_conversations_url(limit: 1, min_id: Status.first.id),
|
||||
next: api_v1_conversations_url(limit: 1, max_id: Status.first.id)
|
||||
)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
|
||||
it 'returns conversations', :aggregate_failures do
|
||||
|
|
|
@ -18,6 +18,8 @@ RSpec.describe 'Custom Emojis' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_present
|
||||
|
@ -33,6 +35,8 @@ RSpec.describe 'Custom Emojis' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_present
|
||||
|
|
|
@ -82,8 +82,13 @@ RSpec.describe 'Directories API' do
|
|||
get '/api/v1/directory', headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.parsed_body.size).to eq(2)
|
||||
expect(response.parsed_body.pluck(:id)).to contain_exactly(eligible_remote_account.id.to_s, local_discoverable_account.id.to_s)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: eligible_remote_account.id.to_s),
|
||||
hash_including(id: local_discoverable_account.id.to_s)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -101,9 +106,13 @@ RSpec.describe 'Directories API' do
|
|||
get '/api/v1/directory', headers: headers, params: { local: '1' }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.parsed_body.size).to eq(1)
|
||||
expect(response.parsed_body.first[:id]).to include(local_account.id.to_s)
|
||||
expect(response.body).to_not include(remote_account.id.to_s)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: local_account.id.to_s)
|
||||
)
|
||||
.and not_include(remote_account.id.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -115,9 +124,13 @@ RSpec.describe 'Directories API' do
|
|||
get '/api/v1/directory', headers: headers, params: { order: 'active' }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.parsed_body.size).to eq(2)
|
||||
expect(response.parsed_body.first[:id]).to include(new_stat.account_id.to_s)
|
||||
expect(response.parsed_body.second[:id]).to include(old_stat.account_id.to_s)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: new_stat.account_id.to_s),
|
||||
hash_including(id: old_stat.account_id.to_s)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -130,9 +143,13 @@ RSpec.describe 'Directories API' do
|
|||
get '/api/v1/directory', headers: headers, params: { order: 'new' }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.parsed_body.size).to eq(2)
|
||||
expect(response.parsed_body.first[:id]).to include(account_new.id.to_s)
|
||||
expect(response.parsed_body.second[:id]).to include(account_old.id.to_s)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: account_new.id.to_s),
|
||||
hash_including(id: account_old.id.to_s)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,6 +26,8 @@ RSpec.describe 'Domain blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match_array(blocked_domains)
|
||||
end
|
||||
|
||||
|
@ -53,6 +55,8 @@ RSpec.describe 'Domain blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(user.account.domain_blocking?(params[:domain])).to be(true)
|
||||
end
|
||||
|
||||
|
@ -63,6 +67,8 @@ RSpec.describe 'Domain blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -73,6 +79,8 @@ RSpec.describe 'Domain blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -94,6 +102,8 @@ RSpec.describe 'Domain blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(user.account.domain_blocking?('example.com')).to be(false)
|
||||
end
|
||||
|
||||
|
@ -104,6 +114,8 @@ RSpec.describe 'Domain blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,6 +26,8 @@ RSpec.describe 'Confirmations' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(403)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,6 +43,8 @@ RSpec.describe 'Confirmations' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(403)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
|
||||
context 'when user changed e-mail and has not confirmed it' do
|
||||
|
@ -52,6 +56,8 @@ RSpec.describe 'Confirmations' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -61,6 +67,8 @@ RSpec.describe 'Confirmations' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -71,6 +79,8 @@ RSpec.describe 'Confirmations' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(user.reload.unconfirmed_email).to eq('foo@bar.com')
|
||||
end
|
||||
end
|
||||
|
@ -82,6 +92,8 @@ RSpec.describe 'Confirmations' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -94,6 +106,8 @@ RSpec.describe 'Confirmations' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -111,6 +125,8 @@ RSpec.describe 'Confirmations' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to be false
|
||||
end
|
||||
end
|
||||
|
@ -122,6 +138,8 @@ RSpec.describe 'Confirmations' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to be true
|
||||
end
|
||||
end
|
||||
|
@ -139,6 +157,8 @@ RSpec.describe 'Confirmations' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to be false
|
||||
end
|
||||
end
|
||||
|
@ -150,6 +170,8 @@ RSpec.describe 'Confirmations' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to be true
|
||||
end
|
||||
end
|
||||
|
@ -162,6 +184,8 @@ RSpec.describe 'Confirmations' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ RSpec.describe 'Endorsements' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -36,6 +38,8 @@ RSpec.describe 'Endorsements' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_present
|
||||
|
@ -51,6 +55,8 @@ RSpec.describe 'Endorsements' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to_not be_present
|
||||
|
|
|
@ -24,35 +24,29 @@ RSpec.describe 'Favourites' do
|
|||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write'
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success and includes the favourites' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns the favourites' do
|
||||
subject
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match_array(expected_response)
|
||||
end
|
||||
|
||||
context 'with limit param' do
|
||||
let(:params) { { limit: 1 } }
|
||||
|
||||
it 'returns only the requested number of favourites' do
|
||||
it 'returns only the requested number of favourites and sets pagination headers' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body.size).to eq(params[:limit])
|
||||
end
|
||||
|
||||
it 'sets the correct pagination headers' do
|
||||
subject
|
||||
|
||||
expect(response)
|
||||
.to include_pagination_headers(
|
||||
prev: api_v1_favourites_url(limit: params[:limit], min_id: favourites.last.id),
|
||||
next: api_v1_favourites_url(limit: params[:limit], max_id: favourites.second.id)
|
||||
)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -63,6 +57,8 @@ RSpec.describe 'Favourites' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,6 +32,8 @@ RSpec.describe 'Featured Tags Suggestions API' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
include(name: used_tag.name)
|
||||
|
|
|
@ -22,6 +22,8 @@ RSpec.describe 'FeaturedTags' do
|
|||
get '/api/v1/featured_tags'
|
||||
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,6 +31,8 @@ RSpec.describe 'FeaturedTags' do
|
|||
get '/api/v1/featured_tags', headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
|
||||
context 'when the requesting user has no featured tag' do
|
||||
|
@ -58,15 +62,12 @@ RSpec.describe 'FeaturedTags' do
|
|||
describe 'POST /api/v1/featured_tags' do
|
||||
let(:params) { { name: 'tag' } }
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success and includes correct tag name' do
|
||||
post '/api/v1/featured_tags', headers: headers, params: params
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns the correct tag name' do
|
||||
post '/api/v1/featured_tags', headers: headers, params: params
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
name: params[:name]
|
||||
|
@ -94,6 +95,8 @@ RSpec.describe 'FeaturedTags' do
|
|||
post '/api/v1/featured_tags', params: params
|
||||
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -102,6 +105,8 @@ RSpec.describe 'FeaturedTags' do
|
|||
post '/api/v1/featured_tags', headers: headers
|
||||
|
||||
expect(response).to have_http_status(400)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -112,6 +117,8 @@ RSpec.describe 'FeaturedTags' do
|
|||
post '/api/v1/featured_tags', headers: headers, params: params
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -124,6 +131,8 @@ RSpec.describe 'FeaturedTags' do
|
|||
post '/api/v1/featured_tags', headers: headers, params: params
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -132,23 +141,15 @@ RSpec.describe 'FeaturedTags' do
|
|||
let!(:featured_tag) { FeaturedTag.create(name: 'tag', account: user.account) }
|
||||
let(:id) { featured_tag.id }
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success with an empty body and deletes the featured tag', :inline_jobs do
|
||||
delete "/api/v1/featured_tags/#{id}", headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns an empty body' do
|
||||
delete "/api/v1/featured_tags/#{id}", headers: headers
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to be_empty
|
||||
end
|
||||
|
||||
it 'deletes the featured tag', :inline_jobs do
|
||||
delete "/api/v1/featured_tags/#{id}", headers: headers
|
||||
|
||||
featured_tag = FeaturedTag.find_by(id: id)
|
||||
|
||||
expect(featured_tag).to be_nil
|
||||
end
|
||||
|
||||
|
@ -165,6 +166,8 @@ RSpec.describe 'FeaturedTags' do
|
|||
delete "/api/v1/featured_tags/#{id}"
|
||||
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -173,6 +176,8 @@ RSpec.describe 'FeaturedTags' do
|
|||
delete '/api/v1/featured_tags/0', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -184,6 +189,8 @@ RSpec.describe 'FeaturedTags' do
|
|||
delete "/api/v1/featured_tags/#{id}", headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,8 @@ RSpec.describe 'API V1 Filters' do
|
|||
it 'returns http success' do
|
||||
get '/api/v1/filters', headers: headers
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
include(id: custom_filter_keyword.id.to_s)
|
||||
|
@ -35,6 +37,8 @@ RSpec.describe 'API V1 Filters' do
|
|||
filter = user.account.custom_filters.first
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(filter).to_not be_nil
|
||||
expect(filter.keywords.pluck(:keyword, :whole_word)).to eq [['magic', whole_word]]
|
||||
expect(filter.context).to eq %w(home)
|
||||
|
@ -50,6 +54,8 @@ RSpec.describe 'API V1 Filters' do
|
|||
filter = user.account.custom_filters.first
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(filter).to_not be_nil
|
||||
expect(filter.keywords.pluck(:keyword, :whole_word)).to eq [['magic', whole_word]]
|
||||
expect(filter.context).to eq %w(home)
|
||||
|
@ -68,6 +74,8 @@ RSpec.describe 'API V1 Filters' do
|
|||
get "/api/v1/filters/#{keyword.id}", headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -82,6 +90,8 @@ RSpec.describe 'API V1 Filters' do
|
|||
|
||||
it 'updates the filter', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(keyword.reload.phrase).to eq 'updated'
|
||||
end
|
||||
end
|
||||
|
@ -97,6 +107,8 @@ RSpec.describe 'API V1 Filters' do
|
|||
|
||||
it 'removes the filter', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect { keyword.reload }.to raise_error ActiveRecord::RecordNotFound
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,6 +36,8 @@ RSpec.describe 'Follow requests' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match_array(expected_response)
|
||||
end
|
||||
|
||||
|
@ -66,6 +68,8 @@ RSpec.describe 'Follow requests' do
|
|||
it 'allows the requesting follower to follow', :aggregate_failures do
|
||||
expect { subject }.to change { follower.following?(user.account) }.from(false).to(true)
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:followed_by]).to be true
|
||||
end
|
||||
end
|
||||
|
@ -87,6 +91,8 @@ RSpec.describe 'Follow requests' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(FollowRequest.where(target_account: user.account, account: follower)).to_not exist
|
||||
expect(response.parsed_body[:followed_by]).to be false
|
||||
end
|
||||
|
|
|
@ -28,29 +28,24 @@ RSpec.describe 'Followed tags' do
|
|||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write write:follows'
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success and includes followed tags' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
it 'returns the followed tags correctly' do
|
||||
subject
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match_array(expected_response)
|
||||
end
|
||||
|
||||
context 'with limit param' do
|
||||
let(:params) { { limit: 1 } }
|
||||
|
||||
it 'returns only the requested number of follow tags' do
|
||||
it 'returns only the requested number of follow tags and sets pagination headers' do
|
||||
subject
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to eq(params[:limit])
|
||||
end
|
||||
|
||||
it 'sets the correct pagination headers' do
|
||||
subject
|
||||
|
||||
expect(response)
|
||||
.to include_pagination_headers(
|
||||
|
|
|
@ -14,6 +14,8 @@ RSpec.describe 'Instances' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_present
|
||||
|
@ -27,6 +29,8 @@ RSpec.describe 'Instances' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_present
|
||||
|
|
|
@ -13,6 +13,9 @@ RSpec.describe 'Activity' do
|
|||
expect(response)
|
||||
.to have_http_status(200)
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_present
|
||||
.and(be_an(Array))
|
||||
|
|
|
@ -22,6 +22,9 @@ RSpec.describe 'Domain Blocks' do
|
|||
expect(response)
|
||||
.to have_http_status(200)
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_present
|
||||
.and(be_an(Array))
|
||||
|
|
|
@ -9,6 +9,8 @@ RSpec.describe 'Extended Descriptions' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_present
|
||||
|
|
|
@ -8,11 +8,10 @@ RSpec.describe 'Languages' do
|
|||
get '/api/v1/instance/languages'
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success and includes supported languages' do
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns the supported languages' do
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.pluck(:code)).to match_array LanguagesHelper::SUPPORTED_LOCALES.keys.map(&:to_s)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,6 +12,8 @@ RSpec.describe 'Peers' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Array)
|
||||
|
|
|
@ -9,6 +9,8 @@ RSpec.describe 'Privacy Policy' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_present
|
||||
|
|
|
@ -9,6 +9,8 @@ RSpec.describe 'Rules' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Array)
|
||||
|
|
|
@ -10,6 +10,8 @@ RSpec.describe 'Translation Languages' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to eq({})
|
||||
|
@ -24,6 +26,8 @@ RSpec.describe 'Translation Languages' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to match({ und: %w(en de), en: ['de'] })
|
||||
|
|
|
@ -34,6 +34,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match_array(expected_response)
|
||||
end
|
||||
|
||||
|
@ -68,6 +70,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(list.accounts).to include(bob)
|
||||
end
|
||||
end
|
||||
|
@ -81,6 +85,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(list.accounts).to include(bob)
|
||||
end
|
||||
end
|
||||
|
@ -90,6 +96,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(list.accounts).to_not include(bob)
|
||||
end
|
||||
end
|
||||
|
@ -105,6 +113,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -118,6 +128,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -139,16 +151,13 @@ RSpec.describe 'Accounts' do
|
|||
list.accounts << [bob, peter]
|
||||
end
|
||||
|
||||
it 'removes the specified account from the list', :aggregate_failures do
|
||||
it 'removes the specified account from the list but keeps other accounts in the list', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(list.accounts).to_not include(bob)
|
||||
end
|
||||
|
||||
it 'does not remove any other account from the list' do
|
||||
subject
|
||||
|
||||
expect(list.accounts).to include(peter)
|
||||
end
|
||||
|
||||
|
@ -159,6 +168,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(list.accounts).to contain_exactly(bob, peter)
|
||||
end
|
||||
end
|
||||
|
@ -172,6 +183,8 @@ RSpec.describe 'Accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,6 +46,8 @@ RSpec.describe 'Lists' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match_array(expected_response)
|
||||
end
|
||||
end
|
||||
|
@ -63,6 +65,8 @@ RSpec.describe 'Lists' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match({
|
||||
id: list.id.to_s,
|
||||
title: list.title,
|
||||
|
@ -80,6 +84,8 @@ RSpec.describe 'Lists' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -88,6 +94,8 @@ RSpec.describe 'Lists' do
|
|||
get '/api/v1/lists/-1', headers: headers
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -105,6 +113,8 @@ RSpec.describe 'Lists' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match(a_hash_including(title: 'my list', replies_policy: 'none', exclusive: true))
|
||||
expect(List.where(account: user.account).count).to eq(1)
|
||||
end
|
||||
|
@ -116,6 +126,8 @@ RSpec.describe 'Lists' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -126,6 +138,8 @@ RSpec.describe 'Lists' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -147,6 +161,8 @@ RSpec.describe 'Lists' do
|
|||
.and change_list_exclusive
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
list.reload
|
||||
|
||||
expect(response.parsed_body).to match({
|
||||
|
@ -176,6 +192,8 @@ RSpec.describe 'Lists' do
|
|||
put '/api/v1/lists/-1', headers: headers, params: params
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -186,6 +204,8 @@ RSpec.describe 'Lists' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -203,6 +223,8 @@ RSpec.describe 'Lists' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(List.where(id: list.id)).to_not exist
|
||||
end
|
||||
|
||||
|
@ -221,6 +243,8 @@ RSpec.describe 'Lists' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,8 @@ RSpec.describe 'API Markers' do
|
|||
|
||||
it 'returns markers', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
home: include(last_read_id: '123'),
|
||||
|
@ -34,6 +36,8 @@ RSpec.describe 'API Markers' do
|
|||
|
||||
it 'creates a marker', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(user.markers.first.timeline).to eq 'home'
|
||||
expect(user.markers.first.last_read_id).to eq 69_420
|
||||
end
|
||||
|
@ -47,6 +51,8 @@ RSpec.describe 'API Markers' do
|
|||
|
||||
it 'updates a marker', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(user.markers.first.timeline).to eq 'home'
|
||||
expect(user.markers.first.last_read_id).to eq 70_120
|
||||
end
|
||||
|
@ -61,6 +67,8 @@ RSpec.describe 'API Markers' do
|
|||
it 'returns error json' do
|
||||
expect(response)
|
||||
.to have_http_status(409)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to include(error: /Conflict during update/)
|
||||
end
|
||||
|
|
|
@ -17,15 +17,12 @@ RSpec.describe 'Media' do
|
|||
|
||||
it_behaves_like 'forbidden for wrong scope', 'read'
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success with media information' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns the media information' do
|
||||
subject
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match(
|
||||
a_hash_including(
|
||||
id: media.id.to_s,
|
||||
|
@ -44,6 +41,8 @@ RSpec.describe 'Media' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(206)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -54,6 +53,8 @@ RSpec.describe 'Media' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -64,6 +65,8 @@ RSpec.describe 'Media' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -80,6 +83,8 @@ RSpec.describe 'Media' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(MediaAttachment.first).to be_present
|
||||
expect(MediaAttachment.first).to have_attached_file(:file)
|
||||
|
||||
|
@ -107,6 +112,8 @@ RSpec.describe 'Media' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -117,6 +124,8 @@ RSpec.describe 'Media' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(500)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -158,6 +167,8 @@ RSpec.describe 'Media' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -176,6 +187,8 @@ RSpec.describe 'Media' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,32 +18,26 @@ RSpec.describe 'Mutes' do
|
|||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write write:mutes'
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success with muted accounts' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns the muted accounts' do
|
||||
subject
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
muted_accounts = mutes.map(&:target_account)
|
||||
|
||||
expect(response.parsed_body.pluck(:id)).to match_array(muted_accounts.map { |account| account.id.to_s })
|
||||
end
|
||||
|
||||
context 'with limit param' do
|
||||
let(:params) { { limit: 1 } }
|
||||
|
||||
it 'returns only the requested number of muted accounts' do
|
||||
it 'returns only the requested number of muted accounts with pagination headers' do
|
||||
subject
|
||||
|
||||
expect(response.parsed_body.size).to eq(params[:limit])
|
||||
end
|
||||
|
||||
it 'sets the correct pagination headers', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response)
|
||||
.to include_pagination_headers(
|
||||
prev: api_v1_mutes_url(limit: params[:limit], since_id: mutes.last.id),
|
||||
|
@ -81,6 +75,8 @@ RSpec.describe 'Mutes' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,6 +26,8 @@ RSpec.describe 'Policies' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to include(
|
||||
filter_not_following: false,
|
||||
filter_not_followers: false,
|
||||
|
@ -54,6 +56,8 @@ RSpec.describe 'Policies' do
|
|||
.to change { NotificationPolicy.find_or_initialize_by(account: user.account).for_not_following.to_sym }.from(:accept).to(:filter)
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to include(
|
||||
filter_not_following: true,
|
||||
filter_not_followers: false,
|
||||
|
|
|
@ -26,6 +26,8 @@ RSpec.describe 'Requests' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -39,15 +41,12 @@ RSpec.describe 'Requests' do
|
|||
|
||||
it_behaves_like 'forbidden for wrong scope', 'read read:notifications'
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success and creates notification permission' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'creates notification permission' do
|
||||
subject
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(NotificationPermission.find_by(account: notification_request.account, from_account: notification_request.from_account)).to_not be_nil
|
||||
end
|
||||
|
||||
|
@ -58,6 +57,8 @@ RSpec.describe 'Requests' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -75,6 +76,8 @@ RSpec.describe 'Requests' do
|
|||
expect { subject }.to change(NotificationRequest, :count).by(-1)
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
|
||||
context 'when notification request belongs to someone else' do
|
||||
|
@ -84,6 +87,8 @@ RSpec.describe 'Requests' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -102,6 +107,8 @@ RSpec.describe 'Requests' do
|
|||
|
||||
expect(NotificationPermission.find_by(account: notification_request.account, from_account: notification_request.from_account)).to_not be_nil
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -118,6 +125,8 @@ RSpec.describe 'Requests' do
|
|||
expect { subject }.to change(NotificationRequest, :count).by(-1)
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -133,6 +142,8 @@ RSpec.describe 'Requests' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match({ merged: true })
|
||||
end
|
||||
end
|
||||
|
@ -146,6 +157,8 @@ RSpec.describe 'Requests' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match({ merged: false })
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,6 +31,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:count]).to eq 5
|
||||
end
|
||||
end
|
||||
|
@ -45,6 +47,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:count]).to eq 2
|
||||
end
|
||||
end
|
||||
|
@ -56,6 +60,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:count]).to eq 4
|
||||
end
|
||||
end
|
||||
|
@ -67,6 +73,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:count]).to eq 2
|
||||
end
|
||||
end
|
||||
|
@ -80,6 +88,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:count]).to eq Api::V1::NotificationsController::DEFAULT_NOTIFICATIONS_COUNT_LIMIT
|
||||
end
|
||||
end
|
||||
|
@ -111,6 +121,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to eq 5
|
||||
expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow')
|
||||
expect(response.parsed_body.any? { |x| x[:filtered] }).to be false
|
||||
|
@ -124,6 +136,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to eq 6
|
||||
expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow')
|
||||
expect(response.parsed_body.any? { |x| x[:filtered] }).to be true
|
||||
|
@ -137,6 +151,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(body_json_account_ids.uniq).to eq [tom.account.id.to_s]
|
||||
end
|
||||
|
||||
|
@ -152,6 +168,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to eq 0
|
||||
end
|
||||
end
|
||||
|
@ -163,6 +181,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to_not eq 0
|
||||
expect(body_json_types.uniq).to_not include 'mention'
|
||||
end
|
||||
|
@ -175,6 +195,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(body_json_types.uniq).to eq ['mention']
|
||||
end
|
||||
end
|
||||
|
@ -216,6 +238,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
|
||||
context 'when notification belongs to someone else' do
|
||||
|
@ -225,6 +249,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -242,6 +268,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect { notification.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
|
@ -252,6 +280,8 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -272,6 +302,8 @@ RSpec.describe 'Notifications' do
|
|||
|
||||
expect(user.account.reload.notifications).to be_empty
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,6 +23,8 @@ RSpec.describe 'API Peers Search' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to be_blank
|
||||
end
|
||||
|
@ -34,6 +36,8 @@ RSpec.describe 'API Peers Search' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to be_blank
|
||||
end
|
||||
|
@ -49,10 +53,12 @@ RSpec.describe 'API Peers Search' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.parsed_body.size)
|
||||
.to eq(1)
|
||||
expect(response.parsed_body.first)
|
||||
.to eq(account.domain)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
eq(account.domain)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,8 @@ RSpec.describe 'API V1 Polls Votes' do
|
|||
|
||||
it 'creates a vote', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(vote).to_not be_nil
|
||||
expect(vote.choice).to eq 1
|
||||
|
@ -30,6 +32,8 @@ RSpec.describe 'API V1 Polls Votes' do
|
|||
|
||||
it 'returns http bad request' do
|
||||
expect(response).to have_http_status(400)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ RSpec.describe 'Polls' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match(
|
||||
a_hash_including(
|
||||
id: poll.id.to_s,
|
||||
|
@ -41,6 +43,8 @@ RSpec.describe 'Polls' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ RSpec.describe 'Preferences' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -34,6 +36,9 @@ RSpec.describe 'Preferences' do
|
|||
expect(response)
|
||||
.to have_http_status(200)
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_present
|
||||
end
|
||||
|
|
|
@ -28,31 +28,16 @@ RSpec.describe 'Deleting profile images' do
|
|||
it_behaves_like 'forbidden for wrong scope', 'read'
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success and deletes the avatar, preserves the header, queues up distribution' do
|
||||
delete '/api/v1/profile/avatar', headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'deletes the avatar' do
|
||||
delete '/api/v1/profile/avatar', headers: headers
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
account.reload
|
||||
|
||||
expect(account.avatar).to_not exist
|
||||
end
|
||||
|
||||
it 'does not delete the header' do
|
||||
delete '/api/v1/profile/avatar', headers: headers
|
||||
|
||||
account.reload
|
||||
|
||||
expect(account.header).to exist
|
||||
end
|
||||
|
||||
it 'queues up an account update distribution' do
|
||||
delete '/api/v1/profile/avatar', headers: headers
|
||||
|
||||
expect(ActivityPub::UpdateDistributionWorker).to have_received(:perform_async).with(account.id)
|
||||
end
|
||||
end
|
||||
|
@ -66,31 +51,16 @@ RSpec.describe 'Deleting profile images' do
|
|||
it_behaves_like 'forbidden for wrong scope', 'read'
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
it 'returns http success, preserves the avatar, deletes the header, queues up distribution' do
|
||||
delete '/api/v1/profile/header', headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'does not delete the avatar' do
|
||||
delete '/api/v1/profile/header', headers: headers
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
account.reload
|
||||
|
||||
expect(account.avatar).to exist
|
||||
end
|
||||
|
||||
it 'deletes the header' do
|
||||
delete '/api/v1/profile/header', headers: headers
|
||||
|
||||
account.reload
|
||||
|
||||
expect(account.header).to_not exist
|
||||
end
|
||||
|
||||
it 'queues up an account update distribution' do
|
||||
delete '/api/v1/profile/header', headers: headers
|
||||
|
||||
expect(ActivityPub::UpdateDistributionWorker).to have_received(:perform_async).with(account.id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,6 +45,8 @@ RSpec.describe 'API V1 Push Subscriptions' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(endpoint_push_subscriptions.count).to eq(0)
|
||||
expect(endpoint_push_subscription).to be_nil
|
||||
end
|
||||
|
|
|
@ -37,6 +37,8 @@ RSpec.describe 'Reports' do
|
|||
emails = capture_emails { subject }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to match(
|
||||
a_hash_including(
|
||||
status_ids: [status.id.to_s],
|
||||
|
@ -65,6 +67,8 @@ RSpec.describe 'Reports' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue