Merge remote-tracking branch 'parent/main' into upstream-20231214
This commit is contained in:
commit
08a2f557fe
61 changed files with 980 additions and 838 deletions
31
spec/requests/api/v1/accounts/familiar_followers_spec.rb
Normal file
31
spec/requests/api/v1/accounts/familiar_followers_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
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' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
describe 'GET /api/v1/accounts/familiar_followers' do
|
||||
it 'returns http success' do
|
||||
get '/api/v1/accounts/familiar_followers', params: { account_id: account.id, limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
context 'when there are duplicate account IDs in the params' do
|
||||
let(:account_a) { Fabricate(:account) }
|
||||
let(:account_b) { Fabricate(:account) }
|
||||
|
||||
it 'removes duplicate account IDs from params' do
|
||||
account_ids = [account_a, account_b, account_b, account_a, account_a].map { |a| a.id.to_s }
|
||||
get '/api/v1/accounts/familiar_followers', params: { id: account_ids }, headers: headers
|
||||
|
||||
expect(body_as_json.pluck(:id)).to contain_exactly(account_a.id.to_s, account_b.id.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
19
spec/requests/api/v1/accounts/identity_proofs_spec.rb
Normal file
19
spec/requests/api/v1/accounts/identity_proofs_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
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' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
describe 'GET /api/v1/accounts/identity_proofs' do
|
||||
it 'returns http success' do
|
||||
get "/api/v1/accounts/#{account.id}/identity_proofs", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
25
spec/requests/api/v1/accounts/lists_spec.rb
Normal file
25
spec/requests/api/v1/accounts/lists_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
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' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:list) { Fabricate(:list, account: user.account) }
|
||||
|
||||
before do
|
||||
user.account.follow!(account)
|
||||
list.accounts << account
|
||||
end
|
||||
|
||||
describe 'GET /api/v1/accounts/lists' do
|
||||
it 'returns http success' do
|
||||
get "/api/v1/accounts/#{account.id}/lists", headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
19
spec/requests/api/v1/accounts/lookup_spec.rb
Normal file
19
spec/requests/api/v1/accounts/lookup_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
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' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
describe 'GET /api/v1/accounts/lookup' do
|
||||
it 'returns http success' do
|
||||
get '/api/v1/accounts/lookup', params: { account_id: account.id, acct: account.acct }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
40
spec/requests/api/v1/accounts/notes_spec.rb
Normal file
40
spec/requests/api/v1/accounts/notes_spec.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
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' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:comment) { 'foo' }
|
||||
|
||||
describe 'POST /api/v1/accounts/:account_id/note' do
|
||||
subject do
|
||||
post "/api/v1/accounts/#{account.id}/note", params: { comment: comment }, headers: headers
|
||||
end
|
||||
|
||||
context 'when account note has reasonable length', :aggregate_failures do
|
||||
let(:comment) { 'foo' }
|
||||
|
||||
it 'updates account note' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(AccountNote.find_by(account_id: user.account.id, target_account_id: account.id).comment).to eq comment
|
||||
end
|
||||
end
|
||||
|
||||
context 'when account note exceeds allowed length', :aggregate_failures do
|
||||
let(:comment) { 'a' * 2_001 }
|
||||
|
||||
it 'does not create account note' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(AccountNote.where(account_id: user.account.id, target_account_id: account.id)).to_not exist
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
41
spec/requests/api/v1/accounts/pins_spec.rb
Normal file
41
spec/requests/api/v1/accounts/pins_spec.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
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' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
let(:kevin) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
kevin.account.followers << user.account
|
||||
end
|
||||
|
||||
describe 'POST /api/v1/accounts/:account_id/pin' do
|
||||
subject { post "/api/v1/accounts/#{kevin.account.id}/pin", headers: headers }
|
||||
|
||||
it 'creates account_pin', :aggregate_failures do
|
||||
expect do
|
||||
subject
|
||||
end.to change { AccountPin.where(account: user.account, target_account: kevin.account).count }.by(1)
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST /api/v1/accounts/:account_id/unpin' do
|
||||
subject { post "/api/v1/accounts/#{kevin.account.id}/unpin", headers: headers }
|
||||
|
||||
before do
|
||||
Fabricate(:account_pin, account: user.account, target_account: kevin.account)
|
||||
end
|
||||
|
||||
it 'destroys account_pin', :aggregate_failures do
|
||||
expect do
|
||||
subject
|
||||
end.to change { AccountPin.where(account: user.account, target_account: kevin.account).count }.by(-1)
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -31,8 +31,8 @@ describe 'GET /api/v1/accounts/relationships' do
|
|||
.to have_http_status(200)
|
||||
expect(body_as_json)
|
||||
.to be_an(Enumerable)
|
||||
.and have_attributes(
|
||||
first: include(
|
||||
.and contain_exactly(
|
||||
include(
|
||||
following: true,
|
||||
followed_by: false
|
||||
)
|
||||
|
@ -53,9 +53,11 @@ describe 'GET /api/v1/accounts/relationships' do
|
|||
expect(body_as_json)
|
||||
.to be_an(Enumerable)
|
||||
.and have_attributes(
|
||||
size: 2,
|
||||
first: include(simon_item),
|
||||
second: include(lewis_item)
|
||||
size: 2
|
||||
)
|
||||
.and contain_exactly(
|
||||
include(simon_item),
|
||||
include(lewis_item)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -71,10 +73,12 @@ describe 'GET /api/v1/accounts/relationships' do
|
|||
expect(body_as_json)
|
||||
.to be_an(Enumerable)
|
||||
.and have_attributes(
|
||||
size: 3,
|
||||
first: include(simon_item),
|
||||
second: include(lewis_item),
|
||||
third: include(bob_item)
|
||||
size: 3
|
||||
)
|
||||
.and contain_exactly(
|
||||
include(simon_item),
|
||||
include(lewis_item),
|
||||
include(bob_item)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -88,9 +92,11 @@ describe 'GET /api/v1/accounts/relationships' do
|
|||
expect(body_as_json)
|
||||
.to be_an(Enumerable)
|
||||
.and have_attributes(
|
||||
size: 2,
|
||||
first: include(simon_item),
|
||||
second: include(lewis_item)
|
||||
size: 2
|
||||
)
|
||||
.and contain_exactly(
|
||||
include(simon_item),
|
||||
include(lewis_item)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -116,7 +122,6 @@ describe 'GET /api/v1/accounts/relationships' do
|
|||
muting: false,
|
||||
requested: false,
|
||||
domain_blocking: false,
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -129,7 +134,6 @@ describe 'GET /api/v1/accounts/relationships' do
|
|||
muting: false,
|
||||
requested: false,
|
||||
domain_blocking: false,
|
||||
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -149,8 +153,10 @@ describe 'GET /api/v1/accounts/relationships' do
|
|||
expect(body_as_json)
|
||||
.to be_an(Enumerable)
|
||||
.and have_attributes(
|
||||
size: 1,
|
||||
first: include(
|
||||
size: 1
|
||||
)
|
||||
.and contain_exactly(
|
||||
include(
|
||||
following: true,
|
||||
showing_reblogs: true
|
||||
)
|
||||
|
@ -168,8 +174,8 @@ describe 'GET /api/v1/accounts/relationships' do
|
|||
|
||||
expect(body_as_json)
|
||||
.to be_an(Enumerable)
|
||||
.and have_attributes(
|
||||
first: include(
|
||||
.and contain_exactly(
|
||||
include(
|
||||
following: false,
|
||||
showing_reblogs: false
|
||||
)
|
||||
|
|
18
spec/requests/api/v1/accounts/search_spec.rb
Normal file
18
spec/requests/api/v1/accounts/search_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
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' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
||||
describe 'GET /api/v1/accounts/search' do
|
||||
it 'returns http success' do
|
||||
get '/api/v1/accounts/search', params: { q: 'query' }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
19
spec/requests/api/v1/featured_tags/suggestions_spec.rb
Normal file
19
spec/requests/api/v1/featured_tags/suggestions_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
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' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
describe 'GET /api/v1/featured_tags/suggestions' do
|
||||
it 'returns http success' do
|
||||
get '/api/v1/featured_tags/suggestions', params: { account_id: account.id, limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
18
spec/requests/api/v2/suggestions_spec.rb
Normal file
18
spec/requests/api/v2/suggestions_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Suggestions API' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
||||
describe 'GET /api/v2/suggestions' do
|
||||
it 'returns http success' do
|
||||
get '/api/v2/suggestions', headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue