diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-10 18:09:00 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-10 18:09:00 +0000 |
commit | c57e10faab0abb213e7a18274fd5a98ba87a5c09 (patch) | |
tree | de0195e28dfe19fbfeb5bffa8fde4f511288d8ef /spec/lib | |
parent | 11e5d1b9ca3efa7be34ddebb708a6aedb4e91639 (diff) | |
download | gitlab-ce-c57e10faab0abb213e7a18274fd5a98ba87a5c09.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/import_export/safe_model_attributes.yml | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/profiler_spec.rb | 39 |
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 |