tokens_controller_spec.rb 719 B

1234567891011121314151617181920212223
  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!(:access_token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }
  7. let!(:web_push_subscription) { Fabricate(:web_push_subscription, user: user, access_token: access_token) }
  8. before do
  9. post :revoke, params: { token: access_token.token }
  10. end
  11. it 'revokes the token' do
  12. expect(access_token.reload.revoked_at).to_not be_nil
  13. end
  14. it 'removes web push subscription for token' do
  15. expect(Web::PushSubscription.where(access_token: access_token).count).to eq 0
  16. end
  17. end
  18. end