issue_2368_add_indices_to_histories_and_tickets_spec.rb 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. require 'rails_helper'
  2. RSpec.describe Issue2368AddIndicesToHistoriesAndTickets, type: :db_migration do
  3. self.use_transactional_tests = false # see comments on #without_index method
  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