Merge tag 'v2.7.0' into instance_only_statuses
This commit is contained in:
@ -84,19 +84,17 @@ RSpec.describe Api::V1::MediaController, type: :controller do
|
||||
post :create, params: { file: fixture_file_upload('files/attachment.webm', 'video/webm') }
|
||||
end
|
||||
|
||||
xit 'returns http success' do
|
||||
it do
|
||||
# returns http success
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
xit 'creates a media attachment' do
|
||||
# creates a media attachment
|
||||
expect(MediaAttachment.first).to_not be_nil
|
||||
end
|
||||
|
||||
xit 'uploads a file' do
|
||||
# uploads a file
|
||||
expect(MediaAttachment.first).to have_attached_file(:file)
|
||||
end
|
||||
|
||||
xit 'returns media ID in JSON' do
|
||||
# returns media ID in JSON
|
||||
expect(body_as_json[:id]).to eq MediaAttachment.first.id.to_s
|
||||
end
|
||||
end
|
||||
|
||||
@ -17,7 +17,7 @@ RSpec.describe TagsController, type: :controller do
|
||||
|
||||
it 'renders application layout' do
|
||||
get :show, params: { id: 'test', max_id: late.id }
|
||||
expect(response).to render_template layout: 'application'
|
||||
expect(response).to render_template layout: 'public'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
7
spec/fixtures/requests/oembed_json_empty.html
vendored
Normal file
7
spec/fixtures/requests/oembed_json_empty.html
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='https://host.test/empty_provider.json' rel='alternate' type='application/json+oembed'>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
@ -1,4 +1,131 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::AccountAction, type: :model do
|
||||
let(:account_action) { described_class.new }
|
||||
|
||||
describe '#save!' do
|
||||
subject { account_action.save! }
|
||||
let(:account) { Fabricate(:account, user: Fabricate(:user, admin: true)) }
|
||||
let(:target_account) { Fabricate(:account, user: Fabricate(:user)) }
|
||||
let(:type) { 'disable' }
|
||||
|
||||
before do
|
||||
account_action.assign_attributes(
|
||||
type: type,
|
||||
current_account: account,
|
||||
target_account: target_account
|
||||
)
|
||||
end
|
||||
|
||||
context 'type is "disable"' do
|
||||
let(:type) { 'disable' }
|
||||
|
||||
it 'disable user' do
|
||||
subject
|
||||
expect(target_account.user).to be_disabled
|
||||
end
|
||||
end
|
||||
|
||||
context 'type is "silence"' do
|
||||
let(:type) { 'silence' }
|
||||
|
||||
it 'silences account' do
|
||||
subject
|
||||
expect(target_account).to be_silenced
|
||||
end
|
||||
end
|
||||
|
||||
context 'type is "suspend"' do
|
||||
let(:type) { 'suspend' }
|
||||
|
||||
it 'suspends account' do
|
||||
subject
|
||||
expect(target_account).to be_suspended
|
||||
end
|
||||
|
||||
it 'queues Admin::SuspensionWorker by 1' do
|
||||
Sidekiq::Testing.fake! do
|
||||
expect do
|
||||
subject
|
||||
end.to change { Admin::SuspensionWorker.jobs.size }.by 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'creates Admin::ActionLog' do
|
||||
expect do
|
||||
subject
|
||||
end.to change { Admin::ActionLog.count }.by 1
|
||||
end
|
||||
|
||||
it 'calls queue_email!' do
|
||||
expect(account_action).to receive(:queue_email!)
|
||||
subject
|
||||
end
|
||||
|
||||
it 'calls process_reports!' do
|
||||
expect(account_action).to receive(:process_reports!)
|
||||
subject
|
||||
end
|
||||
end
|
||||
|
||||
describe '#report' do
|
||||
subject { account_action.report }
|
||||
|
||||
context 'report_id.present?' do
|
||||
before do
|
||||
account_action.report_id = Fabricate(:report).id
|
||||
end
|
||||
|
||||
it 'returns Report' do
|
||||
expect(subject).to be_instance_of Report
|
||||
end
|
||||
end
|
||||
|
||||
context '!report_id.present?' do
|
||||
it 'returns nil' do
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#with_report?' do
|
||||
subject { account_action.with_report? }
|
||||
|
||||
context '!report.nil?' do
|
||||
before do
|
||||
account_action.report_id = Fabricate(:report).id
|
||||
end
|
||||
|
||||
it 'returns true' do
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context '!(!report.nil?)' do
|
||||
it 'returns false' do
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '.types_for_account' do
|
||||
subject { described_class.types_for_account(account) }
|
||||
|
||||
context 'account.local?' do
|
||||
let(:account) { Fabricate(:account, domain: nil) }
|
||||
|
||||
it 'returns ["none", "disable", "silence", "suspend"]' do
|
||||
expect(subject).to eq %w(none disable silence suspend)
|
||||
end
|
||||
end
|
||||
|
||||
context '!account.local?' do
|
||||
let(:account) { Fabricate(:account, domain: 'hoge.com') }
|
||||
|
||||
it 'returns ["silence", "suspend"]' do
|
||||
expect(subject).to eq %w(silence suspend)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,4 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::ActionLog, type: :model do
|
||||
describe '#action' do
|
||||
it 'returns action' do
|
||||
action_log = described_class.new(action: 'hoge')
|
||||
expect(action_log.action).to be :hoge
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -29,7 +29,6 @@ Devise::Test::ControllerHelpers.module_eval do
|
||||
value: resource.activate_session(warden.request),
|
||||
expires: 1.year.from_now,
|
||||
httponly: true,
|
||||
same_site: :lax,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@ -8,6 +8,7 @@ describe FetchOEmbedService, type: :service do
|
||||
before do
|
||||
stub_request(:get, "https://host.test/provider.json").to_return(status: 404)
|
||||
stub_request(:get, "https://host.test/provider.xml").to_return(status: 404)
|
||||
stub_request(:get, "https://host.test/empty_provider.json").to_return(status: 200)
|
||||
end
|
||||
|
||||
describe 'discover_provider' do
|
||||
@ -93,6 +94,23 @@ describe FetchOEmbedService, type: :service do
|
||||
expect(subject.call('https://host.test/oembed.html')).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'Empty JSON provider is discoverable' do
|
||||
before do
|
||||
stub_request(:get, 'https://host.test/oembed.html').to_return(
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'text/html' },
|
||||
body: request_fixture('oembed_json_empty.html')
|
||||
)
|
||||
end
|
||||
|
||||
it 'returns new OEmbed::Provider for JSON provider' do
|
||||
subject.call('https://host.test/oembed.html')
|
||||
expect(subject.endpoint_url).to eq 'https://host.test/empty_provider.json'
|
||||
expect(subject.format).to eq :json
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'when status code is not 200' do
|
||||
|
||||
@ -56,4 +56,22 @@ RSpec.describe UnfollowService, type: :service do
|
||||
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
|
||||
end
|
||||
end
|
||||
|
||||
describe 'remote ActivityPub (reverse)' do
|
||||
let(:bob) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox')).account }
|
||||
|
||||
before do
|
||||
bob.follow!(sender)
|
||||
stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
|
||||
subject.call(bob, sender)
|
||||
end
|
||||
|
||||
it 'destroys the following relation' do
|
||||
expect(bob.following?(sender)).to be false
|
||||
end
|
||||
|
||||
it 'sends a reject activity' do
|
||||
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user