Dont init repo on every create(:repo)

This commit is contained in:
Dmitriy Zaporozhets 2013-04-01 17:27:44 +03:00
parent 541d899410
commit 9a26e9a0d6
7 changed files with 18 additions and 11 deletions

View file

@ -86,9 +86,9 @@ FactoryGirl.define do
target_branch "master" # pretend bcf03b5d~3
source_branch "stable" # pretend bcf03b5d
st_commits do
[Commit.new(project.repo.commit('bcf03b5d')),
Commit.new(project.repo.commit('bcf03b5d~1')),
Commit.new(project.repo.commit('bcf03b5d~2'))]
[Commit.new(project.repository.commit('bcf03b5d')),
Commit.new(project.repository.commit('bcf03b5d~1')),
Commit.new(project.repository.commit('bcf03b5d~2'))]
end
st_diffs do
project.repo.diff("bcf03b5d~3", "bcf03b5d")
@ -120,6 +120,7 @@ FactoryGirl.define do
factory :note_on_merge_request_diff, traits: [:on_merge_request, :on_diff]
trait :on_commit do
project factory: :project_with_code
commit_id "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a"
noteable_type "Commit"
end
@ -129,6 +130,7 @@ FactoryGirl.define do
end
trait :on_merge_request do
project factory: :project_with_code
noteable_id 1
noteable_type "MergeRequest"
end

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe Commit do
let(:commit) { create(:project).repository.commit }
let(:commit) { create(:project_with_code).repository.commit }
describe '#title' do

View file

@ -81,7 +81,7 @@ describe GollumWiki do
end
it "raises CouldNotCreateWikiError if it can't create the wiki repository" do
Gitlab::Shell.any_instance.stub(:add_repository).and_return(false)
GollumWiki.any_instance.stub(:init_repo).and_return(false)
expect { GollumWiki.new(project, user).wiki }.to raise_exception(GollumWiki::CouldNotCreateWikiError)
end
end

View file

@ -17,11 +17,12 @@ module TestEnv
repos_path = Rails.root.join('tmp', 'test-git-base-path')
Gitlab.config.gitlab_shell.stub(repos_path: repos_path)
Gitlab::Shell.any_instance.stub(:add_repository) do |path|
GollumWiki.any_instance.stub(:init_repo) do |path|
create_temp_repo(File.join(repos_path, "#{path}.git"))
end
Gitlab::Shell.any_instance.stub(
add_repository: true,
mv_repository: true,
remove_repository: true,
add_key: true,