diff options
-rw-r--r-- | app/models/commit.rb | 7 | ||||
-rw-r--r-- | spec/models/commit_spec.rb | 9 |
2 files changed, 7 insertions, 9 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 09fe9f11dd4..594972ad344 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -193,12 +193,9 @@ class Commit # otherwise returns commit message without first line def description return safe_message if full_title.length >= 100 + return no_commit_message if safe_message.blank? - if safe_message.blank? - no_commit_message - else - safe_message.split("\n", 2)[1].try(:chomp) - end + safe_message.split("\n", 2)[1].try(:chomp) end def description? diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index ab241b83077..d5f88e930d4 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -225,11 +225,12 @@ eos end describe 'description' do - it "returns no_commit_message when safe_message is blank" do - allow(commit).to receive(:safe_message).and_return('') - expect(commit.description).to eq("--no commit message") + it 'returns no_commit_message when safe_message is blank' do + allow(commit).to receive(:safe_message).and_return(nil) + + expect(commit.description).to eq('--no commit message') end - + it 'returns description of commit message if title less than 100 characters' do message = <<eos Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit. |