diff options
author | James Lopez <james@jameslopez.es> | 2016-11-23 15:04:06 +0300 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-01-17 13:32:55 +0300 |
commit | e4e313fccab6816fb2e52ebdf83807fba4a52051 (patch) | |
tree | 14608c8b47cbc6e136e4a5d3ea160c26b284a892 /spec/lib/gitlab | |
parent | a67311cb4c9f54af43d300fde5240f9a370193d1 (diff) |
Fix other spec failures
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r-- | spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb b/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb new file mode 100644 index 00000000000..77dbf1c79a5 --- /dev/null +++ b/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb @@ -0,0 +1,59 @@ +require 'spec_helper' + +describe Gitlab::CycleAnalytics::StageSummary, models: true do + let(:project) { create(:project) } + let(:from) { Time.now } + let(:user) { create(:user, :admin) } + subject { described_class.new(project, from: Time.now).data } + + describe "#new_issues" do + it "finds the number of issues created after the 'from date'" do + Timecop.freeze(5.days.ago) { create(:issue, project: project) } + Timecop.freeze(5.days.from_now) { create(:issue, project: project) } + + expect(subject.first[:value]).to eq(1) + end + + it "doesn't find issues from other projects" do + Timecop.freeze(5.days.from_now) { create(:issue, project: create(:project)) } + + expect(subject.first[:value]).to eq(0) + end + end + + describe "#commits" do + it "finds the number of commits created after the 'from date'" do + Timecop.freeze(5.days.ago) { create_commit("Test message", project, user, 'master') } + Timecop.freeze(5.days.from_now) { create_commit("Test message", project, user, 'master') } + + expect(subject.second[:value]).to eq(1) + end + + it "doesn't find commits from other projects" do + Timecop.freeze(5.days.from_now) { create_commit("Test message", create(:project), user, 'master') } + + expect(subject.second[:value]).to eq(0) + end + + it "finds a large (> 100) snumber of commits if present" do + Timecop.freeze(5.days.from_now) { create_commit("Test message", project, user, 'master', count: 100) } + + expect(subject.second[:value]).to eq(100) + end + end + + describe "#deploys" do + it "finds the number of deploys made created after the 'from date'" do + Timecop.freeze(5.days.ago) { create(:deployment, project: project) } + Timecop.freeze(5.days.from_now) { create(:deployment, project: project) } + + expect(subject.third[:value]).to eq(1) + end + + it "doesn't find commits from other projects" do + Timecop.freeze(5.days.from_now) { create(:deployment, project: create(:project)) } + + expect(subject.third[:value]).to eq(0) + end + end +end |