Commit 937a99a4 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'projects-graphs-rspec' into 'master'

Replace project graphs spinach tests with RSpec analog

See merge request gitlab-org/gitlab-ce!17675
parents 9cd57354 7a916e12
Feature: Project Graph
Background:
Given I sign in as a user
And I own project "Shop"
@javascript
Scenario: I should see project graphs
When I visit project "Shop" graph page
Then page should have graphs
@javascript
Scenario: I should see project languages & commits graphs on commits graph url
When I visit project "Shop" commits graph page
Then page should have commits graphs
Then page should have languages graphs
@javascript
Scenario: I should see project ci graphs
Given project "Shop" has CI enabled
When I visit project "Shop" CI graph page
Then page should have CI graphs
@javascript
Scenario: I should see project languages & commits graphs on language graph url
When I visit project "Shop" languages graph page
Then page should have languages graphs
Then page should have commits graphs
@javascript
Scenario: I should see project languages & commits graphs on charts url
When I visit project "Shop" chart page
Then page should have languages graphs
Then page should have commits graphs
class Spinach::Features::ProjectGraph < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
step 'page should have graphs' do
expect(page).to have_selector ".stat-graph"
end
When 'I visit project "Shop" graph page' do
visit project_graph_path(project, "master")
end
step 'I visit project "Shop" commits graph page' do
visit commits_project_graph_path(project, "master")
end
step 'I visit project "Shop" languages graph page' do
visit languages_project_graph_path(project, "master")
end
step 'I visit project "Shop" chart page' do
visit charts_project_graph_path(project, "master")
end
step 'page should have languages graphs' do
expect(page).to have_content /Ruby 66.* %/
expect(page).to have_content /JavaScript 22.* %/
end
step 'page should have commits graphs' do
expect(page).to have_content "Commit statistics for master"
expect(page).to have_content "Commits per day of month"
end
step 'I visit project "Shop" CI graph page' do
visit ci_project_graph_path(project, 'master')
end
step 'page should have 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
def project
@project ||= Project.find_by(name: "Shop")
end
end
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment