issue_5091_timezone_default_spec.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Issue5091TimezoneDefault, type: :db_migration do
  4. subject(:setting) { Setting.find_by(name: 'timezone_default') }
  5. describe 'timezone value' do
  6. context 'when timezone_default is empty' do
  7. before do
  8. setting.state_current = { value: nil }
  9. setting.save!(validate: false)
  10. end
  11. it 'sets timezone_default to UTC' do
  12. migrate
  13. expect(setting.reload.state_current).to include(value: 'UTC')
  14. end
  15. end
  16. context 'when timezone_default is present' do
  17. let(:sample_tz) { 'Europe/Vilnius' }
  18. before do
  19. setting.state_current = { value: sample_tz }
  20. setting.save(validate: false)
  21. end
  22. it 'does not change timezone_default' do
  23. migrate
  24. expect(setting.reload.state_current).to include(value: sample_tz)
  25. end
  26. end
  27. end
  28. describe 'validations preferences' do
  29. before do
  30. setting.preferences = {}
  31. setting.save!
  32. end
  33. it 'adds validations preference' do
  34. migrate
  35. expect(setting.reload.preferences)
  36. .to include('validations' => include('Setting::Validation::TimeZone'))
  37. end
  38. end
  39. end