blob: 6dddc4edb209712645de310de8d74fb754f5c405 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Authorization, type: :model do
describe '#revoke!' do
subject { create(:authorization) }
context "when the authorization has not been revoked" do
before { subject.revoke! }
specify { expect(subject.revoked_at).to be_present }
end
context "when the authorization has already been revoked" do
before { subject.revoke! }
specify do
expect do
subject.revoke!
end.to raise_error(/already revoked/)
end
end
end
describe ".active, .revoked, .expired" do
subject { described_class }
let!(:active) { create(:authorization) }
let!(:expired) { create(:authorization, expired_at: 1.second.ago) }
let!(:revoked) { create(:authorization, revoked_at: 1.second.ago) }
specify { expect(subject.active).to match_array([active]) }
specify { expect(subject.expired).to match_array([expired]) }
specify { expect(subject.revoked).to match_array([revoked]) }
end
end
|