0
0
Fork 0

Convert more API specs from controller->request style (#29004)

This commit is contained in:
Matt Jankowski 2024-03-01 11:24:45 -05:00 committed by GitHub
parent a25014de8f
commit 18945f62e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 159 additions and 156 deletions

View file

@ -0,0 +1,33 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'API V1 Polls Votes' do
let(:user) { Fabricate(:user) }
let(:scopes) { 'write:statuses' }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
describe 'POST /api/v1/polls/:poll_id/votes' do
let(:poll) { Fabricate(:poll) }
before do
post "/api/v1/polls/#{poll.id}/votes", params: { choices: %w(1) }, headers: headers
end
it 'creates a vote', :aggregate_failures do
expect(response).to have_http_status(200)
expect(vote).to_not be_nil
expect(vote.choice).to eq 1
expect(poll.reload.cached_tallies).to eq [0, 1]
end
private
def vote
poll.votes.where(account: user.account).first
end
end
end