issue_3763_default_date_datetime_diff_clear_spec.rb 808 B

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Issue3763DefaultDateDatetimeDiffClear, current_user_id: 1, type: :db_migration do
  4. shared_examples 'clears diff' do |type:|
  5. it "clears #{type} diffs" do
  6. object = create(type)
  7. migrate
  8. object.reload
  9. expect(object.data_option).to include(diff: nil, future: true)
  10. end
  11. end
  12. include_examples 'clears diff', type: 'date'
  13. include_examples 'clears diff', type: 'datetime'
  14. def create(type)
  15. ObjectManager::Attribute.add(
  16. object: 'Ticket',
  17. name: 'test_date',
  18. display: __('Test Date'),
  19. data_type: type,
  20. data_option: {
  21. future: true,
  22. past: true,
  23. diff: 123,
  24. },
  25. )
  26. end
  27. end