summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2018-03-14 11:16:25 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2018-03-14 11:16:25 +0000
commit937a99a4949bb550271f26eab53b4f95b3e0a28c (patch)
tree8ac7f63db59055c50e46e31ecba2000ea46aeabd
parent9cd573549fbc1f48e497fe455a1ff8f196840069 (diff)
parent7a916e122bd5d8c1b58492cad5adbeb683248650 (diff)
downloadgitlab-ce-937a99a4949bb550271f26eab53b4f95b3e0a28c.tar.gz
Merge branch 'projects-graphs-rspec' into 'master'
Replace project graphs spinach tests with RSpec analog See merge request gitlab-org/gitlab-ce!17675
-rw-r--r--features/project/graph.feature33
-rw-r--r--features/steps/project/graph.rb50
-rw-r--r--spec/features/projects/graph_spec.rb75
3 files changed, 75 insertions, 83 deletions
diff --git a/features/project/graph.feature b/features/project/graph.feature
deleted file mode 100644
index b25c73ad870..00000000000
--- a/features/project/graph.feature
+++ /dev/null
@@ -1,33 +0,0 @@
-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
diff --git a/features/steps/project/graph.rb b/features/steps/project/graph.rb
deleted file mode 100644
index b9cddf4041d..00000000000
--- a/features/steps/project/graph.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-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
diff --git a/spec/features/projects/graph_spec.rb b/spec/features/projects/graph_spec.rb
new file mode 100644
index 00000000000..57172610aed
--- /dev/null
+++ b/spec/features/projects/graph_spec.rb
@@ -0,0 +1,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