adds_metadata_general_spec.rb 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. require 'rails_helper'
  2. RSpec.describe Ticket::Article::AddsMetadataGeneral do
  3. let(:agent) { create(:agent) }
  4. context 'when Agent creates Article' do
  5. shared_examples 'not including email in from' do |factory|
  6. subject(:article) { create(:ticket_article, factory, ticket: ticket, created_by_id: agent.id, updated_by_id: agent.id ) }
  7. let(:ticket) { create(:ticket) }
  8. let!(:agent) { create(:agent, groups: [ticket.group]) }
  9. it "doesn't include email in from" do
  10. expect(article.from).not_to include agent.email
  11. end
  12. end
  13. it_behaves_like 'not including email in from', :outbound_phone
  14. it_behaves_like 'not including email in from', :outbound_web
  15. context 'when as Customer' do
  16. subject(:article) { create(:ticket_article, :inbound_phone, ticket: ticket) }
  17. let(:customer) { agent }
  18. let(:ticket) { create(:ticket, customer_id: customer.id) }
  19. it 'includes email in from' do
  20. expect(article.from).not_to include agent.email
  21. end
  22. end
  23. end
  24. end