issue_1573_multi_orga_spec.rb 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Issue1573MultiOrga, type: :db_migration do
  4. context 'when overview is given' do
  5. before do
  6. Overview.find_by(link: 'my_organization_tickets').update(view: {
  7. 'd' => %w[title customer state created_at],
  8. 's' => %w[number title customer state created_at],
  9. 'm' => %w[number title customer state created_at],
  10. 'view_mode_default' => 's'
  11. })
  12. migrate
  13. end
  14. it 'does add new field organization_ids' do
  15. expect(ObjectManager::Attribute.exists?(name: 'organization_ids')).to be true
  16. end
  17. it 'does update the ticket organization field' do
  18. attribute = ObjectManager::Attribute.find_by(name: 'organization_id', object_lookup_id: ObjectLookup.by_name('Ticket'))
  19. expect(attribute.data_type).to eq('autocompletion_ajax_customer_organization')
  20. end
  21. it 'does update ticket overview my_organization_tickets view d' do
  22. overview = Overview.find_by(link: 'my_organization_tickets')
  23. expect(overview.view[:d]).to include('organization')
  24. end
  25. it 'does update ticket overview my_organization_tickets view s' do
  26. overview = Overview.find_by(link: 'my_organization_tickets')
  27. expect(overview.view[:s]).to include('organization')
  28. end
  29. it 'does update ticket overview my_organization_tickets view m' do
  30. overview = Overview.find_by(link: 'my_organization_tickets')
  31. expect(overview.view[:m]).to include('organization')
  32. end
  33. it 'does update screens for organzation fields (name)' do
  34. field = ObjectManager::Attribute.find_by(name: 'name', object_lookup_id: ObjectLookup.by_name('Organization'))
  35. expect(field.screens[:view][:'ticket.customer'][:shown]).to be(true)
  36. end
  37. it 'does update screens for organzation fields (note)' do
  38. field = ObjectManager::Attribute.find_by(name: 'note', object_lookup_id: ObjectLookup.by_name('Organization'))
  39. expect(field.screens[:view][:'ticket.customer'][:shown]).to be(false)
  40. end
  41. end
  42. context 'when overview is missing' do
  43. before do
  44. Overview.find_by(link: 'my_organization_tickets').destroy
  45. end
  46. it 'does not crash if the overview does not exist' do
  47. migrate
  48. end
  49. end
  50. end