Welcome to mirror list, hosted at ThFree Co, Russian Federation.

commits_spec.rb « graphs « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f92c7fb11a18be41f9fc0b55e6f3e652898275fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::Graphs::Commits do
  let!(:project) { create(:project, :public) }

  let!(:commit1) { create(:commit, git_commit: RepoHelpers.sample_commit, project: project, committed_date: Time.now) }
  let!(:commit1_yesterday) { create(:commit, git_commit: RepoHelpers.sample_commit, project: project, committed_date: 1.day.ago)}

  let!(:commit2) { create(:commit, git_commit: RepoHelpers.another_sample_commit, project: project, committed_date: Time.now) }

  describe '#commit_per_day' do
    context 'when range is only commits from today' do
      subject { described_class.new([commit2, commit1]).commit_per_day }

      it { is_expected.to eq 2 }
    end
  end

  context 'when range is only commits from today' do
    subject { described_class.new([commit2, commit1]) }

    describe '#commit_per_day' do
      it { expect(subject.commit_per_day).to eq 2 }
    end

    describe '#duration' do
      it { expect(subject.duration).to eq 0 }
    end
  end

  context 'with commits from yesterday and today' do
    subject { described_class.new([commit2, commit1_yesterday]) }

    describe '#commit_per_day' do
      it { expect(subject.commit_per_day).to eq 1.0 }
    end

    describe '#duration' do
      it { expect(subject.duration).to eq 1 }
    end
  end
end