Merge remote-tracking branch 'parent/main' into upstream-20230209
This commit is contained in:
commit
05e52a09a8
188 changed files with 2810 additions and 1295 deletions
|
@ -49,6 +49,7 @@ RSpec.describe 'Domain Blocks' do
|
|||
{
|
||||
id: domain_block.id.to_s,
|
||||
domain: domain_block.domain,
|
||||
digest: domain_block.domain_digest,
|
||||
created_at: domain_block.created_at.strftime('%Y-%m-%dT%H:%M:%S.%LZ'),
|
||||
severity: domain_block.severity.to_s,
|
||||
reject_media: domain_block.reject_media,
|
||||
|
@ -123,7 +124,7 @@ RSpec.describe 'Domain Blocks' do
|
|||
it_behaves_like 'forbidden for wrong role', ''
|
||||
it_behaves_like 'forbidden for wrong role', 'Moderator'
|
||||
|
||||
it 'returns the expected domain block content', :aggregate_failures do # rubocop:disable RSpec/ExampleLength
|
||||
it 'returns the expected domain block content', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
|
@ -131,6 +132,7 @@ RSpec.describe 'Domain Blocks' do
|
|||
{
|
||||
id: domain_block.id.to_s,
|
||||
domain: domain_block.domain,
|
||||
digest: domain_block.domain_digest,
|
||||
created_at: domain_block.created_at.strftime('%Y-%m-%dT%H:%M:%S.%LZ'),
|
||||
severity: domain_block.severity.to_s,
|
||||
reject_media: domain_block.reject_media,
|
||||
|
@ -232,6 +234,7 @@ RSpec.describe 'Domain Blocks' do
|
|||
{
|
||||
id: domain_block.id.to_s,
|
||||
domain: domain_block.domain,
|
||||
digest: domain_block.domain_digest,
|
||||
severity: 'suspend',
|
||||
}
|
||||
)
|
||||
|
|
|
@ -151,7 +151,9 @@ RSpec.describe 'Reports' do
|
|||
let(:params) { { category: 'spam' } }
|
||||
|
||||
it 'updates the report category', :aggregate_failures do
|
||||
expect { subject }.to change { report.reload.category }.from('other').to('spam')
|
||||
expect { subject }
|
||||
.to change { report.reload.category }.from('other').to('spam')
|
||||
.and create_an_action_log
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
|
@ -184,7 +186,9 @@ RSpec.describe 'Reports' do
|
|||
it_behaves_like 'forbidden for wrong role', ''
|
||||
|
||||
it 'marks report as resolved', :aggregate_failures do
|
||||
expect { subject }.to change { report.reload.unresolved? }.from(true).to(false)
|
||||
expect { subject }
|
||||
.to change { report.reload.unresolved? }.from(true).to(false)
|
||||
.and create_an_action_log
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
@ -200,7 +204,9 @@ RSpec.describe 'Reports' do
|
|||
it_behaves_like 'forbidden for wrong role', ''
|
||||
|
||||
it 'marks report as unresolved', :aggregate_failures do
|
||||
expect { subject }.to change { report.reload.unresolved? }.from(false).to(true)
|
||||
expect { subject }
|
||||
.to change { report.reload.unresolved? }.from(false).to(true)
|
||||
.and create_an_action_log
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
@ -216,7 +222,9 @@ RSpec.describe 'Reports' do
|
|||
it_behaves_like 'forbidden for wrong role', ''
|
||||
|
||||
it 'assigns report to the requesting user', :aggregate_failures do
|
||||
expect { subject }.to change { report.reload.assigned_account_id }.from(nil).to(user.account.id)
|
||||
expect { subject }
|
||||
.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)
|
||||
end
|
||||
end
|
||||
|
@ -232,8 +240,16 @@ RSpec.describe 'Reports' do
|
|||
it_behaves_like 'forbidden for wrong role', ''
|
||||
|
||||
it 'unassigns report from assignee', :aggregate_failures do
|
||||
expect { subject }.to change { report.reload.assigned_account_id }.from(user.account.id).to(nil)
|
||||
expect { subject }
|
||||
.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)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_an_action_log
|
||||
change(Admin::ActionLog, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -52,5 +52,19 @@ RSpec.describe 'API Markers' do
|
|||
expect(user.markers.first.last_read_id).to eq 70_120
|
||||
end
|
||||
end
|
||||
|
||||
context 'when database object becomes stale' do
|
||||
before do
|
||||
allow(Marker).to receive(:transaction).and_raise(ActiveRecord::StaleObjectError)
|
||||
post '/api/v1/markers', headers: headers, params: { home: { last_read_id: '69420' } }
|
||||
end
|
||||
|
||||
it 'returns error json' do
|
||||
expect(response)
|
||||
.to have_http_status(409)
|
||||
expect(body_as_json)
|
||||
.to include(error: /Conflict during update/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,10 +9,28 @@ describe 'Suggestions API' do
|
|||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
||||
describe 'GET /api/v2/suggestions' do
|
||||
it 'returns http success' do
|
||||
let(:bob) { Fabricate(:account) }
|
||||
let(:jeff) { Fabricate(:account) }
|
||||
let(:params) { {} }
|
||||
|
||||
before do
|
||||
Setting.bootstrap_timeline_accounts = [bob, jeff].map(&:acct).join(',')
|
||||
end
|
||||
|
||||
it 'returns the expected suggestions' do
|
||||
get '/api/v2/suggestions', headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
expect(body_as_json).to match_array(
|
||||
[bob, jeff].map do |account|
|
||||
hash_including({
|
||||
source: 'staff',
|
||||
sources: ['featured'],
|
||||
account: hash_including({ id: account.id.to_s }),
|
||||
})
|
||||
end
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue