logo

mastofe

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

list_controller_spec.rb (1727B)


  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Api::V1::Timelines::ListController do
  4. render_views
  5. let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
  6. let(:list) { Fabricate(:list, account: user.account) }
  7. before do
  8. allow(controller).to receive(:doorkeeper_token) { token }
  9. end
  10. context 'with a user context' do
  11. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read') }
  12. describe 'GET #show' do
  13. before do
  14. follow = Fabricate(:follow, account: user.account)
  15. list.accounts << follow.target_account
  16. PostStatusService.new.call(follow.target_account, 'New status for user home timeline.')
  17. end
  18. it 'returns http success' do
  19. get :show, params: { id: list.id }
  20. expect(response).to have_http_status(:success)
  21. end
  22. end
  23. end
  24. context 'with the wrong user context' do
  25. let(:other_user) { Fabricate(:user, account: Fabricate(:account, username: 'bob')) }
  26. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: other_user.id, scopes: 'read') }
  27. describe 'GET #show' do
  28. it 'returns http not found' do
  29. get :show, params: { id: list.id }
  30. expect(response).to have_http_status(:not_found)
  31. end
  32. end
  33. end
  34. context 'without a user context' do
  35. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil, scopes: 'read') }
  36. describe 'GET #show' do
  37. it 'returns http unprocessable entity' do
  38. get :show, params: { id: list.id }
  39. expect(response).to have_http_status(:unprocessable_entity)
  40. expect(response.headers['Link']).to be_nil
  41. end
  42. end
  43. end
  44. end