From 4f05a630951858cc2b7dafada27f3dcf87ba29bd Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 28 Nov 2019 18:06:11 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../cop/put_project_routes_under_scope_spec.rb | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 spec/rubocop/cop/put_project_routes_under_scope_spec.rb (limited to 'spec/rubocop') 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 -- cgit v1.2.3