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: abb5a26060f72c7ec303786c5e8b13f4dc2ea13f (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
require 'spec_helper'

describe Gitlab::Graphs::Commits, lib: true do
  let!(:project) { create(:empty_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 }
    end

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