polls_controller_spec.rb 911 B

1234567891011121314151617181920212223242526272829303132333435
  1. require 'rails_helper'
  2. RSpec.describe Api::V1::PollsController, type: :controller do
  3. render_views
  4. let(:user) { Fabricate(:user) }
  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