<commit_before>require 'spec_helper'

describe DataImportsController do

  before :each do
    @user = FactoryGirl.create :user
    @data_import = FactoryGirl.create :data_import_running

    login_user_for_unit @user
  end

  context 'GET show' do

    it 'returns import process status successfully' do
      get :show, format: :json
      response.status.should eq 200
    end

  end

  context 'POST create' do

    before :each do
      String.any_instance.stub :tempfile
    end

    it 'redirects to feeds_path if successful' do
      User.any_instance.stub :import_subscriptions
      post :create, data_imports: {file: 'mock_file'}
      response.should redirect_to feeds_path
    end

    it 'redirects to feeds_path if an error happens' do
      SubscriptionsImporter.stub(:read_data_file).and_raise StandardError.new
      post :create, data_imports: {file: 'mock_file'}
      response.should redirect_to feeds_path
    end
  end

end<commit_msg>Fixed unit test.<commit_after>require 'spec_helper'

describe DataImportsController do

  before :each do
    @user = FactoryGirl.create :user
    @data_import = FactoryGirl.create :data_import_running

    login_user_for_unit @user
  end

  context 'GET show' do

    it 'returns import process status successfully' do
      get :show, format: :json
      response.status.should eq 200
    end

  end

  context 'POST create' do

    before :each do
      String.any_instance.stub :tempfile
    end

    it 'redirects to feeds_path if successful' do
      User.any_instance.stub :import_subscriptions
      post :create, data_import: {file: 'mock_file'}
      response.should redirect_to feeds_path
    end

    it 'redirects to feeds_path if an error happens' do
      SubscriptionsImporter.stub(:read_data_file).and_raise StandardError.new
      post :create, data_import: {file: 'mock_file'}
      response.should redirect_to feeds_path
    end
  end

end
{'fraction_non_alphanumeric': 0.06520605112154408, 'fraction_numerical': 0.003129890453834116, 'mean_word_length': 3.28125, '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': '3394010', 'n_tokens_mistral': 601, 'n_tokens_neox': 568, 'n_words': 175}