accounts_routing_spec.rb 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe 'Routes under accounts/' do
  4. context 'with local username' do
  5. let(:username) { 'alice' }
  6. it 'routes /@:username' do
  7. expect(get("/@#{username}")).to route_to('accounts#show', username: username)
  8. end
  9. it 'routes /@:username.json' do
  10. expect(get("/@#{username}.json")).to route_to('accounts#show', username: username, format: 'json')
  11. end
  12. it 'routes /@:username.rss' do
  13. expect(get("/@#{username}.rss")).to route_to('accounts#show', username: username, format: 'rss')
  14. end
  15. it 'routes /@:username/:id' do
  16. expect(get("/@#{username}/123")).to route_to('statuses#show', account_username: username, id: '123')
  17. end
  18. it 'routes /@:username/:id/embed' do
  19. expect(get("/@#{username}/123/embed")).to route_to('statuses#embed', account_username: username, id: '123')
  20. end
  21. it 'routes /@:username/following' do
  22. expect(get("/@#{username}/following")).to route_to('following_accounts#index', account_username: username)
  23. end
  24. it 'routes /@:username/followers' do
  25. expect(get("/@#{username}/followers")).to route_to('follower_accounts#index', account_username: username)
  26. end
  27. it 'routes /@:username/with_replies' do
  28. expect(get("/@#{username}/with_replies")).to route_to('accounts#show', username: username)
  29. end
  30. it 'routes /@:username/media' do
  31. expect(get("/@#{username}/media")).to route_to('accounts#show', username: username)
  32. end
  33. it 'routes /@:username/tagged/:tag' do
  34. expect(get("/@#{username}/tagged/foo")).to route_to('accounts#show', username: username, tag: 'foo')
  35. end
  36. end
  37. context 'with remote username' do
  38. let(:username) { 'alice@example.com' }
  39. it 'routes /@:username' do
  40. expect(get("/@#{username}")).to route_to('home#index', username_with_domain: username)
  41. end
  42. it 'routes /@:username/:id' do
  43. expect(get("/@#{username}/123")).to route_to('home#index', username_with_domain: username, any: '123')
  44. end
  45. it 'routes /@:username/:id/embed' do
  46. expect(get("/@#{username}/123/embed")).to route_to('home#index', username_with_domain: username, any: '123/embed')
  47. end
  48. it 'routes /@:username/following' do
  49. expect(get("/@#{username}/following")).to route_to('home#index', username_with_domain: username, any: 'following')
  50. end
  51. it 'routes /@:username/followers' do
  52. expect(get("/@#{username}/followers")).to route_to('home#index', username_with_domain: username, any: 'followers')
  53. end
  54. it 'routes /@:username/with_replies' do
  55. expect(get("/@#{username}/with_replies")).to route_to('home#index', username_with_domain: username, any: 'with_replies')
  56. end
  57. it 'routes /@:username/media' do
  58. expect(get("/@#{username}/media")).to route_to('home#index', username_with_domain: username, any: 'media')
  59. end
  60. it 'routes /@:username/tagged/:tag' do
  61. expect(get("/@#{username}/tagged/foo")).to route_to('home#index', username_with_domain: username, any: 'tagged/foo')
  62. end
  63. end
  64. end