mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-09 01:04:08 +00:00
Fix error and incorrect URLs in /api/v1/accounts/:id/featured_tags
for remote accounts (#27459)
This commit is contained in:
parent
3ef0a19bac
commit
ff3a9dad0d
|
@ -10,7 +10,9 @@ class REST::FeaturedTagSerializer < ActiveModel::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
short_account_tag_url(object.account, object.tag)
|
# The path is hardcoded because we have to deal with both local and
|
||||||
|
# remote users, which are different routes
|
||||||
|
account_with_domain_url(object.account, "tagged/#{object.tag.to_param}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def name
|
def name
|
||||||
|
|
|
@ -126,7 +126,7 @@ Rails.application.routes.draw do
|
||||||
get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
|
get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/@:username_with_domain/(*any)', to: 'home#index', constraints: { username_with_domain: /([^\/])+?/ }, format: false
|
get '/@:username_with_domain/(*any)', to: 'home#index', constraints: { username_with_domain: %r{([^/])+?} }, as: :account_with_domain, format: false
|
||||||
get '/settings', to: redirect('/settings/profile')
|
get '/settings', to: redirect('/settings/profile')
|
||||||
|
|
||||||
namespace :settings do
|
namespace :settings do
|
||||||
|
|
50
spec/requests/api/v1/accounts/featured_tags_spec.rb
Normal file
50
spec/requests/api/v1/accounts/featured_tags_spec.rb
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'account featured tags API' do
|
||||||
|
let(:user) { Fabricate(:user) }
|
||||||
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||||
|
let(:scopes) { 'read:accounts' }
|
||||||
|
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||||
|
let(:account) { Fabricate(:account) }
|
||||||
|
|
||||||
|
describe 'GET /api/v1/accounts/:id/featured_tags' do
|
||||||
|
subject do
|
||||||
|
get "/api/v1/accounts/#{account.id}/featured_tags", headers: headers
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
account.featured_tags.create!(name: 'foo')
|
||||||
|
account.featured_tags.create!(name: 'bar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns the expected tags', :aggregate_failures do
|
||||||
|
subject
|
||||||
|
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(body_as_json).to contain_exactly(a_hash_including({
|
||||||
|
name: 'bar',
|
||||||
|
url: "https://cb6e6126.ngrok.io/@#{account.username}/tagged/bar",
|
||||||
|
}), a_hash_including({
|
||||||
|
name: 'foo',
|
||||||
|
url: "https://cb6e6126.ngrok.io/@#{account.username}/tagged/foo",
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the account is remote' do
|
||||||
|
it 'returns the expected tags', :aggregate_failures do
|
||||||
|
subject
|
||||||
|
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(body_as_json).to contain_exactly(a_hash_including({
|
||||||
|
name: 'bar',
|
||||||
|
url: "https://cb6e6126.ngrok.io/@#{account.pretty_acct}/tagged/bar",
|
||||||
|
}), a_hash_including({
|
||||||
|
name: 'foo',
|
||||||
|
url: "https://cb6e6126.ngrok.io/@#{account.pretty_acct}/tagged/foo",
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue