<commit_before>describe API::V1::ProceduresController, type: :controller do
  let!(:admin) { create(:administrateur, :with_api_token) }
  let!(:token) { admin.renew_api_token }

  it { expect(described_class).to be < APIController }

  describe 'GET show' do
    subject { get :show, params: { id: procedure_id, token: token } }

    context 'when procedure does not exist' do
      let(:procedure_id) { 999_999_999 }

      it { expect(subject.status).to eq(404) }
    end

    context 'when procedure does not belong to administrateur' do
      let(:procedure_id) { create(:procedure, administrateur: create(:administrateur)).id }

      it { expect(subject.status).to eq(404) }
    end

    context 'when procedure exist' do
      let(:procedure_id) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, administrateur: admin).id }

      it 'return REST code 200', :show_in_doc do
        expect(subject.status).to eq(200)
      end

      describe 'body' do
        let(:module_api_carto) { create(:module_api_carto, use_api_carto: true, quartiers_prioritaires: true, cadastre: true) }
        let(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative, module_api_carto: module_api_carto, administrateur: admin) }<commit_msg>Spec: simplify<commit_after>describe API::V1::ProceduresController, type: :controller do
  let!(:admin) { create(:administrateur, :with_api_token) }
  let!(:token) { admin.renew_api_token }

  it { expect(described_class).to be < APIController }

  describe 'GET show' do
    subject { get :show, params: { id: procedure_id, token: token } }

    context 'when procedure does not exist' do
      let(:procedure_id) { 999_999_999 }

      it { expect(subject.status).to eq(404) }
    end

    context 'when procedure does not belong to administrateur' do
      let(:procedure_id) { create(:procedure).id }

      it { expect(subject.status).to eq(404) }
    end

    context 'when procedure exist' do
      let(:procedure_id) { create(:procedure, administrateur: admin).id }

      it { expect(subject.status).to eq(200) }

      describe 'body' do
        let(:module_api_carto) { create(:module_api_carto, use_api_carto: true, quartiers_prioritaires: true, cadastre: true) }
        let(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative, module_api_carto: module_api_carto, administrateur: admin) }
{'fraction_non_alphanumeric': 0.11412151067323481, 'fraction_numerical': 0.01683087027914614, 'mean_word_length': 4.240860215053764, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '931512', 'n_tokens_mistral': 831, 'n_tokens_neox': 773, 'n_words': 182}