logo

mastofe

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

reblogged_by_accounts_controller_spec.rb (1918B)


  1. require 'rails_helper'
  2. RSpec.describe Api::V1::Statuses::RebloggedByAccountsController, type: :controller do
  3. render_views
  4. let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
  5. let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
  6. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, application: app) }
  7. context 'with an oauth token' do
  8. before do
  9. allow(controller).to receive(:doorkeeper_token) { token }
  10. end
  11. describe 'GET #index' do
  12. let(:status) { Fabricate(:status, account: user.account) }
  13. before do
  14. Fabricate(:status, reblog_of_id: status.id)
  15. end
  16. it 'returns http success' do
  17. get :index, params: { status_id: status.id, limit: 1 }
  18. expect(response).to have_http_status(:success)
  19. expect(response.headers['Link'].links.size).to eq(2)
  20. end
  21. end
  22. end
  23. context 'without an oauth token' do
  24. before do
  25. allow(controller).to receive(:doorkeeper_token) { nil }
  26. end
  27. context 'with a private status' do
  28. let(:status) { Fabricate(:status, account: user.account, visibility: :private) }
  29. describe 'GET #index' do
  30. before do
  31. Fabricate(:status, reblog_of_id: status.id)
  32. end
  33. it 'returns http unautharized' do
  34. get :index, params: { status_id: status.id }
  35. expect(response).to have_http_status(:missing)
  36. end
  37. end
  38. end
  39. context 'with a public status' do
  40. let(:status) { Fabricate(:status, account: user.account, visibility: :public) }
  41. describe 'GET #index' do
  42. before do
  43. Fabricate(:status, reblog_of_id: status.id)
  44. end
  45. it 'returns http success' do
  46. get :index, params: { status_id: status.id }
  47. expect(response).to have_http_status(:success)
  48. end
  49. end
  50. end
  51. end
  52. end