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.

35 lines
960 B

  1. require 'rails_helper'
  2. RSpec.describe Api::V1::PollsController, type: :controller do
  3. render_views
  4. let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
  5. let(:scopes) { 'read:statuses' }
  6. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
  7. before { allow(controller).to receive(:doorkeeper_token) { token } }
  8. describe 'GET #show' do
  9. let(:poll) { Fabricate(:poll, status: Fabricate(:status, visibility: visibility)) }
  10. before do
  11. get :show, params: { id: poll.id }
  12. end
  13. context 'when parent status is public' do
  14. let(:visibility) { 'public' }
  15. it 'returns http success' do
  16. expect(response).to have_http_status(200)
  17. end
  18. end
  19. context 'when parent status is private' do
  20. let(:visibility) { 'private' }
  21. it 'returns http not found' do
  22. expect(response).to have_http_status(404)
  23. end
  24. end
  25. end
  26. end