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:
Dmitriy Zaporozhets 2013-04-01 16:56:25 +03:00
parent 49b024f5f5
commit 541d899410
13 changed files with 51 additions and 54 deletions

View file

@ -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

View file

@ -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')