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

project_path_helper_spec.rb « cop « rubocop « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 16782802a27cbdb4f45d109c2d60a6e7b180eeee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

require 'fast_spec_helper'

require 'rubocop'
require_relative '../../../rubocop/cop/project_path_helper'

RSpec.describe RuboCop::Cop::ProjectPathHelper do
  subject(:cop) { described_class.new }

  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)' }

    it 'registers an offense and corrects', :aggregate_failures do
      expect_offense(<<~CODE)
        #{source}
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use short project path helpers without explicitly passing the namespace[...]
      CODE

      expect_correction(<<~CODE)
        #{correct_source}
      CODE
    end
  end

  context 'when using namespace_project with a different namespace' do
    it 'registers no offense' do
      expect_no_offenses('edit_namespace_project_issue_path(namespace, project)')
    end
  end
end