BigW Consortium Gitlab

git_spec.rb 937 Bytes
Newer Older
1 2 3
require 'spec_helper'

describe Gitlab::Git, lib: true do
4 5
  let(:committer_email) { 'user@example.org' }
  let(:committer_name) { 'John Doe' }
6 7 8

  describe 'committer_hash' do
    it "returns a hash containing the given email and name" do
9
      committer_hash = Gitlab::Git.committer_hash(email: committer_email, name: committer_name)
10 11 12 13 14 15 16 17

      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
18
        committer_hash = Gitlab::Git.committer_hash(email: nil, name: committer_name)
19 20 21 22 23 24 25

        expect(committer_hash).to be_nil
      end
    end

    context 'when name is nil' do
      it "returns nil" do
26
        committer_hash = Gitlab::Git.committer_hash(email: committer_email, name: nil)
27 28 29 30 31 32

        expect(committer_hash).to be_nil
      end
    end
  end
end