0
0
Fork 0

Remove Atom feeds and old URLs in the form of GET /:username/updates/:id (#11247)

This commit is contained in:
Eugen Rochko 2019-07-07 16:16:51 +02:00 committed by GitHub
parent 406b46395d
commit b851456139
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 130 additions and 2791 deletions

View file

@ -48,37 +48,6 @@ RSpec.describe AccountsController, type: :controller do
end
end
context 'atom' do
let(:format) { 'atom' }
let(:content_type) { 'application/atom+xml' }
shared_examples 'responsed streams' do
it 'assigns @entries' do
entries = assigns(:entries).to_a
expect(entries.size).to eq expected_statuses.size
entries.each.zip(expected_statuses.each) do |entry, expected_status|
expect(entry.status).to eq expected_status
end
end
end
include_examples 'responses'
context 'without max_id nor since_id' do
let(:expected_statuses) { [status7, status6, status5, status4, status3, status2, status1] }
include_examples 'responsed streams'
end
context 'with max_id and since_id' do
let(:max_id) { status4.stream_entry.id }
let(:since_id) { status1.stream_entry.id }
let(:expected_statuses) { [status3, status2] }
include_examples 'responsed streams'
end
end
context 'activitystreams2' do
let(:format) { 'json' }
let(:content_type) { 'application/activity+json' }

View file

@ -9,7 +9,7 @@ RSpec.describe Api::OEmbedController, type: :controller do
describe 'GET #show' do
before do
request.host = Rails.configuration.x.local_domain
get :show, params: { url: account_stream_entry_url(alice, status.stream_entry) }, format: :json
get :show, params: { url: short_account_status_url(alice, status) }, format: :json
end
it 'returns http success' do

View file

@ -360,9 +360,5 @@ describe ApplicationController, type: :controller do
context 'Status' do
include_examples 'cacheable', :status, Status
end
context 'StreamEntry' do
include_examples 'receives :with_includes', :stream_entry, StreamEntry
end
end
end

View file

@ -55,18 +55,6 @@ describe StatusesController do
expect(assigns(:status)).to eq status
end
it 'assigns @stream_entry' do
status = Fabricate(:status)
get :show, params: { account_username: status.account.username, id: status.id }
expect(assigns(:stream_entry)).to eq status.stream_entry
end
it 'assigns @type' do
status = Fabricate(:status)
get :show, params: { account_username: status.account.username, id: status.id }
expect(assigns(:type)).to eq 'status'
end
it 'assigns @ancestors for ancestors of the status if it is a reply' do
ancestor = Fabricate(:status)
status = Fabricate(:status, in_reply_to_id: ancestor.id)
@ -135,10 +123,10 @@ describe StatusesController do
expect(response).to have_http_status(200)
end
it 'renders stream_entries/show' do
it 'renders statuses/show' do
status = Fabricate(:status)
get :show, params: { account_username: status.account.username, id: status.id }
expect(response).to render_template 'stream_entries/show'
expect(response).to render_template 'statuses/show'
end
end
end

View file

@ -1,95 +0,0 @@
require 'rails_helper'
RSpec.describe StreamEntriesController, type: :controller do
render_views
shared_examples 'before_action' do |route|
context 'when account is not suspended and stream_entry is available' do
it 'assigns instance variables' do
status = Fabricate(:status)
get route, params: { account_username: status.account.username, id: status.stream_entry.id }
expect(assigns(:account)).to eq status.account
expect(assigns(:stream_entry)).to eq status.stream_entry
expect(assigns(:type)).to eq 'status'
end
it 'sets Link headers' do
alice = Fabricate(:account, username: 'alice')
status = Fabricate(:status, account: alice)
get route, params: { account_username: alice.username, id: status.stream_entry.id }
expect(response.headers['Link'].to_s).to eq "<http://test.host/users/alice/updates/#{status.stream_entry.id}.atom>; rel=\"alternate\"; type=\"application/atom+xml\", <https://cb6e6126.ngrok.io/users/alice/statuses/#{status.id}>; rel=\"alternate\"; type=\"application/activity+json\""
end
end
context 'when account is suspended' do
it 'returns http status 410' do
account = Fabricate(:account, suspended: true)
status = Fabricate(:status, account: account)
get route, params: { account_username: account.username, id: status.stream_entry.id }
expect(response).to have_http_status(410)
end
end
context 'when activity is nil' do
it 'raises ActiveRecord::RecordNotFound' do
account = Fabricate(:account)
stream_entry = Fabricate.build(:stream_entry, account: account, activity: nil, activity_type: 'Status')
stream_entry.save!(validate: false)
get route, params: { account_username: account.username, id: stream_entry.id }
expect(response).to have_http_status(404)
end
end
context 'when it is hidden and it is not permitted' do
it 'raises ActiveRecord::RecordNotFound' do
status = Fabricate(:status)
user = Fabricate(:user)
status.account.block!(user.account)
status.stream_entry.update!(hidden: true)
sign_in(user)
get route, params: { account_username: status.account.username, id: status.stream_entry.id }
expect(response).to have_http_status(404)
end
end
end
describe 'GET #show' do
include_examples 'before_action', :show
it 'redirects to status page' do
status = Fabricate(:status)
get :show, params: { account_username: status.account.username, id: status.stream_entry.id }
expect(response).to redirect_to(short_account_status_url(status.account, status))
end
it 'returns http success with Atom' do
status = Fabricate(:status)
get :show, params: { account_username: status.account.username, id: status.stream_entry.id }, format: 'atom'
expect(response).to have_http_status(200)
end
end
describe 'GET #embed' do
include_examples 'before_action', :embed
it 'redirects to new embed page' do
status = Fabricate(:status)
get :embed, params: { account_username: status.account.username, id: status.stream_entry.id }
expect(response).to redirect_to(embed_short_account_status_url(status.account, status))
end
end
end