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.

65 lines
1.6 KiB

  1. require 'rails_helper'
  2. RSpec.describe Api::V1::TimelinesController, type: :controller do
  3. render_views
  4. let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
  5. before do
  6. allow(controller).to receive(:doorkeeper_token) { token }
  7. end
  8. context 'with a user context' do
  9. let(:token) { double acceptable?: true, resource_owner_id: user.id }
  10. describe 'GET #home' do
  11. it 'returns http success' do
  12. get :home
  13. expect(response).to have_http_status(:success)
  14. end
  15. end
  16. describe 'GET #public' do
  17. it 'returns http success' do
  18. get :public
  19. expect(response).to have_http_status(:success)
  20. end
  21. end
  22. describe 'GET #tag' do
  23. before do
  24. PostStatusService.new.call(user.account, 'It is a #test')
  25. end
  26. it 'returns http success' do
  27. get :tag, params: { id: 'test' }
  28. expect(response).to have_http_status(:success)
  29. end
  30. end
  31. end
  32. context 'without a user context' do
  33. let(:token) { double acceptable?: true, resource_owner_id: nil }
  34. describe 'GET #home' do
  35. it 'returns http unprocessable entity' do
  36. get :home
  37. expect(response).to have_http_status(:unprocessable_entity)
  38. end
  39. end
  40. describe 'GET #public' do
  41. it 'returns http success' do
  42. get :public
  43. expect(response).to have_http_status(:success)
  44. end
  45. end
  46. describe 'GET #tag' do
  47. it 'returns http success' do
  48. get :tag, params: { id: 'test' }
  49. expect(response).to have_http_status(:success)
  50. end
  51. end
  52. end
  53. end