require 'spec_helper' describe Commit do let(:project) { create :project } let(:commit) { project.repository.commit } 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 80 characters" do message = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit. Vivamus egestas lacinia lacus, sed rutrum mauris.' commit.stub(:safe_message).and_return(message) commit.title.should == "#{message[0..79]}…" end it "truncates a message with a newline before 80 characters at the newline" do message = commit.safe_message.split(" ").first commit.stub(:safe_message).and_return(message + "\n" + message) commit.title.should == message end it "does not truncates a message with a newline after 80 but less 100 characters" do message =<(txt){ subject.stub(safe_message: txt) } } # Include the subject in the repository stub. let(:extra_commits) { [subject] } end end