Merge commit '1467f1e1e1c18dc4b310862ff1f719165a24cfb6' into glitch-soc/merge-upstream
This commit is contained in:
commit
dfd74f0dae
|
@ -164,6 +164,7 @@ class EmojiPickerMenuImpl extends PureComponent {
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
skinTone: PropTypes.number.isRequired,
|
skinTone: PropTypes.number.isRequired,
|
||||||
onSkinTone: PropTypes.func.isRequired,
|
onSkinTone: PropTypes.func.isRequired,
|
||||||
|
pickerButtonRef: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
|
@ -178,7 +179,7 @@ class EmojiPickerMenuImpl extends PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
handleDocumentClick = e => {
|
handleDocumentClick = e => {
|
||||||
if (this.node && !this.node.contains(e.target)) {
|
if (this.node && !this.node.contains(e.target) && !this.props.pickerButtonRef.contains(e.target)) {
|
||||||
this.props.onClose();
|
this.props.onClose();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -233,6 +234,7 @@ class EmojiPickerMenuImpl extends PureComponent {
|
||||||
emoji.native = emoji.colons;
|
emoji.native = emoji.colons;
|
||||||
}
|
}
|
||||||
if (!(event.ctrlKey || event.metaKey)) {
|
if (!(event.ctrlKey || event.metaKey)) {
|
||||||
|
|
||||||
this.props.onClose();
|
this.props.onClose();
|
||||||
}
|
}
|
||||||
this.props.onPick(emoji);
|
this.props.onPick(emoji);
|
||||||
|
@ -407,6 +409,7 @@ class EmojiPickerDropdown extends PureComponent {
|
||||||
onSkinTone={onSkinTone}
|
onSkinTone={onSkinTone}
|
||||||
skinTone={skinTone}
|
skinTone={skinTone}
|
||||||
frequentlyUsedEmojis={frequentlyUsedEmojis}
|
frequentlyUsedEmojis={frequentlyUsedEmojis}
|
||||||
|
pickerButtonRef={this.target}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,31 +2,26 @@
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Api::V1::Admin::Trends::Links::PreviewCardProvidersController do
|
describe 'API V1 Admin Trends Links Preview Card Providers' do
|
||||||
render_views
|
|
||||||
|
|
||||||
let(:role) { UserRole.find_by(name: 'Admin') }
|
let(:role) { UserRole.find_by(name: 'Admin') }
|
||||||
let(:user) { Fabricate(:user, role: role) }
|
let(:user) { Fabricate(:user, role: role) }
|
||||||
let(:scopes) { 'admin:read admin:write' }
|
let(:scopes) { 'admin:read admin:write' }
|
||||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||||
|
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
let(:preview_card_provider) { Fabricate(:preview_card_provider) }
|
let(:preview_card_provider) { Fabricate(:preview_card_provider) }
|
||||||
|
|
||||||
before do
|
describe 'GET /api/v1/admin/trends/links/publishers' do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #index' do
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :index, params: { account_id: account.id, limit: 2 }
|
get '/api/v1/admin/trends/links/publishers', params: { account_id: account.id, limit: 2 }, headers: headers
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #approve' do
|
describe 'POST /api/v1/admin/trends/links/publishers/:id/approve' do
|
||||||
before do
|
before do
|
||||||
post :approve, params: { id: preview_card_provider.id }
|
post "/api/v1/admin/trends/links/publishers/#{preview_card_provider.id}/approve", headers: headers
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
||||||
|
@ -37,9 +32,9 @@ describe Api::V1::Admin::Trends::Links::PreviewCardProvidersController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #reject' do
|
describe 'POST /api/v1/admin/trends/links/publishers/:id/reject' do
|
||||||
before do
|
before do
|
||||||
post :reject, params: { id: preview_card_provider.id }
|
post "/api/v1/admin/trends/links/publishers/#{preview_card_provider.id}/reject", headers: headers
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
|
@ -2,23 +2,18 @@
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Api::V1::Statuses::HistoriesController do
|
describe 'API V1 Statuses Histories' do
|
||||||
render_views
|
|
||||||
|
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:statuses', application: app) }
|
let(:scopes) { 'read:statuses' }
|
||||||
|
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||||
|
|
||||||
context 'with an oauth token' do
|
context 'with an oauth token' do
|
||||||
before do
|
describe 'GET /api/v1/statuses/:status_id/history' do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #show' do
|
|
||||||
let(:status) { Fabricate(:status, account: user.account) }
|
let(:status) { Fabricate(:status, account: user.account) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
get :show, params: { status_id: status.id }
|
get "/api/v1/statuses/#{status.id}/history", headers: headers
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
|
@ -2,23 +2,18 @@
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Api::V1::Statuses::MutesController do
|
describe 'API V1 Statuses Mutes' do
|
||||||
render_views
|
|
||||||
|
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'write:mutes', application: app) }
|
let(:scopes) { 'write:mutes' }
|
||||||
|
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||||
|
|
||||||
context 'with an oauth token' do
|
context 'with an oauth token' do
|
||||||
before do
|
describe 'POST /api/v1/statuses/:status_id/mute' do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'POST #create' do
|
|
||||||
let(:status) { Fabricate(:status, account: user.account) }
|
let(:status) { Fabricate(:status, account: user.account) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
post :create, params: { status_id: status.id }
|
post "/api/v1/statuses/#{status.id}/mute", headers: headers
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a conversation mute', :aggregate_failures do
|
it 'creates a conversation mute', :aggregate_failures do
|
||||||
|
@ -27,12 +22,12 @@ describe Api::V1::Statuses::MutesController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #destroy' do
|
describe 'POST /api/v1/statuses/:status_id/unmute' do
|
||||||
let(:status) { Fabricate(:status, account: user.account) }
|
let(:status) { Fabricate(:status, account: user.account) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
user.account.mute_conversation!(status.conversation)
|
user.account.mute_conversation!(status.conversation)
|
||||||
post :destroy, params: { status_id: status.id }
|
post "/api/v1/statuses/#{status.id}/unmute", headers: headers
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'destroys the conversation mute', :aggregate_failures do
|
it 'destroys the conversation mute', :aggregate_failures do
|
|
@ -2,23 +2,18 @@
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Api::V1::Statuses::ReblogsController do
|
describe 'API V1 Statuses Reblogs' do
|
||||||
render_views
|
|
||||||
|
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'write:statuses', application: app) }
|
let(:scopes) { 'write:statuses' }
|
||||||
|
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||||
|
|
||||||
context 'with an oauth token' do
|
context 'with an oauth token' do
|
||||||
before do
|
describe 'POST /api/v1/statuses/:status_id/reblog' do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'POST #create' do
|
|
||||||
let(:status) { Fabricate(:status, account: user.account) }
|
let(:status) { Fabricate(:status, account: user.account) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
post :create, params: { status_id: status.id }
|
post "/api/v1/statuses/#{status.id}/reblog", headers: headers
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with public status' do
|
context 'with public status' do
|
||||||
|
@ -46,13 +41,13 @@ describe Api::V1::Statuses::ReblogsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #destroy', :sidekiq_inline do
|
describe 'POST /api/v1/statuses/:status_id/unreblog', :sidekiq_inline do
|
||||||
context 'with public status' do
|
context 'with public status' do
|
||||||
let(:status) { Fabricate(:status, account: user.account) }
|
let(:status) { Fabricate(:status, account: user.account) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
ReblogService.new.call(user.account, status)
|
ReblogService.new.call(user.account, status)
|
||||||
post :destroy, params: { status_id: status.id }
|
post "/api/v1/statuses/#{status.id}/unreblog", headers: headers
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'destroys the reblog', :aggregate_failures do
|
it 'destroys the reblog', :aggregate_failures do
|
||||||
|
@ -76,7 +71,7 @@ describe Api::V1::Statuses::ReblogsController do
|
||||||
before do
|
before do
|
||||||
ReblogService.new.call(user.account, status)
|
ReblogService.new.call(user.account, status)
|
||||||
status.account.block!(user.account)
|
status.account.block!(user.account)
|
||||||
post :destroy, params: { status_id: status.id }
|
post "/api/v1/statuses/#{status.id}/unreblog", headers: headers
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'destroys the reblog', :aggregate_failures do
|
it 'destroys the reblog', :aggregate_failures do
|
||||||
|
@ -98,7 +93,7 @@ describe Api::V1::Statuses::ReblogsController do
|
||||||
let(:status) { Fabricate(:status, visibility: :private) }
|
let(:status) { Fabricate(:status, visibility: :private) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
post :destroy, params: { status_id: status.id }
|
post "/api/v1/statuses/#{status.id}/unreblog", headers: headers
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http not found' do
|
it 'returns http not found' do
|
|
@ -2,19 +2,14 @@
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Api::V1::Statuses::TranslationsController do
|
describe 'API V1 Statuses Translations' do
|
||||||
render_views
|
|
||||||
|
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:statuses', application: app) }
|
let(:scopes) { 'read:statuses' }
|
||||||
|
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||||
|
|
||||||
context 'with an oauth token' do
|
context 'with an oauth token' do
|
||||||
before do
|
describe 'POST /api/v1/statuses/:status_id/translate' do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'POST #create' do
|
|
||||||
let(:status) { Fabricate(:status, account: user.account, text: 'Hola', language: 'es') }
|
let(:status) { Fabricate(:status, account: user.account, text: 'Hola', language: 'es') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -22,7 +17,7 @@ describe Api::V1::Statuses::TranslationsController do
|
||||||
service = instance_double(TranslationService::DeepL, translate: [translation])
|
service = instance_double(TranslationService::DeepL, translate: [translation])
|
||||||
allow(TranslationService).to receive_messages(configured?: true, configured: service)
|
allow(TranslationService).to receive_messages(configured?: true, configured: service)
|
||||||
Rails.cache.write('translation_service/languages', { 'es' => ['en'] })
|
Rails.cache.write('translation_service/languages', { 'es' => ['en'] })
|
||||||
post :create, params: { status_id: status.id }
|
post "/api/v1/statuses/#{status.id}/translate", headers: headers
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
|
@ -2,15 +2,13 @@
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Api::V1::Trends::LinksController do
|
RSpec.describe 'API V1 Trends Links' do
|
||||||
render_views
|
describe 'GET /api/v1/trends/links' do
|
||||||
|
|
||||||
describe 'GET #index' do
|
|
||||||
context 'when trends are disabled' do
|
context 'when trends are disabled' do
|
||||||
before { Setting.trends = false }
|
before { Setting.trends = false }
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :index
|
get '/api/v1/trends/links'
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
|
@ -22,7 +20,7 @@ RSpec.describe Api::V1::Trends::LinksController do
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
prepare_trends
|
prepare_trends
|
||||||
stub_const('Api::V1::Trends::LinksController::DEFAULT_LINKS_LIMIT', 2)
|
stub_const('Api::V1::Trends::LinksController::DEFAULT_LINKS_LIMIT', 2)
|
||||||
get :index
|
get '/api/v1/trends/links'
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
expect(response.headers).to include('Link')
|
expect(response.headers).to include('Link')
|
|
@ -2,15 +2,13 @@
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Api::V1::Trends::StatusesController do
|
RSpec.describe 'API V1 Trends Statuses' do
|
||||||
render_views
|
describe 'GET /api/v1/trends/statuses' do
|
||||||
|
|
||||||
describe 'GET #index' do
|
|
||||||
context 'when trends are disabled' do
|
context 'when trends are disabled' do
|
||||||
before { Setting.trends = false }
|
before { Setting.trends = false }
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :index
|
get '/api/v1/trends/statuses'
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
|
@ -22,7 +20,7 @@ RSpec.describe Api::V1::Trends::StatusesController do
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
prepare_trends
|
prepare_trends
|
||||||
stub_const('Api::BaseController::DEFAULT_STATUSES_LIMIT', 2)
|
stub_const('Api::BaseController::DEFAULT_STATUSES_LIMIT', 2)
|
||||||
get :index
|
get '/api/v1/trends/statuses'
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
expect(response.headers).to include('Link')
|
expect(response.headers).to include('Link')
|
|
@ -2,15 +2,13 @@
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Api::V1::Trends::TagsController do
|
RSpec.describe 'API V1 Trends Tags' do
|
||||||
render_views
|
describe 'GET /api/v1/trends/tags' do
|
||||||
|
|
||||||
describe 'GET #index' do
|
|
||||||
context 'when trends are disabled' do
|
context 'when trends are disabled' do
|
||||||
before { Setting.trends = false }
|
before { Setting.trends = false }
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :index
|
get '/api/v1/trends/tags'
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
expect(response.headers).to_not include('Link')
|
expect(response.headers).to_not include('Link')
|
||||||
|
@ -23,7 +21,7 @@ RSpec.describe Api::V1::Trends::TagsController do
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
prepare_trends
|
prepare_trends
|
||||||
stub_const('Api::V1::Trends::TagsController::DEFAULT_TAGS_LIMIT', 2)
|
stub_const('Api::V1::Trends::TagsController::DEFAULT_TAGS_LIMIT', 2)
|
||||||
get :index
|
get '/api/v1/trends/tags'
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
expect(response.headers).to include('Link')
|
expect(response.headers).to include('Link')
|
|
@ -2,19 +2,14 @@
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Api::V2::Admin::AccountsController do
|
RSpec.describe 'API V2 Admin Accounts' do
|
||||||
render_views
|
|
||||||
|
|
||||||
let(:role) { UserRole.find_by(name: 'Moderator') }
|
let(:role) { UserRole.find_by(name: 'Moderator') }
|
||||||
let(:user) { Fabricate(:user, role: role) }
|
let(:user) { Fabricate(:user, role: role) }
|
||||||
let(:scopes) { 'admin:read admin:write' }
|
let(:scopes) { 'admin:read admin:write' }
|
||||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||||
|
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
|
|
||||||
before do
|
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #index' do
|
describe 'GET #index' do
|
||||||
let!(:remote_account) { Fabricate(:account, domain: 'example.org') }
|
let!(:remote_account) { Fabricate(:account, domain: 'example.org') }
|
||||||
let!(:other_remote_account) { Fabricate(:account, domain: 'foo.bar') }
|
let!(:other_remote_account) { Fabricate(:account, domain: 'foo.bar') }
|
||||||
|
@ -28,7 +23,8 @@ RSpec.describe Api::V2::Admin::AccountsController do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
pending_account.user.update(approved: false)
|
pending_account.user.update(approved: false)
|
||||||
get :index, params: params
|
|
||||||
|
get '/api/v2/admin/accounts', params: params, headers: headers
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
|
@ -21,20 +21,14 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
||||||
let(:account) { subject.call('https://example.com/alice') }
|
let(:account) { subject.call('https://example.com/alice') }
|
||||||
|
|
||||||
shared_examples 'sets profile data' do
|
shared_examples 'sets profile data' do
|
||||||
it 'returns an account' do
|
it 'returns an account with expected details' do
|
||||||
expect(account).to be_an Account
|
expect(account)
|
||||||
end
|
.to be_an(Account)
|
||||||
|
.and have_attributes(
|
||||||
it 'sets display name' do
|
display_name: eq('Alice'),
|
||||||
expect(account.display_name).to eq 'Alice'
|
note: eq('Foo bar'),
|
||||||
end
|
url: eq('https://example.com/alice')
|
||||||
|
)
|
||||||
it 'sets note' do
|
|
||||||
expect(account.note).to eq 'Foo bar'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets URL' do
|
|
||||||
expect(account.url).to eq 'https://example.com/alice'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,18 +42,11 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
||||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and returns nil' do
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns nil' do
|
|
||||||
expect(account).to be_nil
|
expect(account).to be_nil
|
||||||
|
|
||||||
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -71,17 +58,12 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
||||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and sets attributes' do
|
||||||
account
|
account
|
||||||
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets username and domain from webfinger' do
|
|
||||||
expect(account.username).to eq 'alice'
|
expect(account.username).to eq 'alice'
|
||||||
expect(account.domain).to eq 'example.com'
|
expect(account.domain).to eq 'example.com'
|
||||||
end
|
end
|
||||||
|
@ -98,22 +80,13 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
||||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and follows redirection and sets attributes' do
|
||||||
account
|
account
|
||||||
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up "redirected" webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
|
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets username and domain from final webfinger' do
|
|
||||||
expect(account.username).to eq 'alice'
|
expect(account.username).to eq 'alice'
|
||||||
expect(account.domain).to eq 'iscool.af'
|
expect(account.domain).to eq 'iscool.af'
|
||||||
end
|
end
|
||||||
|
@ -129,18 +102,11 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
||||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and does not create account' do
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not create account' do
|
|
||||||
expect(account).to be_nil
|
expect(account).to be_nil
|
||||||
|
|
||||||
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -153,23 +119,12 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
||||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and follows redirect and does not create account' do
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up "redirected" webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not create account' do
|
|
||||||
expect(account).to be_nil
|
expect(account).to be_nil
|
||||||
|
|
||||||
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
|
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,20 +21,14 @@ RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
|
||||||
let(:account) { subject.call('https://example.com/alice') }
|
let(:account) { subject.call('https://example.com/alice') }
|
||||||
|
|
||||||
shared_examples 'sets profile data' do
|
shared_examples 'sets profile data' do
|
||||||
it 'returns an account' do
|
it 'returns an account and sets attributes' do
|
||||||
expect(account).to be_an Account
|
expect(account)
|
||||||
end
|
.to be_an(Account)
|
||||||
|
.and have_attributes(
|
||||||
it 'sets display name' do
|
display_name: eq('Alice'),
|
||||||
expect(account.display_name).to eq 'Alice'
|
note: eq('Foo bar'),
|
||||||
end
|
url: eq('https://example.com/alice')
|
||||||
|
)
|
||||||
it 'sets note' do
|
|
||||||
expect(account.note).to eq 'Foo bar'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets URL' do
|
|
||||||
expect(account.url).to eq 'https://example.com/alice'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,18 +42,11 @@ RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
|
||||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and returns nil' do
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns nil' do
|
|
||||||
expect(account).to be_nil
|
expect(account).to be_nil
|
||||||
|
|
||||||
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -71,17 +58,12 @@ RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
|
||||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and sets values' do
|
||||||
account
|
account
|
||||||
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets username and domain from webfinger' do
|
|
||||||
expect(account.username).to eq 'alice'
|
expect(account.username).to eq 'alice'
|
||||||
expect(account.domain).to eq 'example.com'
|
expect(account.domain).to eq 'example.com'
|
||||||
end
|
end
|
||||||
|
@ -98,22 +80,13 @@ RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
|
||||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and follows redirect and sets values' do
|
||||||
account
|
account
|
||||||
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up "redirected" webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
|
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets username and domain from final webfinger' do
|
|
||||||
expect(account.username).to eq 'alice'
|
expect(account.username).to eq 'alice'
|
||||||
expect(account.domain).to eq 'iscool.af'
|
expect(account.domain).to eq 'iscool.af'
|
||||||
end
|
end
|
||||||
|
@ -129,18 +102,11 @@ RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
|
||||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and does not create account' do
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not create account' do
|
|
||||||
expect(account).to be_nil
|
expect(account).to be_nil
|
||||||
|
|
||||||
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -153,23 +119,12 @@ RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
|
||||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fetches resource' do
|
it 'fetches resource and looks up webfinger and follows redirect and does not create account' do
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'looks up "redirected" webfinger' do
|
|
||||||
account
|
|
||||||
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not create account' do
|
|
||||||
expect(account).to be_nil
|
expect(account).to be_nil
|
||||||
|
|
||||||
|
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
|
||||||
|
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
|
||||||
|
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue