Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-28 21:06:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-28 21:06:11 +0300
commit4f05a630951858cc2b7dafada27f3dcf87ba29bd (patch)
tree1b87468300c53594465ca10f89e082651a08707c /spec/rubocop
parent7cdd70dcec27402e89e65451b4b1feb75b5eb267 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop')
-rw-r--r--spec/rubocop/cop/put_project_routes_under_scope_spec.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/rubocop/cop/put_project_routes_under_scope_spec.rb b/spec/rubocop/cop/put_project_routes_under_scope_spec.rb
new file mode 100644
index 00000000000..b0f1e52f397
--- /dev/null
+++ b/spec/rubocop/cop/put_project_routes_under_scope_spec.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require 'rubocop'
+require_relative '../../../rubocop/cop/put_project_routes_under_scope'
+
+describe RuboCop::Cop::PutProjectRoutesUnderScope do
+ include CopHelper
+
+ subject(:cop) { described_class.new }
+
+ before do
+ allow(cop).to receive(:in_project_routes?).and_return(true)
+ end
+
+ it 'registers an offense when route is outside scope' do
+ expect_offense(<<~PATTERN.strip_indent)
+ scope '-' do
+ resource :issues
+ end
+
+ resource :notes
+ ^^^^^^^^^^^^^^^ Put new project routes under /-/ scope
+ PATTERN
+ end
+
+ it 'does not register an offense when resource inside the scope' do
+ expect_no_offenses(<<~PATTERN.strip_indent)
+ scope '-' do
+ resource :issues
+ resource :notes
+ end
+ PATTERN
+ end
+
+ it 'does not register an offense when resource is deep inside the scope' do
+ expect_no_offenses(<<~PATTERN.strip_indent)
+ scope '-' do
+ resource :issues
+ resource :projects do
+ resource :issues do
+ resource :notes
+ end
+ end
+ end
+ PATTERN
+ end
+end