<commit_before>require "rails_helper"

describe ImportsController do
  describe "#create" do
    context "when the import fails to save" do
      it "apologizes to the user" do
        stub_current_user
        import = double("import", save: false)
        allow(Import).to(receive(:new).and_return(import))

        post :create, import: { ohlife_export: double("export") }

        expect(flash[:error]).to include "Sorry"
      end
    end

  end

  def stub_current_user
    allow(controller).to(receive(:current_user))
  end
end<commit_msg>Stub authenticate_user! as well<commit_after>require "rails_helper"

describe ImportsController do
  describe "#create" do
    context "when the import fails to save" do
      it "apologizes to the user" do
        stub_current_user
        import = double("import", save: false)
        allow(Import).to(receive(:new).and_return(import))

        post :create, import: { ohlife_export: double("export") }

        expect(flash[:error]).to include "Sorry"
      end
    end

  end

  def stub_current_user
    allow(controller).to(receive(:authenticate_user!))
    allow(controller).to(receive(:current_user))
  end
end
{'fraction_non_alphanumeric': 0.10472103004291845, 'fraction_numerical': 0.0, 'mean_word_length': 3.4166666666666665, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3859867', 'n_tokens_mistral': 359, 'n_tokens_neox': 340, 'n_words': 91}