summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-08-01 08:46:43 +0200
committerJarka Kadlecova <jarka@gitlab.com>2017-08-07 20:52:08 +0200
commit0f9bde41fc5d51ef227021444e2185fb5e5162f1 (patch)
tree0d1f5959c3464aff053751f99f11bf2319d5ce7a /spec
parent28299de189c4c1e9c900d68f98ecfac993cb0aed (diff)
downloadgitlab-ce-0f9bde41fc5d51ef227021444e2185fb5e5162f1.tar.gz
Store & use ConvDev percentages returned by Version app35761-convdev-perc
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/conversational_development_index_metrics.rb10
-rw-r--r--spec/migrations/calculate_conv_dev_index_percentages_spec.rb41
-rw-r--r--spec/models/conversational_development_index/metric_spec.rb11
-rw-r--r--spec/presenters/conversational_development_index/metric_presenter_spec.rb6
-rw-r--r--spec/services/submit_usage_ping_service_spec.rb7
5 files changed, 71 insertions, 4 deletions
diff --git a/spec/factories/conversational_development_index_metrics.rb b/spec/factories/conversational_development_index_metrics.rb
index a5412629195..3806c43ba15 100644
--- a/spec/factories/conversational_development_index_metrics.rb
+++ b/spec/factories/conversational_development_index_metrics.rb
@@ -2,32 +2,42 @@ FactoryGirl.define do
factory :conversational_development_index_metric, class: ConversationalDevelopmentIndex::Metric do
leader_issues 9.256
instance_issues 1.234
+ percentage_issues 13.331
leader_notes 30.33333
instance_notes 28.123
+ percentage_notes 92.713
leader_milestones 16.2456
instance_milestones 1.234
+ percentage_milestones 7.595
leader_boards 5.2123
instance_boards 3.254
+ percentage_boards 62.429
leader_merge_requests 1.2
instance_merge_requests 0.6
+ percentage_merge_requests 50.0
leader_ci_pipelines 12.1234
instance_ci_pipelines 2.344
+ percentage_ci_pipelines 19.334
leader_environments 3.3333
instance_environments 2.2222
+ percentage_environments 66.672
leader_deployments 1.200
instance_deployments 0.771
+ percentage_deployments 64.25
leader_projects_prometheus_active 0.111
instance_projects_prometheus_active 0.109
+ percentage_projects_prometheus_active 98.198
leader_service_desk_issues 15.891
instance_service_desk_issues 13.345
+ percentage_service_desk_issues 83.978
end
end
diff --git a/spec/migrations/calculate_conv_dev_index_percentages_spec.rb b/spec/migrations/calculate_conv_dev_index_percentages_spec.rb
new file mode 100644
index 00000000000..597d8eab51c
--- /dev/null
+++ b/spec/migrations/calculate_conv_dev_index_percentages_spec.rb
@@ -0,0 +1,41 @@
+# encoding: utf-8
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20170803090603_calculate_conv_dev_index_percentages.rb')
+
+describe CalculateConvDevIndexPercentages, truncate: true do
+ let(:migration) { described_class.new }
+ let!(:conv_dev_index) do
+ create(:conversational_development_index_metric,
+ leader_notes: 0,
+ instance_milestones: 0,
+ percentage_issues: 0,
+ percentage_notes: 0,
+ percentage_milestones: 0,
+ percentage_boards: 0,
+ percentage_merge_requests: 0,
+ percentage_ci_pipelines: 0,
+ percentage_environments: 0,
+ percentage_deployments: 0,
+ percentage_projects_prometheus_active: 0,
+ percentage_service_desk_issues: 0)
+ end
+
+ describe '#up' do
+ it 'calculates percentages correctly' do
+ migration.up
+ conv_dev_index.reload
+
+ expect(conv_dev_index.percentage_issues).to be_within(0.1).of(13.3)
+ expect(conv_dev_index.percentage_notes).to be_zero # leader 0
+ expect(conv_dev_index.percentage_milestones).to be_zero # instance 0
+ expect(conv_dev_index.percentage_boards).to be_within(0.1).of(62.4)
+ expect(conv_dev_index.percentage_merge_requests).to eq(50.0)
+ expect(conv_dev_index.percentage_ci_pipelines).to be_within(0.1).of(19.3)
+ expect(conv_dev_index.percentage_environments).to be_within(0.1).of(66.7)
+ expect(conv_dev_index.percentage_deployments).to be_within(0.1).of(64.2)
+ expect(conv_dev_index.percentage_projects_prometheus_active).to be_within(0.1).of(98.2)
+ expect(conv_dev_index.percentage_service_desk_issues).to be_within(0.1).of(84.0)
+ end
+ end
+end
diff --git a/spec/models/conversational_development_index/metric_spec.rb b/spec/models/conversational_development_index/metric_spec.rb
new file mode 100644
index 00000000000..b3193619503
--- /dev/null
+++ b/spec/models/conversational_development_index/metric_spec.rb
@@ -0,0 +1,11 @@
+require 'rails_helper'
+
+describe ConversationalDevelopmentIndex::Metric do
+ let(:conv_dev_index) { create(:conversational_development_index_metric) }
+
+ describe '#percentage_score' do
+ it 'returns stored percentage score' do
+ expect(conv_dev_index.percentage_score('issues')).to eq(13.331)
+ end
+ end
+end
diff --git a/spec/presenters/conversational_development_index/metric_presenter_spec.rb b/spec/presenters/conversational_development_index/metric_presenter_spec.rb
index 1e015c71f5b..81eb05a9a6b 100644
--- a/spec/presenters/conversational_development_index/metric_presenter_spec.rb
+++ b/spec/presenters/conversational_development_index/metric_presenter_spec.rb
@@ -8,9 +8,9 @@ describe ConversationalDevelopmentIndex::MetricPresenter do
it 'includes instance score, leader score and percentage score' do
issues_card = subject.cards.first
- expect(issues_card.instance_score).to eq 1.234
- expect(issues_card.leader_score).to eq 9.256
- expect(issues_card.percentage_score).to be_within(0.1).of(13.3)
+ expect(issues_card.instance_score).to eq(1.234)
+ expect(issues_card.leader_score).to eq(9.256)
+ expect(issues_card.percentage_score).to eq(13.331)
end
end
diff --git a/spec/services/submit_usage_ping_service_spec.rb b/spec/services/submit_usage_ping_service_spec.rb
index 817fa4262d5..c8a6fc1a99b 100644
--- a/spec/services/submit_usage_ping_service_spec.rb
+++ b/spec/services/submit_usage_ping_service_spec.rb
@@ -46,6 +46,8 @@ describe SubmitUsagePingService do
.by(1)
expect(ConversationalDevelopmentIndex::Metric.last.leader_issues).to eq 10.2
+ expect(ConversationalDevelopmentIndex::Metric.last.instance_issues).to eq 3.2
+ expect(ConversationalDevelopmentIndex::Metric.last.percentage_issues).to eq 31.37
end
end
@@ -60,6 +62,7 @@ describe SubmitUsagePingService do
conv_index: {
leader_issues: 10.2,
instance_issues: 3.2,
+ percentage_issues: 31.37,
leader_notes: 25.3,
instance_notes: 23.2,
@@ -86,7 +89,9 @@ describe SubmitUsagePingService do
instance_projects_prometheus_active: 0.30,
leader_service_desk_issues: 15.8,
- instance_service_desk_issues: 15.1
+ instance_service_desk_issues: 15.1,
+
+ non_existing_column: 'value'
}
}
end