writes_to_ticket_history_examples.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec.shared_examples 'TagWritesToTicketHistory' do
  3. subject { create(described_class.name.underscore) }
  4. # The concern is for the tag model, but the shared example needs to be loaded in the ticket test.
  5. it 'can only be loaded for tickets' do
  6. expect(described_class).to eq Ticket
  7. end
  8. it 'creates a ticket history entry for tag_add' do
  9. subject.tag_add('foo', 1)
  10. expect(subject.history_get.last).to include(
  11. 'object' => described_class.name,
  12. 'o_id' => subject.id,
  13. 'type' => 'added',
  14. 'attribute' => 'tag',
  15. 'value_to' => 'foo',
  16. 'value_from' => nil
  17. )
  18. end
  19. it 'creates a ticket history entry for tag_remove' do
  20. subject.tag_add('foo', 1)
  21. subject.tag_remove('foo', 1)
  22. expect(subject.history_get.last).to include(
  23. 'object' => described_class.name,
  24. 'o_id' => subject.id,
  25. 'type' => 'removed',
  26. 'attribute' => 'tag',
  27. 'value_to' => 'foo',
  28. 'value_from' => nil
  29. )
  30. end
  31. end