Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-19 21:07:48 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-19 21:07:48 +0300
commitb5571e6e22cdacc81f78eff5943d68c8ba220fbb (patch)
tree3677b792f5afe0b4853cee59e166df961993b7e8 /spec
parentf92a53a216e6e7d5037ac701efbee5628f91aa9a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/environments/sample_metrics_controller_spec.rb4
-rw-r--r--spec/fixtures/gitlab/sample_metrics/sample_metric_query_result.yml477
-rw-r--r--spec/services/metrics/sample_metrics_service_spec.rb9
-rw-r--r--spec/services/task_list_toggle_service_spec.rb44
-rw-r--r--spec/tasks/gitlab/generate_sample_prometheus_data_spec.rb2
5 files changed, 381 insertions, 155 deletions
diff --git a/spec/controllers/projects/environments/sample_metrics_controller_spec.rb b/spec/controllers/projects/environments/sample_metrics_controller_spec.rb
index 4faa3ecb567..a1fec46d3a0 100644
--- a/spec/controllers/projects/environments/sample_metrics_controller_spec.rb
+++ b/spec/controllers/projects/environments/sample_metrics_controller_spec.rb
@@ -58,7 +58,9 @@ describe Projects::Environments::SampleMetricsController do
id: environment.id.to_s,
namespace_id: project.namespace.full_path,
project_id: project.name,
- identifier: 'sample_metric_query_result'
+ identifier: 'sample_metric_query_result',
+ start: '2019-12-02T23:31:45.000Z',
+ end: '2019-12-03T00:01:45.000Z'
}.merge(params)
end
end
diff --git a/spec/fixtures/gitlab/sample_metrics/sample_metric_query_result.yml b/spec/fixtures/gitlab/sample_metrics/sample_metric_query_result.yml
index ba074912b3b..ce49f551082 100644
--- a/spec/fixtures/gitlab/sample_metrics/sample_metric_query_result.yml
+++ b/spec/fixtures/gitlab/sample_metrics/sample_metric_query_result.yml
@@ -1,151 +1,332 @@
---
+30:
- metric: {}
values:
- - - 1573560714.209
- - '0.02361297607421875'
- - - 1573560774.209
- - '0.02361297607421875'
- - - 1573560834.209
- - '0.02362823486328125'
- - - 1573560894.209
- - '0.02361297607421875'
- - - 1573560954.209
- - '0.02385711669921875'
- - - 1573561014.209
- - '0.02361297607421875'
- - - 1573561074.209
- - '0.02361297607421875'
- - - 1573561134.209
- - '0.02362060546875'
- - - 1573561194.209
- - '0.02362060546875'
- - - 1573561254.209
- - '0.02362060546875'
- - - 1573561314.209
- - '0.02362060546875'
- - - 1573561374.209
- - '0.023624420166015625'
- - - 1573561434.209
- - '0.023651123046875'
- - - 1573561494.209
- - '0.02362060546875'
- - - 1573561554.209
- - '0.0236358642578125'
- - - 1573561614.209
- - '0.02362060546875'
- - - 1573561674.209
- - '0.02362060546875'
- - - 1573561734.209
- - '0.02362060546875'
- - - 1573561794.209
- - '0.02362060546875'
- - - 1573561854.209
- - '0.02362060546875'
- - - 1573561914.209
- - '0.023651123046875'
- - - 1573561974.209
- - '0.02362060546875'
- - - 1573562034.209
- - '0.02362060546875'
- - - 1573562094.209
- - '0.02362060546875'
- - - 1573562154.209
- - '0.02362060546875'
- - - 1573562214.209
- - '0.023624420166015625'
- - - 1573562274.209
- - '0.02362060546875'
- - - 1573562334.209
- - '0.023868560791015625'
- - - 1573562394.209
- - '0.02374267578125'
- - - 1573562454.209
- - '0.02362060546875'
- - - 1573562514.209
- - '0.02362060546875'
- - - 1573562574.209
- - '0.02362060546875'
- - - 1573562634.209
- - '0.02362060546875'
- - - 1573562694.209
- - '0.023639678955078125'
- - - 1573562754.209
- - '0.0236358642578125'
- - - 1573562814.209
- - '0.02362060546875'
- - - 1573562874.209
- - '0.0236358642578125'
- - - 1573562934.209
- - '0.023651123046875'
- - - 1573562994.209
- - '0.02362060546875'
- - - 1573563054.209
- - '0.023624420166015625'
- - - 1573563114.209
- - '0.02362060546875'
- - - 1573563174.209
- - '0.02362060546875'
- - - 1573563234.209
- - '0.02362060546875'
- - - 1573563294.209
- - '0.02362060546875'
- - - 1573563354.209
- - '0.02362060546875'
- - - 1573563414.209
- - '0.023651123046875'
- - - 1573563474.209
- - '0.023651123046875'
- - - 1573563534.209
- - '0.023651123046875'
- - - 1573563594.209
- - '0.023773193359375'
- - - 1573563654.209
- - '0.023681640625'
- - - 1573563714.209
- - '0.023895263671875'
- - - 1573563774.209
- - '0.023651123046875'
- - - 1573563834.209
- - '0.023651123046875'
- - - 1573563894.209
- - '0.023651123046875'
- - - 1573563954.209
- - '0.0236663818359375'
- - - 1573564014.209
- - '0.023651123046875'
- - - 1573564074.209
- - '0.023681640625'
- - - 1573564134.209
- - '0.0236663818359375'
- - - 1573564194.209
- - '0.0236663818359375'
- - - 1573564254.209
- - '0.023651123046875'
- - - 1573564314.209
- - '0.023651123046875'
- - - 1573564374.209
- - '0.023651123046875'
- - - 1573564434.209
- - '0.023773193359375'
- - - 1573564494.209
- - '0.023651123046875'
- - - 1573564554.209
- - '0.023681640625'
- - - 1573564614.209
- - '0.023773193359375'
- - - 1573564674.209
- - '0.023651123046875'
- - - 1573564734.209
- - '0.023651123046875'
- - - 1573564794.209
- - '0.023651123046875'
- - - 1573564854.209
- - '0.023651123046875'
- - - 1573564914.209
- - '0.023651123046875'
- - - 1573564974.209
- - '0.023651123046875'
- - - 1573565034.209
- - '0.023651123046875'
- - - 1573565094.209
- - '0.023895263671875' \ No newline at end of file
+ - - 1576719533.248
+ - '0.0006172414678571515'
+ - - 1576719593.248
+ - '0.0006189408976190352'
+ - - 1576719653.248
+ - '0.0006182154988094691'
+ - - 1576719713.248
+ - '0.0006194998404763076'
+ - - 1576719773.248
+ - '0.0006194687678569856'
+ - - 1576719833.248
+ - '0.0006171203535713976'
+ - - 1576719893.248
+ - '0.0006244061773808577'
+ - - 1576719953.248
+ - '0.0006170288511561634'
+ - - 1576720013.248
+ - '0.0006243750281248557'
+ - - 1576720073.248
+ - '0.0006152456571427256'
+ - - 1576720133.248
+ - '0.0006215679095237733'
+ - - 1576720193.248
+ - '0.0006218523571429083'
+ - - 1576720253.248
+ - '0.0006200312440475792'
+ - - 1576720313.248
+ - '0.0006214166202382676'
+ - - 1576720373.248
+ - '0.0006152486976191084'
+ - - 1576720433.248
+ - '0.0006136406750000235'
+ - - 1576720493.248
+ - '0.0006135999154761997'
+ - - 1576720553.248
+ - '0.0006126559190475756'
+ - - 1576720613.248
+ - '0.0006153160392857769'
+ - - 1576720673.248
+ - '0.0006146447178572262'
+ - - 1576720733.248
+ - '0.0006146970476189988'
+ - - 1576720793.248
+ - '0.0006219259035715042'
+ - - 1576720853.248
+ - '0.0006111198750001481'
+ - - 1576720913.248
+ - '0.0006169941035715337'
+ - - 1576720973.248
+ - '0.0006102626761905379'
+ - - 1576721033.248
+ - '0.0006163839964285346'
+180:
+- metric: {}
+ values:
+ - - 1576719533.248
+ - '0.0006172414678571515'
+ - - 1576719593.248
+ - '0.0006189408976190352'
+ - - 1576719653.248
+ - '0.0006182154988094691'
+ - - 1576719713.248
+ - '0.0006194998404763076'
+ - - 1576719773.248
+ - '0.0006194687678569856'
+ - - 1576719833.248
+ - '0.0006171203535713976'
+ - - 1576719893.248
+ - '0.0006244061773808577'
+ - - 1576719953.248
+ - '0.0006170288511561634'
+ - - 1576720013.248
+ - '0.0006243750281248557'
+ - - 1576720073.248
+ - '0.0006152456571427256'
+ - - 1576720133.248
+ - '0.0006215679095237733'
+ - - 1576720193.248
+ - '0.0006218523571429083'
+ - - 1576720253.248
+ - '0.0006200312440475792'
+ - - 1576720313.248
+ - '0.0006214166202382676'
+ - - 1576720373.248
+ - '0.0006152486976191084'
+ - - 1576720433.248
+ - '0.0006136406750000235'
+ - - 1576720493.248
+ - '0.0006135999154761997'
+ - - 1576720553.248
+ - '0.0006126559190475756'
+ - - 1576720613.248
+ - '0.0006153160392857769'
+ - - 1576720673.248
+ - '0.0006146447178572262'
+ - - 1576720733.248
+ - '0.0006146970476189988'
+ - - 1576720793.248
+ - '0.0006219259035715042'
+ - - 1576720853.248
+ - '0.0006111198750001481'
+ - - 1576720913.248
+ - '0.0006169941035715337'
+ - - 1576720973.248
+ - '0.0006102626761905379'
+ - - 1576721033.248
+ - '0.0006163839964285346'
+480:
+- metric: {}
+ values:
+ - - 1576719533.248
+ - '0.0006172414678571515'
+ - - 1576719593.248
+ - '0.0006189408976190352'
+ - - 1576719653.248
+ - '0.0006182154988094691'
+ - - 1576719713.248
+ - '0.0006194998404763076'
+ - - 1576719773.248
+ - '0.0006194687678569856'
+ - - 1576719833.248
+ - '0.0006171203535713976'
+ - - 1576719893.248
+ - '0.0006244061773808577'
+ - - 1576719953.248
+ - '0.0006170288511561634'
+ - - 1576720013.248
+ - '0.0006243750281248557'
+ - - 1576720073.248
+ - '0.0006152456571427256'
+ - - 1576720133.248
+ - '0.0006215679095237733'
+ - - 1576720193.248
+ - '0.0006218523571429083'
+ - - 1576720253.248
+ - '0.0006200312440475792'
+ - - 1576720313.248
+ - '0.0006214166202382676'
+ - - 1576720373.248
+ - '0.0006152486976191084'
+ - - 1576720433.248
+ - '0.0006136406750000235'
+ - - 1576720493.248
+ - '0.0006135999154761997'
+ - - 1576720553.248
+ - '0.0006126559190475756'
+ - - 1576720613.248
+ - '0.0006153160392857769'
+ - - 1576720673.248
+ - '0.0006146447178572262'
+ - - 1576720733.248
+ - '0.0006146970476189988'
+ - - 1576720793.248
+ - '0.0006219259035715042'
+ - - 1576720853.248
+ - '0.0006111198750001481'
+ - - 1576720913.248
+ - '0.0006169941035715337'
+ - - 1576720973.248
+ - '0.0006102626761905379'
+ - - 1576721033.248
+ - '0.0006163839964285346'
+1440:
+- metric: {}
+ values:
+ - - 1576719533.248
+ - '0.0006172414678571515'
+ - - 1576719593.248
+ - '0.0006189408976190352'
+ - - 1576719653.248
+ - '0.0006182154988094691'
+ - - 1576719713.248
+ - '0.0006194998404763076'
+ - - 1576719773.248
+ - '0.0006194687678569856'
+ - - 1576719833.248
+ - '0.0006171203535713976'
+ - - 1576719893.248
+ - '0.0006244061773808577'
+ - - 1576719953.248
+ - '0.0006170288511561634'
+ - - 1576720013.248
+ - '0.0006243750281248557'
+ - - 1576720073.248
+ - '0.0006152456571427256'
+ - - 1576720133.248
+ - '0.0006215679095237733'
+ - - 1576720193.248
+ - '0.0006218523571429083'
+ - - 1576720253.248
+ - '0.0006200312440475792'
+ - - 1576720313.248
+ - '0.0006214166202382676'
+ - - 1576720373.248
+ - '0.0006152486976191084'
+ - - 1576720433.248
+ - '0.0006136406750000235'
+ - - 1576720493.248
+ - '0.0006135999154761997'
+ - - 1576720553.248
+ - '0.0006126559190475756'
+ - - 1576720613.248
+ - '0.0006153160392857769'
+ - - 1576720673.248
+ - '0.0006146447178572262'
+ - - 1576720733.248
+ - '0.0006146970476189988'
+ - - 1576720793.248
+ - '0.0006219259035715042'
+ - - 1576720853.248
+ - '0.0006111198750001481'
+ - - 1576720913.248
+ - '0.0006169941035715337'
+ - - 1576720973.248
+ - '0.0006102626761905379'
+ - - 1576721033.248
+ - '0.0006163839964285346'
+4320:
+- metric: {}
+ values:
+ - - 1576719533.248
+ - '0.0006172414678571515'
+ - - 1576719593.248
+ - '0.0006189408976190352'
+ - - 1576719653.248
+ - '0.0006182154988094691'
+ - - 1576719713.248
+ - '0.0006194998404763076'
+ - - 1576719773.248
+ - '0.0006194687678569856'
+ - - 1576719833.248
+ - '0.0006171203535713976'
+ - - 1576719893.248
+ - '0.0006244061773808577'
+ - - 1576719953.248
+ - '0.0006170288511561634'
+ - - 1576720013.248
+ - '0.0006243750281248557'
+ - - 1576720073.248
+ - '0.0006152456571427256'
+ - - 1576720133.248
+ - '0.0006215679095237733'
+ - - 1576720193.248
+ - '0.0006218523571429083'
+ - - 1576720253.248
+ - '0.0006200312440475792'
+ - - 1576720313.248
+ - '0.0006214166202382676'
+ - - 1576720373.248
+ - '0.0006152486976191084'
+ - - 1576720433.248
+ - '0.0006136406750000235'
+ - - 1576720493.248
+ - '0.0006135999154761997'
+ - - 1576720553.248
+ - '0.0006126559190475756'
+ - - 1576720613.248
+ - '0.0006153160392857769'
+ - - 1576720673.248
+ - '0.0006146447178572262'
+ - - 1576720733.248
+ - '0.0006146970476189988'
+ - - 1576720793.248
+ - '0.0006219259035715042'
+ - - 1576720853.248
+ - '0.0006111198750001481'
+ - - 1576720913.248
+ - '0.0006169941035715337'
+ - - 1576720973.248
+ - '0.0006102626761905379'
+ - - 1576721033.248
+ - '0.0006163839964285346'
+10080:
+- metric: {}
+ values:
+ - - 1576719533.248
+ - '0.0006172414678571515'
+ - - 1576719593.248
+ - '0.0006189408976190352'
+ - - 1576719653.248
+ - '0.0006182154988094691'
+ - - 1576719713.248
+ - '0.0006194998404763076'
+ - - 1576719773.248
+ - '0.0006194687678569856'
+ - - 1576719833.248
+ - '0.0006171203535713976'
+ - - 1576719893.248
+ - '0.0006244061773808577'
+ - - 1576719953.248
+ - '0.0006170288511561634'
+ - - 1576720013.248
+ - '0.0006243750281248557'
+ - - 1576720073.248
+ - '0.0006152456571427256'
+ - - 1576720133.248
+ - '0.0006215679095237733'
+ - - 1576720193.248
+ - '0.0006218523571429083'
+ - - 1576720253.248
+ - '0.0006200312440475792'
+ - - 1576720313.248
+ - '0.0006214166202382676'
+ - - 1576720373.248
+ - '0.0006152486976191084'
+ - - 1576720433.248
+ - '0.0006136406750000235'
+ - - 1576720493.248
+ - '0.0006135999154761997'
+ - - 1576720553.248
+ - '0.0006126559190475756'
+ - - 1576720613.248
+ - '0.0006153160392857769'
+ - - 1576720673.248
+ - '0.0006146447178572262'
+ - - 1576720733.248
+ - '0.0006146970476189988'
+ - - 1576720793.248
+ - '0.0006219259035715042'
+ - - 1576720853.248
+ - '0.0006111198750001481'
+ - - 1576720913.248
+ - '0.0006169941035715337'
+ - - 1576720973.248
+ - '0.0006102626761905379'
+ - - 1576721033.248
+ - '0.0006163839964285346'
+ \ No newline at end of file
diff --git a/spec/services/metrics/sample_metrics_service_spec.rb b/spec/services/metrics/sample_metrics_service_spec.rb
index 8574674ebc4..3b4f7cb8062 100644
--- a/spec/services/metrics/sample_metrics_service_spec.rb
+++ b/spec/services/metrics/sample_metrics_service_spec.rb
@@ -4,7 +4,10 @@ require 'spec_helper'
describe Metrics::SampleMetricsService do
describe 'query' do
- subject { described_class.new(identifier).query }
+ let(:range_start) { '2019-12-02T23:31:45.000Z' }
+ let(:range_end) { '2019-12-03T00:01:45.000Z' }
+
+ subject { described_class.new(identifier, range_start: range_start, range_end: range_end).query }
context 'when the file is not found' do
let(:identifier) { nil }
@@ -26,10 +29,10 @@ describe Metrics::SampleMetricsService do
FileUtils.rm(destination)
end
- subject { described_class.new(identifier).query }
+ subject { described_class.new(identifier, range_start: range_start, range_end: range_end).query }
it 'loads data from the sample file correctly' do
- expect(subject).to eq(YAML.load_file(source))
+ expect(subject).to eq(YAML.load_file(source)[30])
end
end
diff --git a/spec/services/task_list_toggle_service_spec.rb b/spec/services/task_list_toggle_service_spec.rb
index a309951bbcb..82a5446dcb8 100644
--- a/spec/services/task_list_toggle_service_spec.rb
+++ b/spec/services/task_list_toggle_service_spec.rb
@@ -121,7 +121,7 @@ describe TaskListToggleService do
> * [x] Task 2
EOT
- markdown_html = Banzai::Pipeline::FullPipeline.call(markdown, project: nil)[:output].to_html
+ markdown_html = parse_markdown(markdown)
toggler = described_class.new(markdown, markdown_html,
toggle_as_checked: true,
line_source: '> > * [ ] Task 1', line_number: 1)
@@ -142,7 +142,7 @@ describe TaskListToggleService do
* [x] Task 2
EOT
- markdown_html = Banzai::Pipeline::FullPipeline.call(markdown, project: nil)[:output].to_html
+ markdown_html = parse_markdown(markdown)
toggler = described_class.new(markdown, markdown_html,
toggle_as_checked: true,
line_source: '* [ ] Task 1', line_number: 5)
@@ -151,4 +151,44 @@ describe TaskListToggleService do
expect(toggler.updated_markdown.lines[4]).to eq "* [x] Task 1\n"
expect(toggler.updated_markdown_html).to include('disabled checked> Task 1')
end
+
+ context 'when clicking an embedded subtask' do
+ it 'properly handles it inside an unordered list' do
+ markdown =
+ <<-EOT.strip_heredoc
+ - - [ ] Task 1
+ - [x] Task 2
+ EOT
+
+ markdown_html = parse_markdown(markdown)
+ toggler = described_class.new(markdown, markdown_html,
+ toggle_as_checked: true,
+ line_source: '- - [ ] Task 1', line_number: 1)
+
+ expect(toggler.execute).to be_truthy
+ expect(toggler.updated_markdown.lines[0]).to eq "- - [x] Task 1\n"
+ expect(toggler.updated_markdown_html).to include('disabled checked> Task 1')
+ end
+
+ it 'properly handles it inside an ordered list' do
+ markdown =
+ <<-EOT.strip_heredoc
+ 1. - [ ] Task 1
+ - [x] Task 2
+ EOT
+
+ markdown_html = parse_markdown(markdown)
+ toggler = described_class.new(markdown, markdown_html,
+ toggle_as_checked: true,
+ line_source: '1. - [ ] Task 1', line_number: 1)
+
+ expect(toggler.execute).to be_truthy
+ expect(toggler.updated_markdown.lines[0]).to eq "1. - [x] Task 1\n"
+ expect(toggler.updated_markdown_html).to include('disabled checked> Task 1')
+ end
+ end
+
+ def parse_markdown(markdown)
+ Banzai::Pipeline::FullPipeline.call(markdown, project: nil)[:output].to_html
+ end
end
diff --git a/spec/tasks/gitlab/generate_sample_prometheus_data_spec.rb b/spec/tasks/gitlab/generate_sample_prometheus_data_spec.rb
index 72e61f5c524..7620047624a 100644
--- a/spec/tasks/gitlab/generate_sample_prometheus_data_spec.rb
+++ b/spec/tasks/gitlab/generate_sample_prometheus_data_spec.rb
@@ -17,7 +17,7 @@ describe 'gitlab:generate_sample_prometheus_data rake task' do
it 'creates the file correctly' do
Rake.application.rake_require 'tasks/gitlab/generate_sample_prometheus_data'
allow(Environment).to receive(:find).and_return(environment)
- allow(environment).to receive_message_chain(:prometheus_adapter, :prometheus_client, :query_range) { sample_query_result }
+ allow(environment).to receive_message_chain(:prometheus_adapter, :prometheus_client, :query_range) { sample_query_result[30] }
run_rake_task('gitlab:generate_sample_prometheus_data', [environment.id])
expect(File.exist?(sample_query_file)).to be true