summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/import_export/safe_model_attributes.yml2
-rw-r--r--spec/lib/gitlab/profiler_spec.rb39
2 files changed, 41 insertions, 0 deletions
diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml
index 86bf5710635..7695617cb57 100644
--- a/spec/lib/gitlab/import_export/safe_model_attributes.yml
+++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml
@@ -30,6 +30,7 @@ Issue:
- last_edited_at
- last_edited_by_id
- discussion_locked
+- health_status
Event:
- id
- target_type
@@ -824,3 +825,4 @@ Epic:
- state_id
- start_date_sourcing_epic_id
- due_date_sourcing_epic_id
+ - health_status
diff --git a/spec/lib/gitlab/profiler_spec.rb b/spec/lib/gitlab/profiler_spec.rb
index 8f6fb6eda65..0186d48fd1b 100644
--- a/spec/lib/gitlab/profiler_spec.rb
+++ b/spec/lib/gitlab/profiler_spec.rb
@@ -192,4 +192,43 @@ describe Gitlab::Profiler do
expect(described_class.log_load_times_by_model(null_logger)).to be_nil
end
end
+
+ describe '.print_by_total_time' do
+ let(:stdout) { StringIO.new }
+
+ let(:output) do
+ stdout.rewind
+ stdout.read
+ end
+
+ let_it_be(:result) do
+ RubyProf.profile do
+ sleep 0.1
+ 1.to_s
+ end
+ end
+
+ before do
+ stub_const('STDOUT', stdout)
+ end
+
+ it 'prints a profile result sorted by total time' do
+ described_class.print_by_total_time(result)
+
+ total_times =
+ output
+ .scan(/^\s+\d+\.\d+\s+(\d+\.\d+)/)
+ .map { |(total)| total.to_f }
+
+ expect(output).to include('Kernel#sleep')
+ expect(total_times).to eq(total_times.sort.reverse)
+ expect(total_times).not_to eq(total_times.uniq)
+ end
+
+ it 'accepts a max_percent option' do
+ described_class.print_by_total_time(result, max_percent: 50)
+
+ expect(output).not_to include('Kernel#sleep')
+ end
+ end
end