1
0

accounts_routing_spec.rb 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.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 local username encoded at' do
  38. include RSpec::Rails::RequestExampleGroup
  39. let(:username) { 'alice' }
  40. it 'routes /%40:username' do
  41. get "/%40#{username}"
  42. expect(response).to redirect_to("/@#{username}")
  43. end
  44. it 'routes /%40:username.json' do
  45. get("/%40#{username}.json")
  46. expect(response).to redirect_to("/@#{username}.json")
  47. end
  48. it 'routes /%40:username.rss' do
  49. get("/%40#{username}.rss")
  50. expect(response).to redirect_to("/@#{username}.rss")
  51. end
  52. it 'routes /%40:username/:id' do
  53. get("/%40#{username}/123")
  54. expect(response).to redirect_to("/@#{username}/123")
  55. end
  56. it 'routes /%40:username/:id/embed' do
  57. get("/%40#{username}/123/embed")
  58. expect(response).to redirect_to("/@#{username}/123/embed")
  59. end
  60. it 'routes /%40:username/following' do
  61. get("/%40#{username}/following")
  62. expect(response).to redirect_to("/@#{username}/following")
  63. end
  64. it 'routes /%40:username/followers' do
  65. get("/%40#{username}/followers")
  66. expect(response).to redirect_to("/@#{username}/followers")
  67. end
  68. it 'routes /%40:username/with_replies' do
  69. get("/%40#{username}/with_replies")
  70. expect(response).to redirect_to("/@#{username}/with_replies")
  71. end
  72. it 'routes /%40:username/media' do
  73. get("/%40#{username}/media")
  74. expect(response).to redirect_to("/@#{username}/media")
  75. end
  76. it 'routes /%40:username/tagged/:tag' do
  77. get("/%40#{username}/tagged/foo")
  78. expect(response).to redirect_to("/@#{username}/tagged/foo")
  79. end
  80. end
  81. context 'with remote username' do
  82. let(:username) { 'alice@example.com' }
  83. it 'routes /@:username' do
  84. expect(get("/@#{username}")).to route_to('home#index', username_with_domain: username)
  85. end
  86. it 'routes /@:username/:id' do
  87. expect(get("/@#{username}/123")).to route_to('home#index', username_with_domain: username, any: '123')
  88. end
  89. it 'routes /@:username/:id/embed' do
  90. expect(get("/@#{username}/123/embed")).to route_to('home#index', username_with_domain: username, any: '123/embed')
  91. end
  92. it 'routes /@:username/following' do
  93. expect(get("/@#{username}/following")).to route_to('home#index', username_with_domain: username, any: 'following')
  94. end
  95. it 'routes /@:username/followers' do
  96. expect(get("/@#{username}/followers")).to route_to('home#index', username_with_domain: username, any: 'followers')
  97. end
  98. it 'routes /@:username/with_replies' do
  99. expect(get("/@#{username}/with_replies")).to route_to('home#index', username_with_domain: username, any: 'with_replies')
  100. end
  101. it 'routes /@:username/media' do
  102. expect(get("/@#{username}/media")).to route_to('home#index', username_with_domain: username, any: 'media')
  103. end
  104. it 'routes /@:username/tagged/:tag' do
  105. expect(get("/@#{username}/tagged/foo")).to route_to('home#index', username_with_domain: username, any: 'tagged/foo')
  106. end
  107. end
  108. context 'with remote username encoded at' do
  109. include RSpec::Rails::RequestExampleGroup
  110. let(:username) { 'alice%40example.com' }
  111. let(:username_decoded) { 'alice@example.com' }
  112. it 'routes /%40:username' do
  113. get("/%40#{username}")
  114. expect(response).to redirect_to("/@#{username_decoded}")
  115. end
  116. it 'routes /%40:username/:id' do
  117. get("/%40#{username}/123")
  118. expect(response).to redirect_to("/@#{username_decoded}/123")
  119. end
  120. it 'routes /%40:username/:id/embed' do
  121. get("/%40#{username}/123/embed")
  122. expect(response).to redirect_to("/@#{username_decoded}/123/embed")
  123. end
  124. it 'routes /%40:username/following' do
  125. get("/%40#{username}/following")
  126. expect(response).to redirect_to("/@#{username_decoded}/following")
  127. end
  128. it 'routes /%40:username/followers' do
  129. get("/%40#{username}/followers")
  130. expect(response).to redirect_to("/@#{username_decoded}/followers")
  131. end
  132. it 'routes /%40:username/with_replies' do
  133. get("/%40#{username}/with_replies")
  134. expect(response).to redirect_to("/@#{username_decoded}/with_replies")
  135. end
  136. it 'routes /%40:username/media' do
  137. get("/%40#{username}/media")
  138. expect(response).to redirect_to("/@#{username_decoded}/media")
  139. end
  140. it 'routes /%40:username/tagged/:tag' do
  141. get("/%40#{username}/tagged/foo")
  142. expect(response).to redirect_to("/@#{username_decoded}/tagged/foo")
  143. end
  144. end
  145. end