accounts_routing_spec.rb 3.0 KB

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