summaryrefslogtreecommitdiff
path: root/spec/features/projects/environments/environment_metrics_spec.rb
blob: cf0dfcfb1f3f7b3023d60376407139f32f15f348 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'spec_helper'

feature 'Environment > Metrics', :feature do
  include PrometheusHelpers

  given(:user) { create(:user) }
  given(:project) { create(:prometheus_project) }
  given(:pipeline) { create(:ci_pipeline, project: project) }
  given(:build) { create(:ci_build, pipeline: pipeline) }
  given(:environment) { create(:environment, project: project) }
  given(:current_time) { Time.now.utc }

  background do
    project.add_developer(user)
    create(:deployment, environment: environment, deployable: build)
    stub_all_prometheus_requests(environment.slug)

    sign_in(user)
    visit_environment(environment)
  end

  around do |example|
    Timecop.freeze(current_time) { example.run }
  end

  context 'with deployments and related deployable present' do
    scenario 'shows metrics' do
      click_link('See metrics')

      expect(page).to have_css('div#prometheus-graphs')
    end
  end

  def visit_environment(environment)
    visit project_environment_path(environment.project, environment)
  end
end