2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe Gitlab::Graphs::Commits do
|
|
|
|
let!(:project) { create(:project, :public) }
|
2016-08-24 12:49:21 +05:30
|
|
|
|
|
|
|
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 }
|
2019-12-21 20:55:43 +05:30
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
it { is_expected.to eq 2 }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when range is only commits from today' do
|
|
|
|
subject { described_class.new([commit2, commit1]) }
|
2019-12-21 20:55:43 +05:30
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
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]) }
|
2019-12-21 20:55:43 +05:30
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
describe '#commit_per_day' do
|
2018-11-18 11:00:15 +05:30
|
|
|
it { expect(subject.commit_per_day).to eq 1.0 }
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
describe '#duration' do
|
|
|
|
it { expect(subject.duration).to eq 1 }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|