issue_3647_custom_object_attribute_integer_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Issue3647CustomObjectAttributeInteger, type: :db_migration do
  4. let(:integer_valid) { create(:object_manager_attribute_integer) }
  5. let(:integer_max_over_max) do
  6. object = build(:object_manager_attribute_integer, data_option: { default: 0, min: 0, max: 9_999_999_999 })
  7. object.save(validate: false)
  8. object
  9. end
  10. let(:integer_min_over_max) do
  11. object = build(:object_manager_attribute_integer, data_option: { default: 0, min: 9_999_999_999, max: 99_999_999_999 })
  12. object.save(validate: false)
  13. object
  14. end
  15. it 'leaves valid integer intact' do
  16. expect { migrate }
  17. .not_to change { integer_valid.data_option[:max] }
  18. end
  19. it 'lowers max if it is too big' do
  20. expect { migrate }
  21. .to change { integer_max_over_max.reload.data_option[:max] }
  22. .to 2_147_483_647
  23. end
  24. it 'lowers min if it is too big' do
  25. expect { migrate }
  26. .to change { integer_min_over_max.reload.data_option[:min] }
  27. .to 2_147_483_647
  28. end
  29. end