diff options
author | Sean McGivern <sean@gitlab.com> | 2018-08-21 10:53:43 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-08-21 11:41:25 +0100 |
commit | 5759bfe029b5abb1c3550f702fc5a66da21cfa56 (patch) | |
tree | 3a18d630e8eca69139d5e009547193d50944954b | |
parent | e3f13c9e0a121ef8ed9d60f7239f70d3d0e7815f (diff) | |
download | gitlab-ce-5759bfe029b5abb1c3550f702fc5a66da21cfa56.tar.gz |
Make it clearer when Commit#description returns no_commit_message
-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. |