Merge remote-tracking branch 'parent/main' into upstream-20240906
This commit is contained in:
commit
f18eabfe75
689 changed files with 4369 additions and 2434 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'The account show page' do
|
||||
RSpec.describe 'The account show page' do
|
||||
it 'has valid opengraph tags' do
|
||||
alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
|
||||
_status = Fabricate(:status, account: alice, text: 'Hello World')
|
||||
|
@ -14,18 +14,20 @@ describe 'The account show page' do
|
|||
expect(head_meta_content('og:title')).to match alice.display_name
|
||||
expect(head_meta_content('og:type')).to eq 'profile'
|
||||
expect(head_meta_content('og:image')).to match '.+'
|
||||
expect(head_meta_content('og:url')).to match 'http://.+'
|
||||
expect(head_meta_content('og:url')).to eq short_account_url(username: alice.username)
|
||||
end
|
||||
|
||||
def head_link_icons
|
||||
head_section.css('link[rel=icon]')
|
||||
response
|
||||
.parsed_body
|
||||
.search('html head link[rel=icon]')
|
||||
end
|
||||
|
||||
def head_meta_content(property)
|
||||
head_section.meta("[@property='#{property}']")[:content]
|
||||
end
|
||||
|
||||
def head_section
|
||||
Nokogiri::Slop(response.body).html.head
|
||||
response
|
||||
.parsed_body
|
||||
.search("html head meta[property='#{property}']")
|
||||
.attr('content')
|
||||
.text
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Accounts show response' do
|
||||
RSpec.describe 'Accounts show response' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
context 'with an unapproved account' do
|
||||
|
@ -69,8 +69,7 @@ describe 'Accounts show response' do
|
|||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and render_template(:show)
|
||||
|
||||
expect(response.headers['Link'].to_s).to include ActivityPub::TagManager.instance.uri_for(account)
|
||||
.and have_http_link_header(ActivityPub::TagManager.instance.uri_for(account)).for(rel: 'alternate')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -130,6 +129,7 @@ describe 'Accounts show response' do
|
|||
it 'returns a JSON version of the account', :aggregate_failures do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
||||
.and have_attributes(
|
||||
media_type: eq('application/activity+json')
|
||||
)
|
||||
|
@ -137,8 +137,6 @@ describe 'Accounts show response' do
|
|||
expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
||||
|
||||
context 'with authorized fetch mode' do
|
||||
let(:authorized_fetch_mode) { true }
|
||||
|
||||
|
@ -179,6 +177,7 @@ describe 'Accounts show response' do
|
|||
it 'returns a JSON version of the account', :aggregate_failures do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
||||
.and have_attributes(
|
||||
media_type: eq('application/activity+json')
|
||||
)
|
||||
|
@ -186,8 +185,6 @@ describe 'Accounts show response' do
|
|||
expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
||||
|
||||
context 'with authorized fetch mode' do
|
||||
let(:authorized_fetch_mode) { true }
|
||||
|
||||
|
@ -215,10 +212,10 @@ describe 'Accounts show response' do
|
|||
get short_account_path(username: account.username, format: format)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
||||
|
||||
it 'responds with correct statuses', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
||||
expect(response.body).to include(status_tag_for(status_media))
|
||||
expect(response.body).to include(status_tag_for(status_self_reply))
|
||||
expect(response.body).to include(status_tag_for(status))
|
||||
|
@ -234,10 +231,11 @@ describe 'Accounts show response' do
|
|||
get short_account_with_replies_path(username: account.username, format: format)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
||||
|
||||
it 'responds with correct statuses with replies', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
||||
|
||||
expect(response.body).to include(status_tag_for(status_media))
|
||||
expect(response.body).to include(status_tag_for(status_reply))
|
||||
expect(response.body).to include(status_tag_for(status_self_reply))
|
||||
|
@ -253,10 +251,10 @@ describe 'Accounts show response' do
|
|||
get short_account_media_path(username: account.username, format: format)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
||||
|
||||
it 'responds with correct statuses with media', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
||||
expect(response.body).to include(status_tag_for(status_media))
|
||||
expect(response.body).to_not include(status_tag_for(status_direct))
|
||||
expect(response.body).to_not include(status_tag_for(status_private))
|
||||
|
@ -277,10 +275,11 @@ describe 'Accounts show response' do
|
|||
get short_account_tag_path(username: account.username, tag: tag, format: format)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
||||
|
||||
it 'responds with correct statuses with a tag', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
||||
|
||||
expect(response.body).to include(status_tag_for(status_tag))
|
||||
expect(response.body).to_not include(status_tag_for(status_direct))
|
||||
expect(response.body).to_not include(status_tag_for(status_media))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Anonymous visits' do
|
||||
RSpec.describe 'Anonymous visits' do
|
||||
around do |example|
|
||||
old = ActionController::Base.allow_forgery_protection
|
||||
ActionController::Base.allow_forgery_protection = true
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Accounts Familiar Followers API' do
|
||||
RSpec.describe 'Accounts Familiar Followers API' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read:follows' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API V1 Accounts FollowerAccounts' do
|
||||
RSpec.describe 'API V1 Accounts FollowerAccounts' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read:accounts' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API V1 Accounts FollowingAccounts' do
|
||||
RSpec.describe 'API V1 Accounts FollowingAccounts' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read:accounts' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Accounts Identity Proofs API' do
|
||||
RSpec.describe 'Accounts Identity Proofs API' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read:accounts' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Accounts Lists API' do
|
||||
RSpec.describe 'Accounts Lists API' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read:lists' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Accounts Lookup API' do
|
||||
RSpec.describe 'Accounts Lookup API' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read:accounts' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Accounts Notes API' do
|
||||
RSpec.describe 'Accounts Notes API' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'write:accounts' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Accounts Pins API' do
|
||||
RSpec.describe 'Accounts Pins API' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'write:accounts' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'GET /api/v1/accounts/relationships' do
|
||||
RSpec.describe 'GET /api/v1/accounts/relationships' do
|
||||
subject do
|
||||
get '/api/v1/accounts/relationships', headers: headers, params: params
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Accounts Search API' do
|
||||
RSpec.describe 'Accounts Search API' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read:accounts' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API V1 Accounts Statuses' do
|
||||
RSpec.describe 'API V1 Accounts Statuses' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:scopes) { 'read:statuses' }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe '/api/v1/accounts' do
|
||||
RSpec.describe '/api/v1/accounts' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:scopes) { '' }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
|
@ -122,10 +122,11 @@ describe '/api/v1/accounts' do
|
|||
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
json = body_as_json
|
||||
|
||||
expect(json[:following]).to be true
|
||||
expect(json[:requested]).to be false
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
following: true,
|
||||
requested: false
|
||||
)
|
||||
|
||||
expect(user.account.following?(other_account)).to be true
|
||||
end
|
||||
|
@ -141,10 +142,11 @@ describe '/api/v1/accounts' do
|
|||
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
json = body_as_json
|
||||
|
||||
expect(json[:following]).to be false
|
||||
expect(json[:requested]).to be true
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
following: false,
|
||||
requested: true
|
||||
)
|
||||
|
||||
expect(user.account.requested?(other_account)).to be true
|
||||
end
|
||||
|
|
|
@ -96,10 +96,11 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
json = body_as_json
|
||||
|
||||
expect(json[:id]).to eq(canonical_email_block.id.to_s)
|
||||
expect(json[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
id: eq(canonical_email_block.id.to_s),
|
||||
canonical_email_hash: eq(canonical_email_block.canonical_email_hash)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin Dimensions' do
|
||||
RSpec.describe 'Admin Dimensions' do
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
|
|
@ -126,7 +126,7 @@ RSpec.describe 'Domain Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json).to eq(
|
||||
expect(body_as_json).to match(
|
||||
{
|
||||
id: domain_block.id.to_s,
|
||||
domain: domain_block.domain,
|
||||
|
@ -174,10 +174,8 @@ RSpec.describe 'Domain Blocks' do
|
|||
it 'creates a domain block with the expected domain name and severity', :aggregate_failures do
|
||||
subject
|
||||
|
||||
body = body_as_json
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body).to match a_hash_including(
|
||||
expect(body_as_json).to match a_hash_including(
|
||||
{
|
||||
domain: 'foo.bar.com',
|
||||
severity: 'silence',
|
||||
|
@ -197,10 +195,8 @@ RSpec.describe 'Domain Blocks' do
|
|||
it 'creates a domain block with the expected domain name and severity', :aggregate_failures do
|
||||
subject
|
||||
|
||||
body = body_as_json
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body).to match a_hash_including(
|
||||
expect(body_as_json).to match a_hash_including(
|
||||
{
|
||||
domain: 'foo.bar.com',
|
||||
severity: 'suspend',
|
||||
|
|
|
@ -88,10 +88,12 @@ RSpec.describe 'IP Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
json = body_as_json
|
||||
|
||||
expect(json[:ip]).to eq("#{ip_block.ip}/#{ip_block.ip.prefix}")
|
||||
expect(json[:severity]).to eq(ip_block.severity.to_s)
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
ip: eq("#{ip_block.ip}/#{ip_block.ip.prefix}"),
|
||||
severity: eq(ip_block.severity.to_s)
|
||||
)
|
||||
end
|
||||
|
||||
context 'when ip block does not exist' do
|
||||
|
@ -118,11 +120,12 @@ RSpec.describe 'IP Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
json = body_as_json
|
||||
|
||||
expect(json[:ip]).to eq("#{params[:ip]}/32")
|
||||
expect(json[:severity]).to eq(params[:severity])
|
||||
expect(json[:comment]).to eq(params[:comment])
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
ip: eq("#{params[:ip]}/32"),
|
||||
severity: eq(params[:severity]),
|
||||
comment: eq(params[:comment])
|
||||
)
|
||||
end
|
||||
|
||||
context 'when the required ip param is not provided' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin Measures' do
|
||||
RSpec.describe 'Admin Measures' do
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Admin Retention' do
|
||||
RSpec.describe 'Admin Retention' do
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Links' do
|
||||
RSpec.describe 'Links' do
|
||||
let(:role) { UserRole.find_by(name: 'Admin') }
|
||||
let(:user) { Fabricate(:user, role: role) }
|
||||
let(:scopes) { 'admin:read admin:write' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API V1 Admin Trends Links Preview Card Providers' do
|
||||
RSpec.describe 'API V1 Admin Trends Links Preview Card Providers' do
|
||||
let(:role) { UserRole.find_by(name: 'Admin') }
|
||||
let(:user) { Fabricate(:user, role: role) }
|
||||
let(:scopes) { 'admin:read admin:write' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API V1 Admin Trends Statuses' do
|
||||
RSpec.describe 'API V1 Admin Trends Statuses' do
|
||||
let(:role) { UserRole.find_by(name: 'Admin') }
|
||||
let(:user) { Fabricate(:user, role: role) }
|
||||
let(:scopes) { 'admin:read admin:write' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API V1 Admin Trends Tags' do
|
||||
RSpec.describe 'API V1 Admin Trends Tags' do
|
||||
let(:role) { UserRole.find_by(name: 'Admin') }
|
||||
let(:user) { Fabricate(:user, role: role) }
|
||||
let(:scopes) { 'admin:read admin:write' }
|
||||
|
|
57
spec/requests/api/v1/annual_reports_spec.rb
Normal file
57
spec/requests/api/v1/annual_reports_spec.rb
Normal file
|
@ -0,0 +1,57 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'API V1 Annual Reports' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
||||
describe 'GET /api/v1/annual_reports' do
|
||||
context 'when not authorized' do
|
||||
it 'returns http unauthorized' do
|
||||
get api_v1_annual_reports_path
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(401)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with wrong scope' do
|
||||
before do
|
||||
get api_v1_annual_reports_path, headers: headers
|
||||
end
|
||||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write write:accounts'
|
||||
end
|
||||
|
||||
context 'with correct scope' do
|
||||
let(:scopes) { 'read:accounts' }
|
||||
|
||||
it 'returns http success' do
|
||||
get api_v1_annual_reports_path, headers: headers
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
|
||||
expect(body_as_json)
|
||||
.to be_present
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST /api/v1/annual_reports/:id/read' do
|
||||
context 'with correct scope' do
|
||||
let(:scopes) { 'write:accounts' }
|
||||
|
||||
it 'returns success and marks the report as read' do
|
||||
annual_report = Fabricate :generated_annual_report, account: user.account
|
||||
|
||||
expect { post read_api_v1_annual_report_path(id: annual_report.year), headers: headers }
|
||||
.to change { annual_report.reload.viewed? }.to(true)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Credentials' do
|
||||
RSpec.describe 'Credentials' do
|
||||
describe 'GET /api/v1/apps/verify_credentials' do
|
||||
subject do
|
||||
get '/api/v1/apps/verify_credentials', headers: headers
|
||||
|
|
|
@ -61,9 +61,10 @@ RSpec.describe 'Apps' do
|
|||
expect(response).to have_http_status(200)
|
||||
expect(Doorkeeper::Application.find_by(name: client_name)).to be_present
|
||||
|
||||
body = body_as_json
|
||||
|
||||
expect(body[:scopes]).to eq Doorkeeper.config.default_scopes.to_a
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
scopes: Doorkeeper.config.default_scopes.to_a
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -81,9 +82,10 @@ RSpec.describe 'Apps' do
|
|||
expect(app).to be_present
|
||||
expect(app.scopes.to_s).to eq 'read'
|
||||
|
||||
body = body_as_json
|
||||
|
||||
expect(body[:scopes]).to eq ['read']
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
scopes: %w(read)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -163,10 +165,11 @@ RSpec.describe 'Apps' do
|
|||
expect(app.redirect_uri).to eq redirect_uris
|
||||
expect(app.redirect_uris).to eq redirect_uris.split
|
||||
|
||||
body = body_as_json
|
||||
|
||||
expect(body[:redirect_uri]).to eq redirect_uris
|
||||
expect(body[:redirect_uris]).to eq redirect_uris.split
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
redirect_uri: redirect_uris,
|
||||
redirect_uris: redirect_uris.split
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -184,10 +187,11 @@ RSpec.describe 'Apps' do
|
|||
expect(app.redirect_uri).to eq redirect_uris.join "\n"
|
||||
expect(app.redirect_uris).to eq redirect_uris
|
||||
|
||||
body = body_as_json
|
||||
|
||||
expect(body[:redirect_uri]).to eq redirect_uris.join "\n"
|
||||
expect(body[:redirect_uris]).to eq redirect_uris
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
redirect_uri: redirect_uris.join("\n"),
|
||||
redirect_uris: redirect_uris
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -55,10 +55,8 @@ RSpec.describe 'Blocks' do
|
|||
it 'queries the blocks in range according to max_id', :aggregate_failures do
|
||||
subject
|
||||
|
||||
response_body = body_as_json
|
||||
|
||||
expect(response_body.size).to be 1
|
||||
expect(response_body[0][:id]).to eq(blocks[0].target_account.id.to_s)
|
||||
expect(body_as_json)
|
||||
.to contain_exactly(include(id: blocks.first.target_account.id.to_s))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -68,10 +66,8 @@ RSpec.describe 'Blocks' do
|
|||
it 'queries the blocks in range according to since_id', :aggregate_failures do
|
||||
subject
|
||||
|
||||
response_body = body_as_json
|
||||
|
||||
expect(response_body.size).to be 1
|
||||
expect(response_body[0][:id]).to eq(blocks[2].target_account.id.to_s)
|
||||
expect(body_as_json)
|
||||
.to contain_exactly(include(id: blocks[2].target_account.id.to_s))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API namespace minimal Content-Security-Policy' do
|
||||
RSpec.describe 'API namespace minimal Content-Security-Policy' do
|
||||
before { stub_tests_controller }
|
||||
|
||||
after { Rails.application.reload_routes! }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Custom Emojis' do
|
||||
RSpec.describe 'Custom Emojis' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Directories API' do
|
||||
RSpec.describe 'Directories API' do
|
||||
let(:user) { Fabricate(:user, confirmed_at: nil) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read:follows' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Endorsements' do
|
||||
RSpec.describe 'Endorsements' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Featured Tags Suggestions API' do
|
||||
RSpec.describe 'Featured Tags Suggestions API' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read:accounts' }
|
||||
|
|
|
@ -37,9 +37,7 @@ RSpec.describe 'FeaturedTags' do
|
|||
it 'returns an empty body' do
|
||||
get '/api/v1/featured_tags', headers: headers
|
||||
|
||||
body = body_as_json
|
||||
|
||||
expect(body).to be_empty
|
||||
expect(body_as_json).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -49,10 +47,10 @@ RSpec.describe 'FeaturedTags' do
|
|||
it 'returns only the featured tags belonging to the requesting user' do
|
||||
get '/api/v1/featured_tags', headers: headers
|
||||
|
||||
body = body_as_json
|
||||
expected_ids = user_featured_tags.pluck(:id).map(&:to_s)
|
||||
|
||||
expect(body.pluck(:id)).to match_array(expected_ids)
|
||||
expect(body_as_json.pluck(:id))
|
||||
.to match_array(
|
||||
user_featured_tags.pluck(:id).map(&:to_s)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -69,9 +67,10 @@ RSpec.describe 'FeaturedTags' do
|
|||
it 'returns the correct tag name' do
|
||||
post '/api/v1/featured_tags', headers: headers, params: params
|
||||
|
||||
body = body_as_json
|
||||
|
||||
expect(body[:name]).to eq(params[:name])
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
name: params[:name]
|
||||
)
|
||||
end
|
||||
|
||||
it 'creates a new featured tag for the requesting user' do
|
||||
|
@ -142,9 +141,7 @@ RSpec.describe 'FeaturedTags' do
|
|||
it 'returns an empty body' do
|
||||
delete "/api/v1/featured_tags/#{id}", headers: headers
|
||||
|
||||
body = body_as_json
|
||||
|
||||
expect(body).to be_empty
|
||||
expect(body_as_json).to be_empty
|
||||
end
|
||||
|
||||
it 'deletes the featured tag', :inline_jobs do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Instances' do
|
||||
RSpec.describe 'Instances' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Translation Languages' do
|
||||
RSpec.describe 'Translation Languages' do
|
||||
describe 'GET /api/v1/instances/translation_languages' do
|
||||
context 'when no translation service is configured' do
|
||||
it 'returns empty language matrix', :aggregate_failures do
|
||||
|
@ -26,7 +26,7 @@ describe 'Translation Languages' do
|
|||
.to have_http_status(200)
|
||||
|
||||
expect(body_as_json)
|
||||
.to eq({ und: %w(en de), en: ['de'] })
|
||||
.to match({ und: %w(en de), en: ['de'] })
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -63,7 +63,7 @@ RSpec.describe 'Lists' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json).to eq({
|
||||
expect(body_as_json).to match({
|
||||
id: list.id.to_s,
|
||||
title: list.title,
|
||||
replies_policy: list.replies_policy,
|
||||
|
@ -149,7 +149,7 @@ RSpec.describe 'Lists' do
|
|||
expect(response).to have_http_status(200)
|
||||
list.reload
|
||||
|
||||
expect(body_as_json).to eq({
|
||||
expect(body_as_json).to match({
|
||||
id: list.id.to_s,
|
||||
title: list.title,
|
||||
replies_policy: list.replies_policy,
|
||||
|
|
|
@ -17,13 +17,12 @@ RSpec.describe 'API Markers' do
|
|||
end
|
||||
|
||||
it 'returns markers', :aggregate_failures do
|
||||
json = body_as_json
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(json.key?(:home)).to be true
|
||||
expect(json[:home][:last_read_id]).to eq '123'
|
||||
expect(json.key?(:notifications)).to be true
|
||||
expect(json[:notifications][:last_read_id]).to eq '456'
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
home: include(last_read_id: '123'),
|
||||
notifications: include(last_read_id: '456')
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -58,10 +58,8 @@ RSpec.describe 'Mutes' do
|
|||
it 'queries mutes in range according to max_id', :aggregate_failures do
|
||||
subject
|
||||
|
||||
body = body_as_json
|
||||
|
||||
expect(body.size).to eq 1
|
||||
expect(body[0][:id]).to eq mutes[0].target_account_id.to_s
|
||||
expect(body_as_json)
|
||||
.to contain_exactly(include(id: mutes.first.target_account_id.to_s))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -71,10 +69,8 @@ RSpec.describe 'Mutes' do
|
|||
it 'queries mutes in range according to since_id', :aggregate_failures do
|
||||
subject
|
||||
|
||||
body = body_as_json
|
||||
|
||||
expect(body.size).to eq 1
|
||||
expect(body[0][:id]).to eq mutes[1].target_account_id.to_s
|
||||
expect(body_as_json)
|
||||
.to contain_exactly(include(id: mutes[1].target_account_id.to_s))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ RSpec.describe 'Requests' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json).to eq({ merged: true })
|
||||
expect(body_as_json).to match({ merged: true })
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -146,7 +146,7 @@ RSpec.describe 'Requests' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json).to eq({ merged: false })
|
||||
expect(body_as_json).to match({ merged: false })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API Peers Search' do
|
||||
RSpec.describe 'API Peers Search' do
|
||||
describe 'GET /api/v1/peers/search' do
|
||||
context 'when peers api is disabled' do
|
||||
before do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Preferences' do
|
||||
RSpec.describe 'Preferences' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API V1 Push Subscriptions' do
|
||||
RSpec.describe 'API V1 Push Subscriptions' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:endpoint) { 'https://fcm.googleapis.com/fcm/send/fiuH06a27qE:APA91bHnSiGcLwdaxdyqVXNDR9w1NlztsHb6lyt5WDKOC_Z_Q8BlFxQoR8tWFSXUIDdkyw0EdvxTu63iqamSaqVSevW5LfoFwojws8XYDXv_NRRLH6vo2CdgiN4jgHv5VLt2A8ah6lUX' }
|
||||
let(:keys) do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Scheduled Statuses' do
|
||||
RSpec.describe 'Scheduled Statuses' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API V1 Statuses Histories' do
|
||||
RSpec.describe 'API V1 Statuses Histories' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read:statuses' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API V1 Statuses Mutes' do
|
||||
RSpec.describe 'API V1 Statuses Mutes' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'write:mutes' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Pins' do
|
||||
RSpec.describe 'Pins' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:scopes) { 'write:accounts' }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API V1 Statuses Reblogs' do
|
||||
RSpec.describe 'API V1 Statuses Reblogs' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'write:statuses' }
|
||||
|
@ -24,11 +24,14 @@ describe 'API V1 Statuses Reblogs' do
|
|||
|
||||
expect(user.account.reblogged?(status)).to be true
|
||||
|
||||
hash_body = body_as_json
|
||||
|
||||
expect(hash_body[:reblog][:id]).to eq status.id.to_s
|
||||
expect(hash_body[:reblog][:reblogs_count]).to eq 1
|
||||
expect(hash_body[:reblog][:reblogged]).to be true
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
reblog: include(
|
||||
id: status.id.to_s,
|
||||
reblogs_count: 1,
|
||||
reblogged: true
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -57,11 +60,12 @@ describe 'API V1 Statuses Reblogs' do
|
|||
|
||||
expect(user.account.reblogged?(status)).to be false
|
||||
|
||||
hash_body = body_as_json
|
||||
|
||||
expect(hash_body[:id]).to eq status.id.to_s
|
||||
expect(hash_body[:reblogs_count]).to eq 0
|
||||
expect(hash_body[:reblogged]).to be false
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
id: status.id.to_s,
|
||||
reblogs_count: 0,
|
||||
reblogged: false
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -81,11 +85,12 @@ describe 'API V1 Statuses Reblogs' do
|
|||
|
||||
expect(user.account.reblogged?(status)).to be false
|
||||
|
||||
hash_body = body_as_json
|
||||
|
||||
expect(hash_body[:id]).to eq status.id.to_s
|
||||
expect(hash_body[:reblogs_count]).to eq 0
|
||||
expect(hash_body[:reblogged]).to be false
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
id: status.id.to_s,
|
||||
reblogs_count: 0,
|
||||
reblogged: false
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ RSpec.describe 'Sources' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json).to eq({
|
||||
expect(body_as_json).to match({
|
||||
id: status.id.to_s,
|
||||
text: status.text,
|
||||
spoiler_text: status.spoiler_text,
|
||||
|
@ -51,7 +51,7 @@ RSpec.describe 'Sources' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json).to eq({
|
||||
expect(body_as_json).to match({
|
||||
id: status.id.to_s,
|
||||
text: status.text,
|
||||
spoiler_text: status.spoiler_text,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API V1 Statuses Translations' do
|
||||
RSpec.describe 'API V1 Statuses Translations' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read:statuses' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe '/api/v1/statuses' do
|
||||
RSpec.describe '/api/v1/statuses' do
|
||||
context 'with an oauth token' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:client_app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
||||
|
@ -243,7 +243,7 @@ describe '/api/v1/statuses' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(body_as_json[:unexpected_accounts].map { |a| a.slice(:id, :acct) }).to eq [{ id: bob.id.to_s, acct: bob.acct }]
|
||||
expect(body_as_json[:unexpected_accounts].map { |a| a.slice(:id, :acct) }).to match [{ id: bob.id.to_s, acct: bob.acct }]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API V1 Streaming' do
|
||||
RSpec.describe 'API V1 Streaming' do
|
||||
around do |example|
|
||||
before = Rails.configuration.x.streaming_api_base_url
|
||||
Rails.configuration.x.streaming_api_base_url = "wss://#{Rails.configuration.x.web_domain}"
|
||||
|
@ -10,12 +10,11 @@ describe 'API V1 Streaming' do
|
|||
Rails.configuration.x.streaming_api_base_url = before
|
||||
end
|
||||
|
||||
let(:headers) { { 'Host' => Rails.configuration.x.web_domain } }
|
||||
|
||||
context 'with streaming api on same host' do
|
||||
describe 'GET /api/v1/streaming' do
|
||||
it 'raises ActiveRecord::RecordNotFound' do
|
||||
get '/api/v1/streaming', headers: headers
|
||||
integration_session.https!(false)
|
||||
get '/api/v1/streaming'
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
end
|
||||
|
|
|
@ -32,10 +32,8 @@ RSpec.describe 'Suggestions' do
|
|||
it 'returns accounts' do
|
||||
subject
|
||||
|
||||
body = body_as_json
|
||||
|
||||
expect(body.size).to eq 2
|
||||
expect(body.pluck(:id)).to match_array([bob, jeff].map { |i| i.id.to_s })
|
||||
expect(body_as_json)
|
||||
.to contain_exactly(include(id: bob.id.to_s), include(id: jeff.id.to_s))
|
||||
end
|
||||
|
||||
context 'with limit param' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Home', :inline_jobs do
|
||||
RSpec.describe 'Home', :inline_jobs do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:scopes) { 'read:statuses' }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
|
@ -94,8 +94,9 @@ describe 'Home', :inline_jobs do
|
|||
it 'returns http unprocessable entity', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.headers['Link']).to be_nil
|
||||
expect(response)
|
||||
.to have_http_status(422)
|
||||
.and not_have_http_link_header
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Link' do
|
||||
RSpec.describe 'Link' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:scopes) { 'read:statuses' }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'API V1 Timelines List' do
|
||||
RSpec.describe 'API V1 Timelines List' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:scopes) { 'read:statuses' }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
|
@ -47,8 +47,9 @@ describe 'API V1 Timelines List' do
|
|||
it 'returns http unprocessable entity' do
|
||||
get "/api/v1/timelines/list/#{list.id}", headers: headers
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.headers['Link']).to be_nil
|
||||
expect(response)
|
||||
.to have_http_status(422)
|
||||
.and not_have_http_link_header
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Public' do
|
||||
RSpec.describe 'Public' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:scopes) { 'read:statuses' }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
|
|
|
@ -8,22 +8,25 @@ RSpec.describe 'Tag' do
|
|||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
||||
shared_examples 'a successful request to the tag timeline' do
|
||||
it 'returns the expected statuses', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json.pluck(:id)).to match_array(expected_statuses.map { |status| status.id.to_s })
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /api/v1/timelines/tag/:hashtag' do
|
||||
subject do
|
||||
get "/api/v1/timelines/tag/#{hashtag}", headers: headers, params: params
|
||||
end
|
||||
|
||||
shared_examples 'a successful request to the tag timeline' do
|
||||
it 'returns the expected statuses', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(body_as_json.pluck(:id))
|
||||
.to match_array(expected_statuses.map { |status| status.id.to_s })
|
||||
.and not_include(private_status.id)
|
||||
end
|
||||
end
|
||||
|
||||
let(:account) { Fabricate(:account) }
|
||||
let!(:private_status) { PostStatusService.new.call(account, visibility: :private, text: '#life could be a dream') } # rubocop:disable RSpec/LetSetup
|
||||
let!(:private_status) { PostStatusService.new.call(account, visibility: :private, text: '#life could be a dream') }
|
||||
let!(:life_status) { PostStatusService.new.call(account, text: 'tell me what is my #life without your #love') }
|
||||
let!(:war_status) { PostStatusService.new.call(user.account, text: '#war, war never changes') }
|
||||
let!(:love_status) { PostStatusService.new.call(account, text: 'what is #love?') }
|
||||
|
|
|
@ -42,9 +42,11 @@ RSpec.describe 'API V2 Filters Keywords' do
|
|||
it 'creates a filter', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
json = body_as_json
|
||||
expect(json[:keyword]).to eq 'magic'
|
||||
expect(json[:whole_word]).to be false
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
keyword: 'magic',
|
||||
whole_word: false
|
||||
)
|
||||
|
||||
filter = user.account.custom_filters.first
|
||||
expect(filter).to_not be_nil
|
||||
|
@ -71,9 +73,11 @@ RSpec.describe 'API V2 Filters Keywords' do
|
|||
it 'responds with the keyword', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
json = body_as_json
|
||||
expect(json[:keyword]).to eq 'foo'
|
||||
expect(json[:whole_word]).to be false
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
keyword: 'foo',
|
||||
whole_word: false
|
||||
)
|
||||
end
|
||||
|
||||
context "when trying to access another user's filter keyword" do
|
||||
|
|
|
@ -43,8 +43,10 @@ RSpec.describe 'API V2 Filters Statuses' do
|
|||
it 'creates a filter', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
json = body_as_json
|
||||
expect(json[:status_id]).to eq status.id.to_s
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
status_id: status.id.to_s
|
||||
)
|
||||
|
||||
filter = user.account.custom_filters.first
|
||||
expect(filter).to_not be_nil
|
||||
|
@ -71,8 +73,10 @@ RSpec.describe 'API V2 Filters Statuses' do
|
|||
it 'responds with the filter', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
json = body_as_json
|
||||
expect(json[:status_id]).to eq status_filter.status_id.to_s
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
status_id: status_filter.status.id.to_s
|
||||
)
|
||||
end
|
||||
|
||||
context "when trying to access another user's filter keyword" do
|
||||
|
|
|
@ -68,15 +68,18 @@ RSpec.describe 'Filters' do
|
|||
it 'returns a filter with keywords', :aggregate_failures do
|
||||
subject
|
||||
|
||||
json = body_as_json
|
||||
|
||||
expect(json[:title]).to eq 'magic'
|
||||
expect(json[:filter_action]).to eq 'hide'
|
||||
expect(json[:context]).to eq ['home']
|
||||
expect(json[:keywords].map { |keyword| keyword.slice(:keyword, :whole_word) }).to eq [{ keyword: 'magic', whole_word: true }]
|
||||
expect(json[:exclude_follows]).to be true
|
||||
expect(json[:exclude_localusers]).to be true
|
||||
expect(json[:with_profile]).to be true
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
title: 'magic',
|
||||
filter_action: 'hide',
|
||||
context: %w(home),
|
||||
keywords: contain_exactly(
|
||||
include(keyword: 'magic', whole_word: true)
|
||||
),
|
||||
exclude_follows: true,
|
||||
exclude_localusers: true,
|
||||
with_profile: true
|
||||
)
|
||||
end
|
||||
|
||||
it 'creates a filter', :aggregate_failures do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Instances' do
|
||||
RSpec.describe 'Instances' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Search API' do
|
||||
RSpec.describe 'Search API' do
|
||||
context 'with token' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Suggestions API' do
|
||||
RSpec.describe 'Suggestions API' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read' }
|
||||
|
|
80
spec/requests/api/v2_alpha/notifications/accounts_spec.rb
Normal file
80
spec/requests/api/v2_alpha/notifications/accounts_spec.rb
Normal file
|
@ -0,0 +1,80 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Accounts in grouped notifications' do
|
||||
let(:user) { Fabricate(:user, account_attributes: { username: 'alice' }) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read:notifications write:notifications' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
||||
describe 'GET /api/v2_alpha/notifications/:group_key/accounts', :inline_jobs do
|
||||
subject do
|
||||
get "/api/v2_alpha/notifications/#{user.account.notifications.first.group_key}/accounts", headers: headers, params: params
|
||||
end
|
||||
|
||||
let(:params) { {} }
|
||||
|
||||
before do
|
||||
first_status = PostStatusService.new.call(user.account, text: 'Test')
|
||||
FavouriteService.new.call(Fabricate(:account), first_status)
|
||||
FavouriteService.new.call(Fabricate(:account), first_status)
|
||||
ReblogService.new.call(Fabricate(:account), first_status)
|
||||
FollowService.new.call(Fabricate(:account), user.account)
|
||||
FavouriteService.new.call(Fabricate(:account), first_status)
|
||||
end
|
||||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write write:notifications'
|
||||
|
||||
it 'returns a list of accounts' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
# The group we are interested in is only favorites
|
||||
notifications = user.account.notifications.where(type: 'favourite').reorder(id: :desc)
|
||||
expect(body_as_json).to match(
|
||||
[
|
||||
a_hash_including(
|
||||
id: notifications.first.from_account_id.to_s
|
||||
),
|
||||
a_hash_including(
|
||||
id: notifications.second.from_account_id.to_s
|
||||
),
|
||||
a_hash_including(
|
||||
id: notifications.third.from_account_id.to_s
|
||||
),
|
||||
]
|
||||
)
|
||||
end
|
||||
|
||||
context 'with limit param' do
|
||||
let(:params) { { limit: 2 } }
|
||||
|
||||
it 'returns the requested number of accounts, with pagination headers' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
# The group we are interested in is only favorites
|
||||
notifications = user.account.notifications.where(type: 'favourite').reorder(id: :desc)
|
||||
expect(body_as_json).to match(
|
||||
[
|
||||
a_hash_including(
|
||||
id: notifications.first.from_account_id.to_s
|
||||
),
|
||||
a_hash_including(
|
||||
id: notifications.second.from_account_id.to_s
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
expect(response)
|
||||
.to include_pagination_headers(
|
||||
prev: api_v2_alpha_notification_accounts_url(limit: params[:limit], min_id: notifications.first.id),
|
||||
next: api_v2_alpha_notification_accounts_url(limit: params[:limit], max_id: notifications.second.id)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -116,6 +116,19 @@ RSpec.describe 'Notifications' do
|
|||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write write:notifications'
|
||||
|
||||
context 'when there are no notifications' do
|
||||
before do
|
||||
user.account.notifications.destroy_all
|
||||
end
|
||||
|
||||
it 'returns 0 notifications' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json[:notification_groups]).to eq []
|
||||
end
|
||||
end
|
||||
|
||||
context 'with no options' do
|
||||
it 'returns expected notification types', :aggregate_failures do
|
||||
subject
|
||||
|
@ -235,7 +248,7 @@ RSpec.describe 'Notifications' do
|
|||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json[:partial_accounts].size).to be > 0
|
||||
expect(body_as_json[:partial_accounts][0].keys).to contain_exactly(:acct, :avatar, :avatar_static, :bot, :id, :locked, :url)
|
||||
expect(body_as_json[:partial_accounts][0].keys.map(&:to_sym)).to contain_exactly(:acct, :avatar, :avatar_static, :bot, :id, :locked, :url)
|
||||
expect(body_as_json[:partial_accounts].pluck(:id)).to_not include(recent_account.id.to_s)
|
||||
expect(body_as_json[:accounts].pluck(:id)).to include(recent_account.id.to_s)
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Backups' do
|
||||
RSpec.describe 'Backups' do
|
||||
include RoutingHelper
|
||||
|
||||
describe 'GET backups#download' do
|
||||
|
|
|
@ -118,7 +118,7 @@ module TestEndpoints
|
|||
end
|
||||
end
|
||||
|
||||
describe 'Caching behavior' do
|
||||
RSpec.describe 'Caching behavior' do
|
||||
shared_examples 'cachable response' do |http_success: false|
|
||||
it 'does not set cookies or set public cache control', :aggregate_failures do
|
||||
expect(response.cookies).to be_empty
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'The catch all route' do
|
||||
RSpec.describe 'The catch all route' do
|
||||
describe 'with a simple value' do
|
||||
it 'returns a 404 page as html' do
|
||||
get '/test'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Content-Security-Policy' do
|
||||
RSpec.describe 'Content-Security-Policy' do
|
||||
before { allow(SecureRandom).to receive(:base64).with(16).and_return('ZbA+JmE7+bK8F5qvADZHuQ==') }
|
||||
|
||||
it 'sets the expected CSP headers' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Custom CSS' do
|
||||
RSpec.describe 'Custom CSS' do
|
||||
include RoutingHelper
|
||||
|
||||
describe 'GET /custom.css' do
|
||||
|
|
|
@ -2,18 +2,17 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Custom stylesheets' do
|
||||
RSpec.describe 'Custom stylesheets' do
|
||||
describe 'GET /custom.css' do
|
||||
before { get '/custom.css' }
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers
|
||||
.and have_attributes(
|
||||
content_type: match('text/css')
|
||||
)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Disabled OAuth routes' do
|
||||
RSpec.describe 'Disabled OAuth routes' do
|
||||
# These routes are disabled via the doorkeeper configuration for
|
||||
# `admin_authenticator`, as these routes should only be accessible by server
|
||||
# administrators. For now, these routes are not properly designed and
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Emojis' do
|
||||
RSpec.describe 'Emojis' do
|
||||
describe 'GET /emojis/:id' do
|
||||
let(:emoji) { Fabricate(:custom_emoji, shortcode: 'coolcat') }
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Health check endpoint' do
|
||||
RSpec.describe 'Health check endpoint' do
|
||||
describe 'GET /health' do
|
||||
it 'returns http success when server is functioning' do
|
||||
get '/health'
|
||||
|
|
|
@ -4,11 +4,6 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe 'Instance actor endpoint' do
|
||||
describe 'GET /actor' do
|
||||
before do
|
||||
integration_session.https! # TODO: Move to global rails_helper for all request specs?
|
||||
host! Rails.configuration.x.local_domain # TODO: Move to global rails_helper for all request specs?
|
||||
end
|
||||
|
||||
let!(:original_federation_mode) { Rails.configuration.x.limited_federation_mode }
|
||||
|
||||
shared_examples 'instance actor endpoint' do
|
||||
|
@ -17,6 +12,7 @@ RSpec.describe 'Instance actor endpoint' do
|
|||
it 'returns http success with correct media type and body' do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers
|
||||
expect(response.content_type)
|
||||
.to start_with('application/activity+json')
|
||||
expect(body_as_json)
|
||||
|
@ -32,8 +28,6 @@ RSpec.describe 'Instance actor endpoint' do
|
|||
url: about_more_url(instance_actor: true)
|
||||
)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response'
|
||||
end
|
||||
|
||||
context 'with limited federation mode disabled' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'invites' do
|
||||
RSpec.describe 'invites' do
|
||||
let(:invite) { Fabricate(:invite) }
|
||||
|
||||
context 'when requesting a JSON document' do
|
||||
|
|
31
spec/requests/invites_spec.rb
Normal file
31
spec/requests/invites_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Invites' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
before { sign_in user }
|
||||
|
||||
context 'when not everyone can invite' do
|
||||
before { UserRole.everyone.update(permissions: UserRole.everyone.permissions & ~UserRole::FLAGS[:invite_users]) }
|
||||
|
||||
describe 'GET /invites' do
|
||||
it 'returns http forbidden' do
|
||||
get invites_path
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(403)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST /invites' do
|
||||
it 'returns http forbidden' do
|
||||
post invites_path, params: { invite: { max_users: '10', expires_in: 1800 } }
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(403)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,32 +2,16 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Link headers' do
|
||||
RSpec.describe 'Link headers' do
|
||||
describe 'on the account show page' do
|
||||
let(:account) { Fabricate(:account, username: 'test') }
|
||||
|
||||
before do
|
||||
it 'contains webfinger and activitypub urls in link header' do
|
||||
get short_account_path(username: account)
|
||||
end
|
||||
|
||||
it 'contains webfinger url in link header' do
|
||||
link_header = link_header_with_type('application/jrd+json')
|
||||
|
||||
expect(link_header.href).to eq 'http://www.example.com/.well-known/webfinger?resource=acct%3Atest%40cb6e6126.ngrok.io'
|
||||
expect(link_header.attr_pairs.first).to eq %w(rel lrdd)
|
||||
end
|
||||
|
||||
it 'contains activitypub url in link header' do
|
||||
link_header = link_header_with_type('application/activity+json')
|
||||
|
||||
expect(link_header.href).to eq 'https://cb6e6126.ngrok.io/users/test'
|
||||
expect(link_header.attr_pairs.first).to eq %w(rel alternate)
|
||||
end
|
||||
|
||||
def link_header_with_type(type)
|
||||
LinkHeader.parse(response.headers['Link'].to_s).links.find do |link|
|
||||
link.attr_pairs.any?(['type', type])
|
||||
end
|
||||
expect(response)
|
||||
.to have_http_link_header('https://cb6e6126.ngrok.io/.well-known/webfinger?resource=acct%3Atest%40cb6e6126.ngrok.io').for(rel: 'lrdd', type: 'application/jrd+json')
|
||||
.and have_http_link_header('https://cb6e6126.ngrok.io/users/test').for(rel: 'alternate', type: 'application/activity+json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Localization' do
|
||||
RSpec.describe 'Localization' do
|
||||
around do |example|
|
||||
I18n.with_locale(I18n.locale) do
|
||||
example.run
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Log Out' do
|
||||
RSpec.describe 'Log Out' do
|
||||
include RoutingHelper
|
||||
|
||||
describe 'DELETE /auth/sign_out' do
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Manifest' do
|
||||
RSpec.describe 'Manifest' do
|
||||
describe 'GET /manifest' do
|
||||
before { get '/manifest' }
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers
|
||||
.and have_attributes(
|
||||
content_type: match('application/json')
|
||||
)
|
||||
|
@ -18,7 +19,5 @@ describe 'Manifest' do
|
|||
name: 'Mastodon'
|
||||
)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,14 +2,9 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Media Proxy' do
|
||||
RSpec.describe 'Media Proxy' do
|
||||
describe 'GET /media_proxy/:id' do
|
||||
before do
|
||||
integration_session.https! # TODO: Move to global rails_helper for all request specs?
|
||||
host! Rails.configuration.x.local_domain # TODO: Move to global rails_helper for all request specs?
|
||||
|
||||
stub_request(:get, 'http://example.com/attachment.png').to_return(request_fixture('avatar.txt'))
|
||||
end
|
||||
before { stub_attachment_request }
|
||||
|
||||
context 'when attached to a status' do
|
||||
let(:status) { Fabricate(:status) }
|
||||
|
@ -63,5 +58,15 @@ describe 'Media Proxy' do
|
|||
.to have_http_status(404)
|
||||
end
|
||||
end
|
||||
|
||||
def stub_attachment_request
|
||||
stub_request(
|
||||
:get,
|
||||
'http://example.com/attachment.png'
|
||||
)
|
||||
.to_return(
|
||||
request_fixture('avatar.txt')
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'OmniAuth callbacks' do
|
||||
RSpec.describe 'OmniAuth callbacks' do
|
||||
shared_examples 'omniauth provider callbacks' do |provider|
|
||||
subject { post send :"user_#{provider}_omniauth_callback_path" }
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Remote Interaction Helper' do
|
||||
RSpec.describe 'Remote Interaction Helper' do
|
||||
describe 'GET /remote_interaction_helper' do
|
||||
it 'returns http success' do
|
||||
get remote_interaction_helper_path
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Self-destruct mode' do
|
||||
RSpec.describe 'Self-destruct mode' do
|
||||
before do
|
||||
allow(SelfDestructHelper).to receive(:self_destruct?).and_return(true)
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Settings / Exports / Blocked Accounts' do
|
||||
RSpec.describe 'Settings / Exports / Blocked Accounts' do
|
||||
describe 'GET /settings/exports/blocks' do
|
||||
context 'with a signed in user who has blocked accounts' do
|
||||
let(:user) { Fabricate :user }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Settings / Exports / Blocked Domains' do
|
||||
RSpec.describe 'Settings / Exports / Blocked Domains' do
|
||||
describe 'GET /settings/exports/domain_blocks' do
|
||||
context 'with a signed in user who has blocked domains' do
|
||||
let(:account) { Fabricate :account, domain: 'example.com' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Settings / Exports / Bookmarks' do
|
||||
RSpec.describe 'Settings / Exports / Bookmarks' do
|
||||
describe 'GET /settings/exports/bookmarks' do
|
||||
context 'with a signed in user who has bookmarks' do
|
||||
let(:account) { Fabricate(:account, domain: 'foo.bar') }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Settings / Exports / Following Accounts' do
|
||||
RSpec.describe 'Settings / Exports / Following Accounts' do
|
||||
describe 'GET /settings/exports/follows' do
|
||||
context 'with a signed in user who is following accounts' do
|
||||
let(:user) { Fabricate :user }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Settings / Exports / Lists' do
|
||||
RSpec.describe 'Settings / Exports / Lists' do
|
||||
describe 'GET /settings/exports/lists' do
|
||||
context 'with a signed in user who has lists' do
|
||||
let(:account) { Fabricate(:account, username: 'test', domain: 'example.com') }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Settings / Exports / Muted Accounts' do
|
||||
RSpec.describe 'Settings / Exports / Muted Accounts' do
|
||||
describe 'GET /settings/exports/mutes' do
|
||||
context 'with a signed in user who has muted accounts' do
|
||||
let(:user) { Fabricate :user }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'signature verification concern' do
|
||||
RSpec.describe 'signature verification concern' do
|
||||
before do
|
||||
stub_tests_controller
|
||||
|
||||
|
|
56
spec/requests/tags_spec.rb
Normal file
56
spec/requests/tags_spec.rb
Normal file
|
@ -0,0 +1,56 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Tags' do
|
||||
describe 'GET /tags/:id' do
|
||||
context 'when tag exists' do
|
||||
let(:tag) { Fabricate :tag }
|
||||
|
||||
context 'with HTML format' do
|
||||
# TODO: Update the have_cacheable_headers matcher to operate on capybara sessions
|
||||
# Remove this example, rely on system spec (which should use matcher)
|
||||
before { get tag_path(tag) }
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with JSON format' do
|
||||
before { get tag_path(tag, format: :json) }
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
||||
expect(response.content_type)
|
||||
.to start_with('application/activity+json')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with RSS format' do
|
||||
before { get tag_path(tag, format: :rss) }
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
||||
expect(response.content_type)
|
||||
.to start_with('application/rss+xml')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when tag does not exist' do
|
||||
before { get tag_path('missing') }
|
||||
|
||||
it 'returns http not found' do
|
||||
expect(response)
|
||||
.to have_http_status(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'The /.well-known/change-password request' do
|
||||
RSpec.describe 'The /.well-known/change-password request' do
|
||||
it 'redirects to the change password page' do
|
||||
get '/.well-known/change-password'
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'The /.well-known/host-meta request' do
|
||||
RSpec.describe 'The /.well-known/host-meta request' do
|
||||
it 'returns http success with valid XML response' do
|
||||
get '/.well-known/host-meta'
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'The well-known node-info endpoints' do
|
||||
RSpec.describe 'The well-known node-info endpoints' do
|
||||
describe 'The /.well-known/node-info endpoint' do
|
||||
it 'returns JSON document pointing to node info' do
|
||||
get '/.well-known/nodeinfo'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'The /.well-known/oauth-authorization-server request' do
|
||||
RSpec.describe 'The /.well-known/oauth-authorization-server request' do
|
||||
let(:protocol) { ENV.fetch('LOCAL_HTTPS', true) ? :https : :http }
|
||||
|
||||
before do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'The /.well-known/webfinger endpoint' do
|
||||
RSpec.describe 'The /.well-known/webfinger endpoint' do
|
||||
subject(:perform_request!) { get webfinger_url(resource: resource) }
|
||||
|
||||
let(:alternate_domains) { [] }
|
||||
|
@ -129,9 +129,11 @@ describe 'The /.well-known/webfinger endpoint' do
|
|||
end
|
||||
|
||||
it 'returns links for the internal account' do
|
||||
json = body_as_json
|
||||
expect(json[:subject]).to eq 'acct:mastodon.internal@cb6e6126.ngrok.io'
|
||||
expect(json[:aliases]).to eq ['https://cb6e6126.ngrok.io/actor']
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
subject: 'acct:mastodon.internal@cb6e6126.ngrok.io',
|
||||
aliases: ['https://cb6e6126.ngrok.io/actor']
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue