<commit_before>require 'rails_helper'

RSpec.describe PlotsHelper, type: :helper do

  describe "#link_to_featured_plant" do

    let(:plot) { build(:plot, id: 1) }

    context "plot has no featured plant" do
      before { plot.featured_plant = nil }
      it "returns 'Unassigned' with a link to edit the plot" do
        expect(helper.link_to_featured_plant(plot)).to match "Unassigned. <a href=\"/plots/1/edit\">Add one?</a>"
      end
    end

    context "plot has a featured plant" do
      it "returns a link to the featured plant" do
        expect(helper.link_to_featured_plant(plot)).to match "<a href=\"/plants/.*\">Plant Example</a>"
      end
    end

  end

end<commit_msg>Update plots helper spec to accomodate users that are not logged in<commit_after>require 'rails_helper'

RSpec.describe PlotsHelper, type: :helper do

  describe "#link_to_featured_plant" do

    let(:plot) { build(:plot, id: 1) }
    let(:current_user) { build(:user, :admin) }

    context "plot has no featured plant and admin is logged in" do
      before { plot.featured_plant = nil }
      before { allow(helper).to receive(:logged_in?).and_return(true) }
      before { allow(helper).to receive(:admin?).and_return(true) }
      it "returns 'Unassigned' with a link to edit the plot" do
        expect(helper.link_to_featured_plant(plot)).to match "Unassigned. <a href=\"/plots/1/edit\">Add one?</a>"
      end
    end

    context "plot has no featured plant and admin is not logged in" do
      before { plot.featured_plant = nil }
      it "returns 'n/a'" do
        expect(helper.link_to_featured_plant(plot)).to match "n/a"
      end
    end

    context "plot has a featured plant" do
      it "returns a link to the featured plant" do
        expect(helper.link_to_featured_plant(plot)).to match "<a href=\"/plants/.*\">Plant Example</a>"
      end
    end

  end

end
{'fraction_non_alphanumeric': 0.11544628540887227, 'fraction_numerical': 0.002137894174238375, 'mean_word_length': 3.1052631578947367, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '7299788', 'n_tokens_mistral': 612, 'n_tokens_neox': 591, 'n_words': 185}