<commit_before>require 'rails_helper'

describe CropsController do
  shared_context 'login as wrangler' do
    login_member(:crop_wrangling_member)
  end

  subject { response }

  describe "GET crop wrangler homepage" do
    describe 'fetches the crop wrangler homepage' do
      context 'anonymous' do
        before { get :wrangle }

        it { is_expected.not_to be_success }
      end

      context 'wrangler' do
        include_context 'login as wrangler'
        before { get :wrangle }

        it { is_expected.to be_success }
        it { is_expected.to render_template("crops/wrangle") }
        it { expect(assigns[:crop_wranglers]).to eq(Role.crop_wranglers) }
      end
    end
  end

  describe "GET crop hierarchy " do
    describe 'fetches the crop hierarchy page' do
      context 'wrangler' do
        include_context 'login as wrangler'
        before { get :hierarchy }

        it { is_expected.to be_success }
        it { is_expected.to render_template("crops/hierarchy") }
      end
    end
  end

  describe "GET crop search" do
    describe 'fetches the crop search page' do
      before { get :search }

      it { is_expected.to be_success }
      it { is_expected.to render_template("crops/search") }
    end
  end

  describe "GET RSS feed" do
    describe "returns an RSS feed" do
      before { get :index, format: "rss" }

      it { is_expected.to be_success }
      it { is_expected.to render_template("crops/index") }
      it { expect(response.content_type).to eq("application/rss+xml") }
    end
  end

  describe 'DELETE destroy' do
    subject { delete :destroy, params: { slug: crop.to_param } }
    let!(:crop) { FactoryBot.create :crop }

    context 'not logged in' do
      it { expect { subject }.not_to change(Crop, :count) }
    end

    context 'logged in as member' do
      it { expect { subject }.not_to change(Crop, :count) }
    end

    context 'wrangler' do<commit_msg>Auto corrected by following Lint Ruby RSpecEmptyLine<commit_after>require 'rails_helper'

describe CropsController do
  shared_context 'login as wrangler' do
    login_member(:crop_wrangling_member)
  end

  subject { response }

  describe "GET crop wrangler homepage" do
    describe 'fetches the crop wrangler homepage' do
      context 'anonymous' do
        before { get :wrangle }

        it { is_expected.not_to be_success }
      end

      context 'wrangler' do
        include_context 'login as wrangler'
        before { get :wrangle }

        it { is_expected.to be_success }
        it { is_expected.to render_template("crops/wrangle") }
        it { expect(assigns[:crop_wranglers]).to eq(Role.crop_wranglers) }
      end
    end
  end

  describe "GET crop hierarchy " do
    describe 'fetches the crop hierarchy page' do
      context 'wrangler' do
        include_context 'login as wrangler'
        before { get :hierarchy }

        it { is_expected.to be_success }
        it { is_expected.to render_template("crops/hierarchy") }
      end
    end
  end

  describe "GET crop search" do
    describe 'fetches the crop search page' do
      before { get :search }

      it { is_expected.to be_success }
      it { is_expected.to render_template("crops/search") }
    end
  end

  describe "GET RSS feed" do
    describe "returns an RSS feed" do
      before { get :index, format: "rss" }

      it { is_expected.to be_success }
      it { is_expected.to render_template("crops/index") }
      it { expect(response.content_type).to eq("application/rss+xml") }
    end
  end

  describe 'DELETE destroy' do
    subject { delete :destroy, params: { slug: crop.to_param } }

    let!(:crop) { FactoryBot.create :crop }

    context 'not logged in' do
      it { expect { subject }.not_to change(Crop, :count) }
    end

    context 'logged in as member' do
      it { expect { subject }.not_to change(Crop, :count) }
    end

    context 'wrangler' do
{'fraction_non_alphanumeric': 0.08722421754746024, 'fraction_numerical': 0.0, 'mean_word_length': 2.6439252336448598, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7577223', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1202, 'n_words': 367}