2019-12-26 22:10:19 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
require 'rubocop_spec_helper'
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
require_relative '../../../rubocop/cop/project_path_helper'
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
RSpec.describe RuboCop::Cop::ProjectPathHelper do
|
2017-09-10 17:25:29 +05:30
|
|
|
context "when using namespace_project with the project's namespace" do
|
|
|
|
let(:source) { 'edit_namespace_project_issue_path(@issue.project.namespace, @issue.project, @issue)' }
|
|
|
|
let(:correct_source) { 'edit_project_issue_path(@issue.project, @issue)' }
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
it 'registers an offense and corrects', :aggregate_failures do
|
|
|
|
expect_offense(<<~CODE)
|
|
|
|
#{source}
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use short project path helpers without explicitly passing the namespace[...]
|
|
|
|
CODE
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
expect_correction(<<~CODE)
|
|
|
|
#{correct_source}
|
|
|
|
CODE
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when using namespace_project with a different namespace' do
|
|
|
|
it 'registers no offense' do
|
2021-03-11 19:13:27 +05:30
|
|
|
expect_no_offenses('edit_namespace_project_issue_path(namespace, project)')
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|