mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-23 16:44:04 -05:00
Add specs for BackupPolicy (#9576)
This commit is contained in:
parent
af37f4a70f
commit
5d724aa129
45
spec/policies/backup_policy_spec.rb
Normal file
45
spec/policies/backup_policy_spec.rb
Normal file
@ -0,0 +1,45 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe BackupPolicy do
|
||||
let(:subject) { described_class }
|
||||
let(:john) { Fabricate(:user).account }
|
||||
|
||||
permissions :create? do
|
||||
context 'not user_signed_in?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(nil, Backup)
|
||||
end
|
||||
end
|
||||
|
||||
context 'user_signed_in?' do
|
||||
context 'no backups' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(john, Backup)
|
||||
end
|
||||
end
|
||||
|
||||
context 'backups are too old' do
|
||||
it 'permits' do
|
||||
travel(-8.days) do
|
||||
Fabricate(:backup, user: john.user)
|
||||
end
|
||||
|
||||
expect(subject).to permit(john, Backup)
|
||||
end
|
||||
end
|
||||
|
||||
context 'backups are newer' do
|
||||
it 'denies' do
|
||||
travel(-3.days) do
|
||||
Fabricate(:backup, user: john.user)
|
||||
end
|
||||
|
||||
expect(subject).to_not permit(john, Backup)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user