graph_spec.rb 1.94 KB
Newer Older
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
require 'spec_helper'

describe 'Project Graph', :js do
  let(:user) { create :user }
  let(:project) { create(:project, :repository, namespace: user.namespace) }

  before do
    project.add_master(user)

    sign_in(user)
  end

  shared_examples 'page should have commits graphs' do
    it 'renders commits' do
      expect(page).to have_content('Commit statistics for master')
      expect(page).to have_content('Commits per day of month')
    end
  end

  shared_examples 'page should have languages graphs' do
    it 'renders languages' do
      expect(page).to have_content(/Ruby 66.* %/)
      expect(page).to have_content(/JavaScript 22.* %/)
    end
  end

  it 'renders graphs' do
    visit project_graph_path(project, 'master')

    expect(page).to have_selector('.stat-graph', visible: false)
  end

  context 'commits graph' do
    before do
      visit commits_project_graph_path(project, 'master')
    end

    it_behaves_like 'page should have commits graphs'
    it_behaves_like 'page should have languages graphs'
  end

  context 'languages graph' do
    before do
      visit languages_project_graph_path(project, 'master')
    end

    it_behaves_like 'page should have commits graphs'
    it_behaves_like 'page should have languages graphs'
  end

  context 'charts graph' do
    before do
      visit charts_project_graph_path(project, 'master')
    end

    it_behaves_like 'page should have commits graphs'
    it_behaves_like 'page should have languages graphs'
  end

  context 'when CI enabled' do
    before do
      project.enable_ci

      visit ci_project_graph_path(project, 'master')
    end

    it 'renders CI graphs' do
      expect(page).to have_content 'Overall'
      expect(page).to have_content 'Pipelines for last week'
      expect(page).to have_content 'Pipelines for last month'
      expect(page).to have_content 'Pipelines for last year'
      expect(page).to have_content 'Commit duration in minutes for last 30 commits'
    end
  end
end