logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

statuses_controller_spec.rb (3356B)


  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 'status is a reblog' do
  25. it 'redirects to the original status' do
  26. original_account = Fabricate(:account, domain: 'example.com')
  27. original_status = Fabricate(:status, account: original_account, uri: 'tag:example.com,2017:foo', url: 'https://example.com/123')
  28. status = Fabricate(:status, reblog: original_status)
  29. get :show, params: { account_username: status.account.username, id: status.id }
  30. expect(response).to redirect_to(original_status.url)
  31. end
  32. end
  33. context 'account is not suspended and status is permitted' do
  34. it 'assigns @account' do
  35. status = Fabricate(:status)
  36. get :show, params: { account_username: status.account.username, id: status.id }
  37. expect(assigns(:account)).to eq status.account
  38. end
  39. it 'assigns @status' do
  40. status = Fabricate(:status)
  41. get :show, params: { account_username: status.account.username, id: status.id }
  42. expect(assigns(:status)).to eq status
  43. end
  44. it 'assigns @stream_entry' do
  45. status = Fabricate(:status)
  46. get :show, params: { account_username: status.account.username, id: status.id }
  47. expect(assigns(:stream_entry)).to eq status.stream_entry
  48. end
  49. it 'assigns @type' do
  50. status = Fabricate(:status)
  51. get :show, params: { account_username: status.account.username, id: status.id }
  52. expect(assigns(:type)).to eq 'status'
  53. end
  54. it 'assigns @ancestors for ancestors of the status if it is a reply' do
  55. ancestor = Fabricate(:status)
  56. status = Fabricate(:status, in_reply_to_id: ancestor.id)
  57. get :show, params: { account_username: status.account.username, id: status.id }
  58. expect(assigns(:ancestors)).to eq [ancestor]
  59. end
  60. it 'assigns @ancestors for [] if it is not a reply' do
  61. status = Fabricate(:status)
  62. get :show, params: { account_username: status.account.username, id: status.id }
  63. expect(assigns(:ancestors)).to eq []
  64. end
  65. it 'returns a success' do
  66. status = Fabricate(:status)
  67. get :show, params: { account_username: status.account.username, id: status.id }
  68. expect(response).to have_http_status(:success)
  69. end
  70. it 'renders stream_entries/show' do
  71. status = Fabricate(:status)
  72. get :show, params: { account_username: status.account.username, id: status.id }
  73. expect(response).to render_template 'stream_entries/show'
  74. end
  75. end
  76. end
  77. end