diff options
author | Dan Dunckel <dldunckel@gmail.com> | 2016-09-20 19:07:52 +0300 |
---|---|---|
committer | Dan Dunckel <dldunckel@gmail.com> | 2016-09-20 20:15:43 +0300 |
commit | 02d69091bc1d2ea4d14731b103efd5a5e2c9f040 (patch) | |
tree | 4111492d5b2dc24dc4b7cc25e0e6946cdaac6685 /spec/lib/gitlab/git_spec.rb | |
parent | 422c90251d9dbe42d5a8c852124398d1beae9176 (diff) |
Add spec covering 'committer_hash'
Diffstat (limited to 'spec/lib/gitlab/git_spec.rb')
-rw-r--r-- | spec/lib/gitlab/git_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/lib/gitlab/git_spec.rb b/spec/lib/gitlab/git_spec.rb new file mode 100644 index 00000000000..219198eff60 --- /dev/null +++ b/spec/lib/gitlab/git_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' + +describe Gitlab::Git, lib: true do + let(:committer_email) { FFaker::Internet.email } + + # I have to remove periods from the end of the name + # This happened when the user's name had a suffix (i.e. "Sr.") + # This seems to be what git does under the hood. For example, this commit: + # + # $ git commit --author='Foo Sr. <foo@example.com>' -m 'Where's my trailing period?' + # + # results in this: + # + # $ git show --pretty + # ... + # Author: Foo Sr <foo@example.com> + # ... + let(:committer_name) { FFaker::Name.name.chomp("\.") } + + describe 'committer_hash' do + it "returns a hash containing the given email and name" do + committer_hash = Gitlab::Git::committer_hash(email: committer_email, name: committer_name) + + expect(committer_hash[:email]).to eq(committer_email) + expect(committer_hash[:name]).to eq(committer_name) + expect(committer_hash[:time]).to be_a(Time) + end + + context 'when email is nil' do + it "returns nil" do + committer_hash = Gitlab::Git::committer_hash(email: nil, name: committer_name) + + expect(committer_hash).to be_nil + end + end + + context 'when name is nil' do + it "returns nil" do + committer_hash = Gitlab::Git::committer_hash(email: committer_email, name: nil) + + expect(committer_hash).to be_nil + end + end + end +end |