diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/lib/gitlab/cycle_analytics | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) | |
download | gitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/lib/gitlab/cycle_analytics')
-rw-r--r-- | spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb | 80 |
1 files changed, 55 insertions, 25 deletions
diff --git a/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb b/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb index a86278871ff..ccc99017e37 100644 --- a/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb +++ b/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb @@ -14,19 +14,29 @@ describe Gitlab::CycleAnalytics::StageSummary do let(:stage_summary) { described_class.new(project, options).data } describe "#new_issues" do - subject { stage_summary.first[:value] } + subject { stage_summary.first } - 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) } + context 'when from date is given' do + before do + Timecop.freeze(5.days.ago) { create(:issue, project: project) } + Timecop.freeze(5.days.from_now) { create(:issue, project: project) } + end - expect(subject).to eq('1') + it "finds the number of issues created after the 'from date'" do + expect(subject[:value]).to eq('1') + end + + it 'returns the localized title' do + Gitlab::I18n.with_locale(:ru) do + expect(subject[:title]).to eq(n_('New Issue', 'New Issues', 1)) + end + end end it "doesn't find issues from other projects" do Timecop.freeze(5.days.from_now) { create(:issue, project: create(:project)) } - expect(subject).to eq('-') + expect(subject[:value]).to eq('-') end context 'when `to` parameter is given' do @@ -38,38 +48,48 @@ describe Gitlab::CycleAnalytics::StageSummary do it "doesn't find any record" do options[:to] = Time.now - expect(subject).to eq('-') + expect(subject[:value]).to eq('-') end it "finds records created between `from` and `to` range" do options[:from] = 10.days.ago options[:to] = 10.days.from_now - expect(subject).to eq('2') + expect(subject[:value]).to eq('2') end end end describe "#commits" do - subject { stage_summary.second[:value] } + subject { stage_summary.second } + + context 'when from date is given' do + before 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') } + end - 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') } + it "finds the number of commits created after the 'from date'" do + expect(subject[:value]).to eq('1') + end - expect(subject).to eq('1') + it 'returns the localized title' do + Gitlab::I18n.with_locale(:ru) do + expect(subject[:title]).to eq(n_('Commit', 'Commits', 1)) + end + end end it "doesn't find commits from other projects" do Timecop.freeze(5.days.from_now) { create_commit("Test message", create(:project, :repository), user, 'master') } - expect(subject).to eq('-') + expect(subject[:value]).to eq('-') end it "finds a large (> 100) number of commits if present" do Timecop.freeze(5.days.from_now) { create_commit("Test message", project, user, 'master', count: 100) } - expect(subject).to eq('100') + expect(subject[:value]).to eq('100') end context 'when `to` parameter is given' do @@ -81,14 +101,14 @@ describe Gitlab::CycleAnalytics::StageSummary do it "doesn't find any record" do options[:to] = Time.now - expect(subject).to eq('-') + expect(subject[:value]).to eq('-') end it "finds records created between `from` and `to` range" do options[:from] = 10.days.ago options[:to] = 10.days.from_now - expect(subject).to eq('2') + expect(subject[:value]).to eq('2') end end @@ -112,13 +132,23 @@ describe Gitlab::CycleAnalytics::StageSummary do end describe "#deploys" do - subject { stage_summary.third[:value] } + subject { stage_summary.third } - it "finds the number of deploys made created after the 'from date'" do - Timecop.freeze(5.days.ago) { create(:deployment, :success, project: project) } - Timecop.freeze(5.days.from_now) { create(:deployment, :success, project: project) } + context 'when from date is given' do + before do + Timecop.freeze(5.days.ago) { create(:deployment, :success, project: project) } + Timecop.freeze(5.days.from_now) { create(:deployment, :success, project: project) } + end + + it "finds the number of deploys made created after the 'from date'" do + expect(subject[:value]).to eq('1') + end - expect(subject).to eq('1') + it 'returns the localized title' do + Gitlab::I18n.with_locale(:ru) do + expect(subject[:title]).to eq(n_('Deploy', 'Deploys', 1)) + end + end end it "doesn't find commits from other projects" do @@ -126,7 +156,7 @@ describe Gitlab::CycleAnalytics::StageSummary do create(:deployment, :success, project: create(:project, :repository)) end - expect(subject).to eq('-') + expect(subject[:value]).to eq('-') end context 'when `to` parameter is given' do @@ -138,14 +168,14 @@ describe Gitlab::CycleAnalytics::StageSummary do it "doesn't find any record" do options[:to] = Time.now - expect(subject).to eq('-') + expect(subject[:value]).to eq('-') end it "finds records created between `from` and `to` range" do options[:from] = 10.days.ago options[:to] = 10.days.from_now - expect(subject).to eq('2') + expect(subject[:value]).to eq('2') end end end |