Remove: #429 ドメインブロックの「未ログインユーザーに非公開にする」オプション (#430)

This commit is contained in:
KMY(雪あすか) 2024-01-07 16:23:19 +09:00 committed by GitHub
parent 5f144c017c
commit ecf6f31ecd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 67 additions and 15 deletions

View file

@ -3,6 +3,11 @@
require 'rails_helper'
RSpec.describe 'Domain Blocks' 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/v1/instance/domain_blocks' do
before do
Fabricate(:domain_block)
@ -22,6 +27,26 @@ RSpec.describe 'Domain Blocks' do
.and(be_an(Array))
.and(have_attributes(size: 1))
end
context 'with hidden domain block' do
before { Fabricate(:domain_block, domain: 'hello.com', hidden: true) }
it 'returns http success and dont include hidden record' do
get api_v1_instance_domain_blocks_path
expect(body_as_json.pluck(:domain)).to_not include('hello.com')
end
end
context 'with hidden domain block from anonymous' do
before { Fabricate(:domain_block, domain: 'hello.com', hidden_anonymous: true) }
it 'returns http success and dont include hidden record' do
get api_v1_instance_domain_blocks_path
expect(body_as_json.pluck(:domain)).to_not include('hello.com')
end
end
end
context 'with domain blocks set to users' do
@ -35,6 +60,42 @@ RSpec.describe 'Domain Blocks' do
end
end
context 'with domain blocks set to users with access token' do
before { Setting.show_domain_blocks = 'users' }
it 'returns http not found' do
get api_v1_instance_domain_blocks_path, headers: headers
expect(response)
.to have_http_status(200)
expect(body_as_json)
.to be_present
.and(be_an(Array))
.and(have_attributes(size: 1))
end
context 'with hidden domain block' do
before { Fabricate(:domain_block, domain: 'hello.com', hidden: true) }
it 'returns http success and dont include hidden record' do
get api_v1_instance_domain_blocks_path, headers: headers
expect(body_as_json.pluck(:domain)).to_not include('hello.com')
end
end
context 'with hidden domain block from anonymous' do
before { Fabricate(:domain_block, domain: 'hello.com', hidden_anonymous: true) }
it 'returns http success and dont include hidden record' do
get api_v1_instance_domain_blocks_path, headers: headers
expect(body_as_json.pluck(:domain)).to_not include('hello.com')
end
end
end
context 'with domain blocks set to disabled' do
before { Setting.show_domain_blocks = 'disabled' }