summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/pages/projects/graphs/show/index.js (renamed from app/assets/javascripts/graphs/graphs_show.js)6
-rw-r--r--app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors.js (renamed from app/assets/javascripts/graphs/stat_graph_contributors.js)2
-rw-r--r--app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_graph.js (renamed from app/assets/javascripts/graphs/stat_graph_contributors_graph.js)2
-rw-r--r--app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_util.js (renamed from app/assets/javascripts/graphs/stat_graph_contributors_util.js)0
-rw-r--r--app/models/deployment.rb4
-rw-r--r--app/models/environment.rb2
-rw-r--r--app/views/projects/environments/metrics.html.haml1
-rw-r--r--app/views/projects/graphs/charts.html.haml2
-rw-r--r--app/views/projects/graphs/show.html.haml3
-rw-r--r--changelogs/unreleased/remove-unnecessary-validate-project.yml5
-rw-r--r--config/webpack.config.js14
-rw-r--r--features/project/network_graph.feature46
-rw-r--r--features/steps/project/network_graph.rb116
-rw-r--r--spec/features/projects/network_graph_spec.rb108
-rw-r--r--spec/javascripts/graphs/stat_graph_contributors_graph_spec.js2
-rw-r--r--spec/javascripts/graphs/stat_graph_contributors_spec.js4
-rw-r--r--spec/javascripts/graphs/stat_graph_contributors_util_spec.js2
17 files changed, 125 insertions, 194 deletions
diff --git a/app/assets/javascripts/graphs/graphs_show.js b/app/assets/javascripts/pages/projects/graphs/show/index.js
index b670e907a5c..f516ff20995 100644
--- a/app/assets/javascripts/graphs/graphs_show.js
+++ b/app/assets/javascripts/pages/projects/graphs/show/index.js
@@ -1,6 +1,6 @@
-import flash from '../flash';
-import { __ } from '../locale';
-import axios from '../lib/utils/axios_utils';
+import flash from '~/flash';
+import { __ } from '~/locale';
+import axios from '~/lib/utils/axios_utils';
import ContributorsStatGraph from './stat_graph_contributors';
document.addEventListener('DOMContentLoaded', () => {
diff --git a/app/assets/javascripts/graphs/stat_graph_contributors.js b/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors.js
index 151a4ce012c..9ac0b4c07e5 100644
--- a/app/assets/javascripts/graphs/stat_graph_contributors.js
+++ b/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors.js
@@ -1,9 +1,9 @@
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, camelcase, one-var-declaration-per-line, quotes, no-param-reassign, quote-props, comma-dangle, prefer-template, max-len, no-return-assign, no-shadow */
import _ from 'underscore';
+import { n__, s__, createDateTimeFormat, sprintf } from '~/locale';
import { ContributorsGraph, ContributorsAuthorGraph, ContributorsMasterGraph } from './stat_graph_contributors_graph';
import ContributorsStatGraphUtil from './stat_graph_contributors_util';
-import { n__, s__, createDateTimeFormat, sprintf } from '../locale';
export default (function() {
function ContributorsStatGraph() {
diff --git a/app/assets/javascripts/graphs/stat_graph_contributors_graph.js b/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_graph.js
index 9a4012232a0..6ffaa277a0a 100644
--- a/app/assets/javascripts/graphs/stat_graph_contributors_graph.js
+++ b/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_graph.js
@@ -7,7 +7,7 @@ import { axisLeft, axisBottom } from 'd3-axis';
import { area } from 'd3-shape';
import { brushX } from 'd3-brush';
import { timeParse } from 'd3-time-format';
-import { dateTickFormat } from '../lib/utils/tick_formats';
+import { dateTickFormat } from '~/lib/utils/tick_formats';
const d3 = { extent, max, select, scaleTime, scaleLinear, axisLeft, axisBottom, area, brushX, timeParse };
diff --git a/app/assets/javascripts/graphs/stat_graph_contributors_util.js b/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_util.js
index 77135ad1f0e..77135ad1f0e 100644
--- a/app/assets/javascripts/graphs/stat_graph_contributors_util.js
+++ b/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_util.js
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index 3aed071dd49..b6cf168d60e 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -1,8 +1,8 @@
class Deployment < ActiveRecord::Base
include InternalId
- belongs_to :project, required: true, validate: true
- belongs_to :environment, required: true, validate: true
+ belongs_to :project, required: true
+ belongs_to :environment, required: true
belongs_to :user
belongs_to :deployable, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
diff --git a/app/models/environment.rb b/app/models/environment.rb
index 2f6eae605ee..f78c21aebe5 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -4,7 +4,7 @@ class Environment < ActiveRecord::Base
NUMBERS = '0'..'9'
SUFFIX_CHARS = LETTERS.to_a + NUMBERS.to_a
- belongs_to :project, required: true, validate: true
+ belongs_to :project, required: true
has_many :deployments, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
diff --git a/app/views/projects/environments/metrics.html.haml b/app/views/projects/environments/metrics.html.haml
index 10812f67cbe..91b3743e9e7 100644
--- a/app/views/projects/environments/metrics.html.haml
+++ b/app/views/projects/environments/metrics.html.haml
@@ -2,7 +2,6 @@
- page_title "Metrics for environment", @environment.name
- content_for :page_specific_javascripts do
= webpack_bundle_tag 'common_vue'
- = webpack_bundle_tag 'common_d3'
.prometheus-container{ class: container_class }
.top-area
diff --git a/app/views/projects/graphs/charts.html.haml b/app/views/projects/graphs/charts.html.haml
index efdb494e1ae..d4b4a6203f3 100644
--- a/app/views/projects/graphs/charts.html.haml
+++ b/app/views/projects/graphs/charts.html.haml
@@ -1,7 +1,5 @@
- @no_container = true
- page_title "Charts"
-- content_for :page_specific_javascripts do
- = webpack_bundle_tag('common_d3')
.repo-charts{ class: container_class }
%h4.sub-header
diff --git a/app/views/projects/graphs/show.html.haml b/app/views/projects/graphs/show.html.haml
index 91d2c48ccd1..c81ee6874e3 100644
--- a/app/views/projects/graphs/show.html.haml
+++ b/app/views/projects/graphs/show.html.haml
@@ -1,8 +1,5 @@
- @no_container = true
- page_title _('Contributors')
-- content_for :page_specific_javascripts do
- = webpack_bundle_tag('common_d3')
- = webpack_bundle_tag('graphs_show')
.js-graphs-show{ class: container_class, 'data-project-graph-path': project_graph_path(@project, current_ref, format: :json) }
.sub-header-block
diff --git a/changelogs/unreleased/remove-unnecessary-validate-project.yml b/changelogs/unreleased/remove-unnecessary-validate-project.yml
new file mode 100644
index 00000000000..ebc8da03dd8
--- /dev/null
+++ b/changelogs/unreleased/remove-unnecessary-validate-project.yml
@@ -0,0 +1,5 @@
+---
+title: 'Remove unecessary validate: true from belongs_to :project'
+merge_request:
+author:
+type: fixed
diff --git a/config/webpack.config.js b/config/webpack.config.js
index 225907a544b..31b29075d62 100644
--- a/config/webpack.config.js
+++ b/config/webpack.config.js
@@ -62,7 +62,6 @@ var config = {
environments: './environments/environments_bundle.js',
environments_folder: './environments/folder/environments_folder_bundle.js',
filtered_search: './filtered_search/filtered_search_bundle.js',
- graphs_show: './graphs/graphs_show.js',
help: './help/help.js',
how_to_merge: './how_to_merge.js',
issue_show: './issue_show/index.js',
@@ -277,19 +276,6 @@ var config = {
},
}),
- // create cacheable common library bundle for all d3 chunks
- new webpack.optimize.CommonsChunkPlugin({
- name: 'common_d3',
- chunks: [
- 'graphs_show',
- 'monitoring',
- 'users',
- ],
- minChunks: function (module, count) {
- return module.resource && /d3-/.test(module.resource);
- },
- }),
-
// create cacheable common library bundles
new webpack.optimize.CommonsChunkPlugin({
names: ['main', 'common', 'webpack_runtime'],
diff --git a/features/project/network_graph.feature b/features/project/network_graph.feature
deleted file mode 100644
index 93c884e23c5..00000000000
--- a/features/project/network_graph.feature
+++ /dev/null
@@ -1,46 +0,0 @@
-Feature: Project Network Graph
- Background:
- Given I sign in as a user
- And I own project "Shop"
- And I visit project "Shop" network page
-
- @javascript
- Scenario: I should see project network
- Then page should have network graph
- And page should select "master" in select box
- And page should have "master" on graph
-
- @javascript
- Scenario: I should see project network with 'test' branch
- When I visit project network page on branch 'test'
- Then page should have 'test' on graph
-
- @javascript
- Scenario: I should switch "branch" and "tag"
- When I switch ref to "feature"
- Then page should select "feature" in select box
- And page should have "feature" on graph
- When I switch ref to "v1.0.0"
- Then page should select "v1.0.0" in select box
- And page should have "v1.0.0" on graph
-
- @javascript
- Scenario: I should looking for a commit by SHA
- When I looking for a commit by SHA of "v1.0.0"
- Then page should have network graph
- And page should select "master" in select box
- And page should have "v1.0.0" on graph
-
- @javascript
- Scenario: I should filter selected tag
- When I switch ref to "v1.0.0"
- Then page should have "v1.0.0" in title
- Then page should have content not containing "v1.0.0"
- When click "Show only selected branch" checkbox
- Then page should only have content from "v1.0.0"
- When click "Show only selected branch" checkbox
- Then page should have content not containing "v1.0.0"
-
- Scenario: I should fail to look for a commit
- When I look for a commit by ";"
- Then I should see non-existent git revision error message
diff --git a/features/steps/project/network_graph.rb b/features/steps/project/network_graph.rb
deleted file mode 100644
index ba98d861e7b..00000000000
--- a/features/steps/project/network_graph.rb
+++ /dev/null
@@ -1,116 +0,0 @@
-class Spinach::Features::ProjectNetworkGraph < Spinach::FeatureSteps
- include SharedAuthentication
- include SharedPaths
- include SharedProject
-
- step 'page should have network graph' do
- expect(page).to have_selector ".network-graph"
- end
-
- When 'I visit project "Shop" network page' do
- # Stub Graph max_size to speed up test (10 commits vs. 650)
- Network::Graph.stub(max_count: 10)
-
- @project = Project.find_by(name: "Shop")
- visit project_network_path(@project, "master")
- end
-
- step "I visit project network page on branch 'test'" do
- visit project_network_path(@project, "'test'")
- end
-
- step 'page should select "master" in select box' do
- expect(page).to have_selector '.dropdown-menu-toggle', text: "master"
- end
-
- step 'page should select "v1.0.0" in select box' do
- expect(page).to have_selector '.dropdown-menu-toggle', text: "v1.0.0"
- end
-
- step 'page should have "master" on graph' do
- page.within '.network-graph' do
- expect(page).to have_content 'master'
- end
- end
-
- step "page should have 'test' on graph" do
- page.within '.network-graph' do
- expect(page).to have_content "'test'"
- end
- end
-
- When 'I switch ref to "feature"' do
- first('.js-project-refs-dropdown').click
-
- page.within '.project-refs-form' do
- click_link 'feature'
- end
- end
-
- When 'I switch ref to "v1.0.0"' do
- first('.js-project-refs-dropdown').click
-
- page.within '.project-refs-form' do
- click_link 'v1.0.0'
- end
- end
-
- When 'click "Show only selected branch" checkbox' do
- find('#filter_ref').click
- end
-
- step 'page should have content not containing "v1.0.0"' do
- page.within '.network-graph' do
- expect(page).to have_content 'Change some files'
- end
- end
-
- step 'page should have "v1.0.0" in title' do
- expect(page).to have_css 'title', text: 'Graph · v1.0.0', visible: false
- end
-
- step 'page should only have content from "v1.0.0"' do
- page.within '.network-graph' do
- expect(page).not_to have_content 'Change some files'
- end
- end
-
- step 'page should select "feature" in select box' do
- expect(page).to have_selector '.dropdown-menu-toggle', text: "feature"
- end
-
- step 'page should select "v1.0.0" in select box' do
- expect(page).to have_selector '.dropdown-menu-toggle', text: "v1.0.0"
- end
-
- step 'page should have "feature" on graph' do
- page.within '.network-graph' do
- expect(page).to have_content 'feature'
- end
- end
-
- When 'I looking for a commit by SHA of "v1.0.0"' do
- page.within ".network-form" do
- fill_in 'extended_sha1', with: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
- find('button').click
- end
- sleep 2
- end
-
- step 'page should have "v1.0.0" on graph' do
- page.within '.network-graph' do
- expect(page).to have_content 'v1.0.0'
- end
- end
-
- When 'I look for a commit by ";"' do
- page.within ".network-form" do
- fill_in 'extended_sha1', with: ';'
- find('button').click
- end
- end
-
- step 'I should see non-existent git revision error message' do
- expect(page).to have_selector '.flash-alert', text: "Git revision ';' does not exist."
- end
-end
diff --git a/spec/features/projects/network_graph_spec.rb b/spec/features/projects/network_graph_spec.rb
new file mode 100644
index 00000000000..9f9a7787093
--- /dev/null
+++ b/spec/features/projects/network_graph_spec.rb
@@ -0,0 +1,108 @@
+require 'spec_helper'
+
+describe 'Project Network Graph', :js do
+ let(:user) { create :user }
+ let(:project) { create :project, :repository, namespace: user.namespace }
+
+ before do
+ sign_in(user)
+
+ # Stub Graph max_size to speed up test (10 commits vs. 650)
+ allow(Network::Graph).to receive(:max_count).and_return(10)
+ end
+
+ context 'when branch is master' do
+ def switch_ref_to(ref_name)
+ first('.js-project-refs-dropdown').click
+
+ page.within '.project-refs-form' do
+ click_link ref_name
+ end
+ end
+
+ def click_show_only_selected_branch_checkbox
+ find('#filter_ref').click
+ end
+
+ before do
+ visit project_network_path(project, 'master')
+ end
+
+ it 'renders project network' do
+ expect(page).to have_selector ".network-graph"
+ expect(page).to have_selector '.dropdown-menu-toggle', text: "master"
+ page.within '.network-graph' do
+ expect(page).to have_content 'master'
+ end
+ end
+
+ it 'switches ref to branch' do
+ switch_ref_to('feature')
+
+ expect(page).to have_selector '.dropdown-menu-toggle', text: 'feature'
+ page.within '.network-graph' do
+ expect(page).to have_content 'feature'
+ end
+ end
+
+ it 'switches ref to tag' do
+ switch_ref_to('v1.0.0')
+
+ expect(page).to have_selector '.dropdown-menu-toggle', text: 'v1.0.0'
+ page.within '.network-graph' do
+ expect(page).to have_content 'v1.0.0'
+ end
+ end
+
+ it 'renders by commit sha of "v1.0.0"' do
+ page.within ".network-form" do
+ fill_in 'extended_sha1', with: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
+ find('button').click
+ end
+
+ expect(page).to have_selector ".network-graph"
+ expect(page).to have_selector '.dropdown-menu-toggle', text: "master"
+ page.within '.network-graph' do
+ expect(page).to have_content 'v1.0.0'
+ end
+ end
+
+ it 'filters select tag' do
+ switch_ref_to('v1.0.0')
+
+ expect(page).to have_css 'title', text: 'Graph · v1.0.0', visible: false
+ page.within '.network-graph' do
+ expect(page).to have_content 'Change some files'
+ end
+
+ click_show_only_selected_branch_checkbox
+
+ page.within '.network-graph' do
+ expect(page).not_to have_content 'Change some files'
+ end
+
+ click_show_only_selected_branch_checkbox
+
+ page.within '.network-graph' do
+ expect(page).to have_content 'Change some files'
+ end
+ end
+
+ it 'renders error message when sha commit not exists' do
+ page.within ".network-form" do
+ fill_in 'extended_sha1', with: ';'
+ find('button').click
+ end
+
+ expect(page).to have_selector '.flash-alert', text: "Git revision ';' does not exist."
+ end
+ end
+
+ it 'renders project network with test branch' do
+ visit project_network_path(project, "'test'")
+
+ page.within '.network-graph' do
+ expect(page).to have_content "'test'"
+ end
+ end
+end
diff --git a/spec/javascripts/graphs/stat_graph_contributors_graph_spec.js b/spec/javascripts/graphs/stat_graph_contributors_graph_spec.js
index 6599839a526..d8a8c8cc260 100644
--- a/spec/javascripts/graphs/stat_graph_contributors_graph_spec.js
+++ b/spec/javascripts/graphs/stat_graph_contributors_graph_spec.js
@@ -1,7 +1,7 @@
/* eslint-disable quotes, jasmine/no-suite-dupes, vars-on-top, no-var */
import { scaleLinear, scaleTime } from 'd3-scale';
import { timeParse } from 'd3-time-format';
-import { ContributorsGraph, ContributorsMasterGraph } from '~/graphs/stat_graph_contributors_graph';
+import { ContributorsGraph, ContributorsMasterGraph } from '~/pages/projects/graphs/show/stat_graph_contributors_graph';
const d3 = { scaleLinear, scaleTime, timeParse };
diff --git a/spec/javascripts/graphs/stat_graph_contributors_spec.js b/spec/javascripts/graphs/stat_graph_contributors_spec.js
index 962423462e7..e03114c1cc5 100644
--- a/spec/javascripts/graphs/stat_graph_contributors_spec.js
+++ b/spec/javascripts/graphs/stat_graph_contributors_spec.js
@@ -1,5 +1,5 @@
-import ContributorsStatGraph from '~/graphs/stat_graph_contributors';
-import { ContributorsGraph } from '~/graphs/stat_graph_contributors_graph';
+import ContributorsStatGraph from '~/pages/projects/graphs/show/stat_graph_contributors';
+import { ContributorsGraph } from '~/pages/projects/graphs/show/stat_graph_contributors_graph';
import { setLanguage } from '../helpers/locale_helper';
diff --git a/spec/javascripts/graphs/stat_graph_contributors_util_spec.js b/spec/javascripts/graphs/stat_graph_contributors_util_spec.js
index 9b47ab62181..22a9afe1a9d 100644
--- a/spec/javascripts/graphs/stat_graph_contributors_util_spec.js
+++ b/spec/javascripts/graphs/stat_graph_contributors_util_spec.js
@@ -1,6 +1,6 @@
/* eslint-disable quotes, no-var, camelcase, object-property-newline, comma-dangle, max-len, vars-on-top, quote-props */
-import ContributorsStatGraphUtil from '~/graphs/stat_graph_contributors_util';
+import ContributorsStatGraphUtil from '~/pages/projects/graphs/show/stat_graph_contributors_util';
describe("ContributorsStatGraphUtil", function () {
describe("#parse_log", function () {