helper_spec.rb 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. require 'rails_helper'
  2. require 'lib/import/helper_examples'
  3. RSpec.describe Import::Helper do
  4. it_behaves_like 'Import::Helper'
  5. context 'import mode' do
  6. it 'checks if import_mode is active' do
  7. expect(Setting).to receive(:get).with('import_mode').and_return(true)
  8. expect( described_class.check_import_mode ).to be true
  9. end
  10. it 'throws an exception if import_mode is disabled' do
  11. expect(Setting).to receive(:get).with('import_mode').and_return(false)
  12. expect { described_class.check_import_mode }.to raise_error(RuntimeError)
  13. end
  14. end
  15. context 'system init' do
  16. it 'checks if system_init_done is active' do
  17. expect(Setting).to receive(:get).with('system_init_done').and_return(false)
  18. expect( described_class.check_system_init_done ).to be true
  19. end
  20. it 'throws an exception if system_init_done is disabled' do
  21. expect(Setting).to receive(:get).with('system_init_done').and_return(true)
  22. expect { described_class.check_system_init_done }.to raise_error(RuntimeError)
  23. end
  24. end
  25. end