mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Add coverage for api/v1/domain_blocks/preview
endpoint (#32303)
This commit is contained in:
parent
6d2f865862
commit
0a4a73f9a6
36
spec/requests/api/v1/domain_blocks/previews_spec.rb
Normal file
36
spec/requests/api/v1/domain_blocks/previews_spec.rb
Normal file
@ -0,0 +1,36 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Domain Blocks Previews API' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'write:blocks' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
let(:account) { Fabricate(:account, user: user) }
|
||||
|
||||
describe 'GET /api/v1/domain_blocks/preview' do
|
||||
subject { get '/api/v1/domain_blocks/preview', params: { domain: domain }, headers: headers }
|
||||
|
||||
let(:domain) { 'host.example' }
|
||||
|
||||
before do
|
||||
Fabricate :follow, account: account, target_account: Fabricate(:account, domain: domain)
|
||||
Fabricate :follow, target_account: account, account: Fabricate(:account, domain: domain)
|
||||
end
|
||||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
||||
|
||||
it 'returns http success and follower counts' do
|
||||
subject
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to include(followers_count: 1)
|
||||
.and include(following_count: 1)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user