rules_check_spec.rb 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Admin::SystemCheck::RulesCheck do
  4. subject(:check) { described_class.new(user) }
  5. let(:user) { Fabricate(:user) }
  6. describe 'skip?' do
  7. context 'when user can manage rules' do
  8. before { allow(user).to receive(:can?).with(:manage_rules).and_return(true) }
  9. it 'returns false' do
  10. expect(check.skip?).to be false
  11. end
  12. end
  13. context 'when user cannot manage rules' do
  14. before { allow(user).to receive(:can?).with(:manage_rules).and_return(false) }
  15. it 'returns true' do
  16. expect(check.skip?).to be true
  17. end
  18. end
  19. end
  20. describe 'pass?' do
  21. context 'when there is not a kept rule' do
  22. it 'returns false' do
  23. expect(check.pass?).to be false
  24. end
  25. end
  26. context 'when there is a kept rule' do
  27. before { Fabricate(:rule) }
  28. it 'returns true' do
  29. expect(check.pass?).to be true
  30. end
  31. end
  32. end
  33. describe 'message' do
  34. it 'sends class name symbol to message instance' do
  35. allow(Admin::SystemCheck::Message).to receive(:new).with(:rules_check, nil, '/admin/rules')
  36. check.message
  37. expect(Admin::SystemCheck::Message).to have_received(:new).with(:rules_check, nil, '/admin/rules')
  38. end
  39. end
  40. end