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.

44 lines
1.2 KiB

  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:statuses') }
  11. describe 'GET #show' do
  12. before do
  13. follow = Fabricate(:follow, account: user.account)
  14. PostStatusService.new.call(follow.target_account, text: 'New status for user home timeline.')
  15. end
  16. it 'returns http success' do
  17. get :show
  18. expect(response).to have_http_status(200)
  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