issue_2368_add_indices_to_histories_and_tickets_spec.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Issue2368AddIndicesToHistoriesAndTickets, db_strategy: :reset, type: :db_migration do
  4. before { without_index(table, column: columns) }
  5. context 'for histories table' do
  6. let(:table) { :histories }
  7. context 'and related_o_id column' do
  8. let(:columns) { %i[related_o_id] }
  9. it 'adds an index' do
  10. expect { migrate }.to change { index_exists?(table, columns) }.to(true)
  11. end
  12. end
  13. context 'and related_history_object_id column' do
  14. let(:columns) { %i[related_history_object_id] }
  15. it 'adds an index' do
  16. expect { migrate }.to change { index_exists?(table, columns) }.to(true)
  17. end
  18. end
  19. context 'and o_id, history_object_id, & related_o_id columns' do
  20. let(:columns) { %i[o_id history_object_id related_o_id] }
  21. it 'adds a composite index' do
  22. expect { migrate }.to change { index_exists?(table, columns) }.to(true)
  23. end
  24. end
  25. end
  26. context 'for tickets table' do
  27. let(:table) { :tickets }
  28. context 'and group_id & state_id columns' do
  29. let(:columns) { %i[group_id state_id] }
  30. it 'adds a composite index' do
  31. expect { migrate }.to change { index_exists?(table, columns) }.to(true)
  32. end
  33. end
  34. context 'and group_id, state_id, & owner_id columns' do
  35. let(:columns) { %i[group_id state_id owner_id] }
  36. it 'adds a composite index' do
  37. expect { migrate }.to change { index_exists?(table, columns) }.to(true)
  38. end
  39. end
  40. end
  41. end