<commit_before>require 'spec_helper'

describe RepositoriesController do
  let(:project) { FactoryGirl.build(:project) }

  pending 'It is not correctly mocked and still calls Kalibro' do
  describe 'new' do
    before :each do
      sign_in FactoryGirl.create(:user)
      get :new, project_id: project.id.to_s
    end

    it { should respond_with(:success) }
    it { should render_template(:new) }
  end
  end

  describe 'create' do
    before do
      sign_in FactoryGirl.create(:user)
      @subject = FactoryGirl.build(:repository, project_id: project.id)
      @subject_params = Hash[FactoryGirl.attributes_for(:repository).map { |k,v| [k.to_s, v.to_s] }] #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with symbols and integers
    end

    context 'when the current user owns the project' do<commit_msg>Unit test for RepositoriesController new method<commit_after>require 'spec_helper'

describe RepositoriesController do
  let(:project) { FactoryGirl.build(:project) }

  describe 'new' do
    before :each do
      sign_in FactoryGirl.create(:user)
    end

    context 'when the current user owns the project' do
      before :each do
        Repository.expects(:repository_types).returns([])
        subject.expects(:check_repository_ownership).returns true

        get :new, project_id: project.id.to_s
      end

      it { should respond_with(:success) }
      it { should render_template(:new) }
    end

    context "when the current user doesn't owns the project" do
      before :each do
        get :new, project_id: project.id.to_s
      end

      it { should respond_with(:redirect) }
    end
  end

  describe 'create' do
    before do
      sign_in FactoryGirl.create(:user)
      @subject = FactoryGirl.build(:repository, project_id: project.id)
      @subject_params = Hash[FactoryGirl.attributes_for(:repository).map { |k,v| [k.to_s, v.to_s] }] #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with symbols and integers
    end

    context 'when the current user owns the project' do
{'fraction_non_alphanumeric': 0.08697718631178707, 'fraction_numerical': 0.0, 'mean_word_length': 3.488272921108742, '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': '1684503', 'n_tokens_mistral': 633, 'n_tokens_neox': 600, 'n_words': 193}