attribute_spec.rb 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Overview with custom attributes', authenticated_as: :authenticate, db_strategy: :reset, type: :system do
  4. let(:attribute) { create(:object_manager_attribute_boolean) }
  5. let(:agent) { create(:agent, groups: [Group.find_by(name: 'Users')]) }
  6. let(:overview) { nil }
  7. let(:ticket) { nil }
  8. def authenticate
  9. agent
  10. attribute
  11. ObjectManager::Attribute.migration_execute
  12. overview
  13. ticket
  14. true
  15. end
  16. before do
  17. visit "ticket/view/#{overview.link}"
  18. end
  19. context 'when the custom attribute used in a view in an overview' do
  20. let(:overview) do
  21. create(:overview,
  22. view: { s: ['title', 'number', attribute.name],
  23. view_mode_default: 's' })
  24. end
  25. it 'shows the custom attribute display description' do
  26. within :active_content do
  27. expect(page).to have_text attribute.display.to_s.upcase
  28. end
  29. end
  30. end
  31. context 'when the custom attribute is used as condition in an overview' do
  32. let(:overview) do
  33. create(:overview,
  34. condition: { "ticket.#{attribute.name}" => { operator: 'is', value: true } },
  35. view: { s: ['title', 'number', attribute.name],
  36. view_mode_default: 's' })
  37. end
  38. context 'with no ticket with custom attribute value true' do
  39. it 'shows no entries' do
  40. within :active_content do
  41. expect(page).to have_text 'NO ENTRIES'
  42. end
  43. end
  44. end
  45. context 'with a ticket with custom attribute value true' do
  46. let(:ticket) { create(:ticket, group: Group.find_by(name: 'Users'), attribute.name => true) }
  47. it 'shows the ticket' do
  48. within :active_content do
  49. expect(page).to have_text attribute.display.to_s.upcase
  50. expect(page).to have_text ticket.title
  51. end
  52. end
  53. end
  54. end
  55. end