answer_spec.rb 824 B

1234567891011121314151617181920212223242526
  1. # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
  2. require 'rails_helper'
  3. require 'models/concerns/checks_kb_client_notification_examples'
  4. require 'models/concerns/has_tags_examples'
  5. require 'models/contexts/factory_context'
  6. RSpec.describe KnowledgeBase::Answer, type: :model, current_user_id: 1 do
  7. subject!(:kb_answer) { create(:knowledge_base_answer) }
  8. it_behaves_like 'HasTags'
  9. include_context 'factory'
  10. it_behaves_like 'ChecksKbClientNotification'
  11. it { is_expected.not_to validate_presence_of(:category_id) }
  12. it { is_expected.to belong_to(:category) }
  13. it { expect(kb_answer.attachments).to be_blank }
  14. context 'with attachment' do
  15. subject(:kb_answer) { create(:knowledge_base_answer, :with_attachment) }
  16. it { expect(kb_answer.attachments).to be_present }
  17. end
  18. end