Skip to content
Extraits de code Groupes Projets
Valider e70e721a rédigé par Eugen Rochko's avatar Eugen Rochko
Parcourir les fichiers

Add tests for new API

parent 83ccdeb8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
require 'rails_helper'
RSpec.describe Api::V1::DevicesController, type: :controller do
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
let(:token) { double acceptable?: true, resource_owner_id: user.id }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'POST #register' do
before do
post :register, params: { registration_id: 'foo123' }
end
it 'returns http success' do
expect(response).to have_http_status(:success)
end
it 'registers device' do
expect(Device.where(account: user.account, registration_id: 'foo123').first).to_not be_nil
end
end
describe 'POST #unregister' do
before do
post :unregister, params: { registration_id: 'foo123' }
end
it 'returns http success' do
expect(response).to have_http_status(:success)
end
it 'removes device' do
expect(Device.where(account: user.account, registration_id: 'foo123').first).to be_nil
end
end
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter