tokens_controller_spec.rb 845 B

123456789101112131415161718192021222324
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe Oauth::TokensController, type: :controller do
  4. describe 'POST #revoke' do
  5. let!(:user) { Fabricate(:user) }
  6. let!(:application) { Fabricate(:application, confidential: false) }
  7. let!(:access_token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, application: application) }
  8. let!(:web_push_subscription) { Fabricate(:web_push_subscription, user: user, access_token: access_token) }
  9. before do
  10. post :revoke, params: { client_id: application.uid, token: access_token.token }
  11. end
  12. it 'revokes the token' do
  13. expect(access_token.reload.revoked_at).to_not be_nil
  14. end
  15. it 'removes web push subscription for token' do
  16. expect(Web::PushSubscription.where(access_token: access_token).count).to eq 0
  17. end
  18. end
  19. end