software_update_policy_spec.rb 565 B

12345678910111213141516171819202122232425
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. require 'pundit/rspec'
  4. RSpec.describe SoftwareUpdatePolicy do
  5. subject { described_class }
  6. let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Owner')).account }
  7. let(:john) { Fabricate(:account) }
  8. permissions :index? do
  9. context 'when owner' do
  10. it 'permits' do
  11. expect(subject).to permit(admin, SoftwareUpdate)
  12. end
  13. end
  14. context 'when not owner' do
  15. it 'denies' do
  16. expect(subject).to_not permit(john, SoftwareUpdate)
  17. end
  18. end
  19. end
  20. end