You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: article_spec.rb
    path of file: ./repos/zammad/spec/models/ticket
    
    the code of the file until where you have to start completion: # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/

require 'rails_helper'
require 'models/application_model_examples'
require 'models/concerns/can_be_imported_examples'
require 'models/concerns/can_csv_import_examples'
require 'models/concerns/has_history_examples'
require 'models/concerns/has_object_manager_attributes_examples'
require 'models/ticket/article/has_ticket_contact_attributes_impact_examples'

RSpec.describe Ticket::Article, type: :model do
  subject(:article) { create(:ticket_article) }

  i
    
      def text_blob_with(user)
        "Lorem ipsum dolor <a data-mention-user-id='#{user.id}'>#{user.fullname}</a>"
      end

      let(:ticket)              { create(:ticket) }
      let(:agent_with_access)   { create(:agent, groups: [ticket.group]) }
      let(:user_without_access) { create(:agent) }

      let(:passing_body) { text_blob_with(agent_with_access) }
      let(:failing_body) { text_blob_with(user_without_access) }
      let(:partial_body) { text_blob_with(user_without_access) + text_blob_with(agent_with_access) }

      context 'when created in email parsing' do
        before { ApplicationHandleInfo.current = 'postmaster' }

        it 'silently ignores mentions if agent cannot mention users' do
          UserInfo.current_user_id = user_without_access.id
          record = create(:ticket_article, body: passing_body)

          expect(record).to be_persisted
          expect(Mention.count).to be_zero
        end

        it 'silently ignores mentions if given users cannot be mentioned' do
          UserInfo.current_user_id = agent_with_access.id
          article = build(:ticket_article, ticket: ticket, body: failing_body)
          article.save

          expect(article).to be_persisted
          expect(Mention.count).to eq(0)
        end

        it 'silently saves passing user while failing user is skipped' do
          UserInfo.current_user_id = agent_with_access.id

          article = create(:ticket_article, ticket: ticket, body: partial_body)

          expect(article).to be_persisted
          expect(Mention.count).to eq(1)
        end

        it 'mentioned user is added' do
          UserInfo.current_user_id = agent_with_access.id

          create(:ticket_article, ticket: ticket, body: passing_body)

          expect(article).to be_persisted
          expect(Mention.count).to eq(1)
        end
      end

      context 'when created with check_mentions_raises_error set to true' do
        it 'raises an error if agent cannot mention users' do
          UserInfo.current_user_id = create(:customer).id

          article = build(:ticket_article, ticket: ticket, body: passing_body)
          article.check_mentions_raises_error = true

          expect { article.save! }
            .to raise_error(Pundit::NotAuthorizedError)
          expect(Mention.count).to eq(0)
        end

        it 'raises an error if given users cannot be mentioned' do
          UserInfo.current_user_id = agent_with_access.id

          article = build(:ticket_article, ticket: ticket, body: failing_body)
          article.check_mentions_raises_error = true

          expect { article.save! }
            .to raise_error(ActiveRecord::RecordInvalid)
          expect(Mention.count).to eq(0)
        end

        it 'raises an error if one if given users cannot be mentioned' do
          UserInfo.current_user_id = agent_with_access.id

          article = build(:ticket_article, ticket: ticket, body: partial_body)
          article.check_mentions_raises_error = true

          expect { article.save! }
            .to raise_error(ActiveRecord::RecordInvalid)
          expect(Mention.count).to eq(0)
        end

        it 'mentioned user is added' do
          UserInfo.current_user_id = agent_with_access.id

          article = build(:ticket_article, ticket: ticket, body: passing_body)
          article.check_mentions_raises_error = true
          article.save!

          expect(article).to be_persisted
          expect(Mention.count).to eq(1)
        end
      end

      context 'when created with check_mentions_raises_error set to false' do
        it 'silently ignores mentions if agent cannot mention users' do
          UserInfo.current_user_id = create(:customer).id

          article = build(:ticket_article, ticket: ticket, body: failing_body)
          article.save

          expect(article).to be_persisted
          expect(Mention.count).to eq(0)
        end

        it 'silently ignores mentions if given users cannot be mentioned' do
          UserInfo.current_user_id = agent_with_access.id

          article = build(:ticket_article, ticket: ticket, body: failing_body)
          article.save

          expect(article).to be_persisted
          expect(Mention.count).to eq(0)
        end

        it 'silently saves passing user while failing user is skipped' do
          UserInfo.current_user_id = agent_with_access.id

          article = create(:ticket_article, ticket: ticket, body: partial_body)

          expect(article).to be_persisted
          expect(Mention.count).to eq(1)
        end

        it 'mentioned user is added' do
          UserInfo.current_user_id = agent_with_access.id

          create(:ticket_article, ticket: ticket, body: passing_body)

          expect(article).to be_persisted
          expect(Mention.count).to eq(1)
        end
      end
    end