You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.8 KiB

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe StatusesController do
  4. render_views
  5. describe '#show' do
  6. context 'account is suspended' do
  7. it 'returns gone' do
  8. account = Fabricate(:account, suspended: true)
  9. status = Fabricate(:status, account: account)
  10. get :show, params: { account_username: account.username, id: status.id }
  11. expect(response).to have_http_status(410)
  12. end
  13. end
  14. context 'status is not permitted' do
  15. it 'raises ActiveRecord::RecordNotFound' do
  16. user = Fabricate(:user)
  17. status = Fabricate(:status)
  18. status.account.block!(user.account)
  19. sign_in(user)
  20. get :show, params: { account_username: status.account.username, id: status.id }
  21. expect(response).to have_http_status(404)
  22. end
  23. end
  24. context 'account is not suspended and status is permitted' do
  25. it 'assigns @account' do
  26. status = Fabricate(:status)
  27. get :show, params: { account_username: status.account.username, id: status.id }
  28. expect(assigns(:account)).to eq status.account
  29. end
  30. it 'assigns @status' do
  31. status = Fabricate(:status)
  32. get :show, params: { account_username: status.account.username, id: status.id }
  33. expect(assigns(:status)).to eq status
  34. end
  35. it 'assigns @stream_entry' do
  36. status = Fabricate(:status)
  37. get :show, params: { account_username: status.account.username, id: status.id }
  38. expect(assigns(:stream_entry)).to eq status.stream_entry
  39. end
  40. it 'assigns @type' do
  41. status = Fabricate(:status)
  42. get :show, params: { account_username: status.account.username, id: status.id }
  43. expect(assigns(:type)).to eq 'status'
  44. end
  45. it 'assigns @ancestors for ancestors of the status if it is a reply' do
  46. ancestor = Fabricate(:status)
  47. status = Fabricate(:status, in_reply_to_id: ancestor.id)
  48. get :show, params: { account_username: status.account.username, id: status.id }
  49. expect(assigns(:ancestors)).to eq [ancestor]
  50. end
  51. it 'assigns @ancestors for [] if it is not a reply' do
  52. status = Fabricate(:status)
  53. get :show, params: { account_username: status.account.username, id: status.id }
  54. expect(assigns(:ancestors)).to eq []
  55. end
  56. it 'returns a success' do
  57. status = Fabricate(:status)
  58. get :show, params: { account_username: status.account.username, id: status.id }
  59. expect(response).to have_http_status(:success)
  60. end
  61. it 'renders stream_entries/show' do
  62. status = Fabricate(:status)
  63. get :show, params: { account_username: status.account.username, id: status.id }
  64. expect(response).to render_template 'stream_entries/show'
  65. end
  66. end
  67. end
  68. end