logo

mastofe

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

home_controller_spec.rb (1233B)


  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Api::V1::Timelines::HomeController do
  4. render_views
  5. let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice'), current_sign_in_at: 1.day.ago) }
  6. before do
  7. allow(controller).to receive(:doorkeeper_token) { token }
  8. end
  9. context 'with a user context' do
  10. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read') }
  11. describe 'GET #show' do
  12. before do
  13. follow = Fabricate(:follow, account: user.account)
  14. PostStatusService.new.call(follow.target_account, 'New status for user home timeline.')
  15. end
  16. it 'returns http success' do
  17. get :show
  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 a user context' do
  24. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil, scopes: 'read') }
  25. describe 'GET #show' do
  26. it 'returns http unprocessable entity' do
  27. get :show
  28. expect(response).to have_http_status(:unprocessable_entity)
  29. expect(response.headers['Link']).to be_nil
  30. end
  31. end
  32. end
  33. end