From ec0e78f128a12c5980bf04c870a3ca43a7b5cf5d Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 13 Mar 2026 12:54:57 -0400 Subject: [PATCH] Add coverage for rewrite with vary username paths (#38197) --- spec/requests/username_rewrites_spec.rb | 53 +++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 spec/requests/username_rewrites_spec.rb diff --git a/spec/requests/username_rewrites_spec.rb b/spec/requests/username_rewrites_spec.rb new file mode 100644 index 0000000000..9e025a5f0d --- /dev/null +++ b/spec/requests/username_rewrites_spec.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'Username URL rewrites' do + describe 'GET /users/:username' do + it 'redirects to at-username page variation' do + get '/users/username' + + expect(response) + .to have_http_status(301) + .and redirect_to('/@username') + expect(response.headers) + .to include('Vary' => 'Origin, Accept') + end + end + + describe 'GET /users/:username/following' do + it 'redirects to at-username page variation' do + get '/users/username/following' + + expect(response) + .to have_http_status(301) + .and redirect_to('/@username/following') + expect(response.headers) + .to include('Vary' => 'Origin, Accept') + end + end + + describe 'GET /users/:username/followers' do + it 'redirects to at-username page variation' do + get '/users/username/followers' + + expect(response) + .to have_http_status(301) + .and redirect_to('/@username/followers') + expect(response.headers) + .to include('Vary' => 'Origin, Accept') + end + end + + describe 'GET /users/:username/statuses/:id' do + it 'redirects to at-username page variation' do + get '/users/username/statuses/123456' + + expect(response) + .to have_http_status(301) + .and redirect_to('/@username/123456') + expect(response.headers) + .to include('Vary' => 'Origin, Accept') + end + end +end