diff options
author | Tristan Read <tread@gitlab.com> | 2019-07-26 01:41:54 +0000 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-07-26 01:41:54 +0000 |
commit | ca9b067e3444b90fd5261d30a735b2a10586336f (patch) | |
tree | 086ebf0a284ce3d4e031da5205b9bb63ed38418f /spec/features/markdown | |
parent | 8b7030751cafea606617dfdcfff0ce70d11238f1 (diff) | |
download | gitlab-ce-ca9b067e3444b90fd5261d30a735b2a10586336f.tar.gz |
Feature test for gfm embedding metrics
Diffstat (limited to 'spec/features/markdown')
-rw-r--r-- | spec/features/markdown/metrics_spec.rb | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/features/markdown/metrics_spec.rb b/spec/features/markdown/metrics_spec.rb new file mode 100644 index 00000000000..aa53ac50c78 --- /dev/null +++ b/spec/features/markdown/metrics_spec.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Metrics rendering', :js, :use_clean_rails_memory_store_caching do + include PrometheusHelpers + + let(:user) { create(:user) } + let(:project) { create(:prometheus_project) } + let(:environment) { create(:environment, project: project) } + let(:issue) { create(:issue, project: project, description: description) } + let(:description) { "See [metrics dashboard](#{metrics_url}) for info." } + let(:metrics_url) { metrics_project_environment_url(project, environment) } + + before do + configure_host + import_common_metrics + stub_any_prometheus_request_with_response + + project.add_developer(user) + + sign_in(user) + end + + after do + restore_host + end + + context 'with deployments and related deployable present' do + it 'shows embedded metrics' do + visit project_issue_path(project, issue) + + expect(page).to have_css('div.prometheus-graph') + expect(page).to have_text('Memory Usage (Total)') + expect(page).to have_text('Core Usage (Total)') + end + end + + def import_common_metrics + ::Gitlab::DatabaseImporters::CommonMetrics::Importer.new.execute + end + + def configure_host + @original_default_host = default_url_options[:host] + @original_gitlab_url = Gitlab.config.gitlab[:url] + + # Ensure we create a metrics url with the right host. + # Configure host for route helpers in specs (also updates root_url): + default_url_options[:host] = Capybara.server_host + + # Ensure we identify urls with the appropriate host. + # Configure host to include port in app: + Gitlab.config.gitlab[:url] = root_url.chomp('/') + end + + def restore_host + default_url_options[:host] = @original_default_host + Gitlab.config.gitlab[:url] = @original_gitlab_url + end +end |