time_zone_spec.rb 879 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Setting::Validation::TimeZone do
  4. let(:setting_name) { 'timezone_default' }
  5. context 'when given value is blank' do
  6. it 'does raise an error' do
  7. expect { Setting.set(setting_name, '') }
  8. .to raise_error(ActiveRecord::RecordInvalid, 'Validation failed: Time zone is required.')
  9. end
  10. end
  11. context 'when given value is non-existant identifier' do
  12. it 'does raise an error' do
  13. expect { Setting.set(setting_name, 'blablabla') }
  14. .to raise_error(ActiveRecord::RecordInvalid, 'Validation failed: Given time zone is not valid.')
  15. end
  16. end
  17. context 'when given value is valid time zone identifier' do
  18. it 'does not raise an error' do
  19. expect { Setting.set(setting_name, 'UTC') }.not_to raise_error
  20. end
  21. end
  22. end