Project.repository should never be nil so you can call repository.exists? or repository.empty?
Also specify separate project factory for project with filled repo
This commit is contained in:
parent
49b024f5f5
commit
541d899410
13 changed files with 51 additions and 54 deletions
|
@ -25,7 +25,7 @@ FactoryGirl.define do
|
|||
|
||||
factory :project do
|
||||
sequence(:name) { |n| "project#{n}" }
|
||||
path { 'gitlabhq' }
|
||||
path { name.downcase.gsub(/\s/, '_') }
|
||||
creator
|
||||
end
|
||||
|
||||
|
@ -34,6 +34,10 @@ FactoryGirl.define do
|
|||
issues_tracker_id { "project_name_in_redmine" }
|
||||
end
|
||||
|
||||
factory :project_with_code, parent: :project do
|
||||
path { 'gitlabhq' }
|
||||
end
|
||||
|
||||
factory :group do
|
||||
sequence(:name) { |n| "group#{n}" }
|
||||
path { name.downcase.gsub(/\s/, '_') }
|
||||
|
|
|
@ -7,7 +7,7 @@ describe GitlabMarkdownHelper do
|
|||
let!(:project) { create(:project) }
|
||||
|
||||
let(:user) { create(:user, username: 'gfm') }
|
||||
let(:commit) { CommitDecorator.decorate(Commit.new(project.repository.commit)) }
|
||||
let(:commit) { project.repository.commit) }
|
||||
let(:issue) { create(:issue, project: project) }
|
||||
let(:merge_request) { create(:merge_request, project: project) }
|
||||
let(:snippet) { create(:snippet, project: project) }
|
||||
|
|
|
@ -3,35 +3,32 @@ require 'spec_helper'
|
|||
describe Commit do
|
||||
let(:commit) { create(:project).repository.commit }
|
||||
|
||||
describe CommitDecorator do
|
||||
let(:decorator) { CommitDecorator.new(commit) }
|
||||
|
||||
describe '#title' do
|
||||
it "returns no_commit_message when safe_message is blank" do
|
||||
decorator.stub(:safe_message).and_return('')
|
||||
decorator.title.should == "--no commit message"
|
||||
end
|
||||
describe '#title' do
|
||||
it "returns no_commit_message when safe_message is blank" do
|
||||
commit.stub(:safe_message).and_return('')
|
||||
commit.title.should == "--no commit message"
|
||||
end
|
||||
|
||||
it "truncates a message without a newline at 70 characters" do
|
||||
message = commit.safe_message * 10
|
||||
it "truncates a message without a newline at 70 characters" do
|
||||
message = commit.safe_message * 10
|
||||
|
||||
decorator.stub(:safe_message).and_return(message)
|
||||
decorator.title.should == "#{message[0..69]}…"
|
||||
end
|
||||
commit.stub(:safe_message).and_return(message)
|
||||
commit.title.should == "#{message[0..69]}…"
|
||||
end
|
||||
|
||||
it "truncates a message with a newline before 80 characters at the newline" do
|
||||
message = commit.safe_message.split(" ").first
|
||||
it "truncates a message with a newline before 80 characters at the newline" do
|
||||
message = commit.safe_message.split(" ").first
|
||||
|
||||
decorator.stub(:safe_message).and_return(message + "\n" + message)
|
||||
decorator.title.should == message
|
||||
end
|
||||
commit.stub(:safe_message).and_return(message + "\n" + message)
|
||||
commit.title.should == message
|
||||
end
|
||||
|
||||
it "truncates a message with a newline after 80 characters at 70 characters" do
|
||||
message = (commit.safe_message * 10) + "\n"
|
||||
it "truncates a message with a newline after 80 characters at 70 characters" do
|
||||
message = (commit.safe_message * 10) + "\n"
|
||||
|
||||
decorator.stub(:safe_message).and_return(message)
|
||||
decorator.title.should == "#{message[0..69]}…"
|
||||
end
|
||||
commit.stub(:safe_message).and_return(message)
|
||||
commit.title.should == "#{message[0..69]}…"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ describe Project do
|
|||
end
|
||||
|
||||
describe :update_merge_requests do
|
||||
let(:project) { create(:project) }
|
||||
let(:project) { create(:project_with_code) }
|
||||
|
||||
before do
|
||||
@merge_request = create(:merge_request, project: project)
|
||||
|
@ -187,11 +187,7 @@ describe Project do
|
|||
let(:project) { create(:project) }
|
||||
|
||||
it "should return valid repo" do
|
||||
project.repository.should be_kind_of(Gitlab::Git::Repository)
|
||||
end
|
||||
|
||||
it "should return nil" do
|
||||
Project.new(path: "empty").repository.should be_nil
|
||||
project.repository.should be_kind_of(Repository)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -249,7 +245,7 @@ describe Project do
|
|||
end
|
||||
|
||||
describe :open_branches do
|
||||
let(:project) { create(:project) }
|
||||
let(:project) { create(:project_with_code) }
|
||||
|
||||
before do
|
||||
project.protected_branches.create(name: 'master')
|
||||
|
|
|
@ -47,11 +47,7 @@ Spork.prefork do
|
|||
config.use_transactional_fixtures = false
|
||||
|
||||
config.before do
|
||||
# Use tmp dir for FS manipulations
|
||||
temp_repos_path = Rails.root.join('tmp', 'test-git-base-path')
|
||||
Gitlab.config.gitlab_shell.stub(repos_path: temp_repos_path)
|
||||
FileUtils.rm_rf temp_repos_path
|
||||
FileUtils.mkdir_p temp_repos_path
|
||||
TestEnv.init
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue