Commit cc8a8e97 authored by Jarka Košanová's avatar Jarka Košanová

Merge branch '215189-add-section-attribute-to-gitlab_codeowners_entry' into 'master'

Add section attribute to Gitlab::CodeOwners::Entry

See merge request gitlab-org/gitlab!30103
parents be7874c2 eb3bffcc
......@@ -5,15 +5,15 @@ module Gitlab
class Entry
include ::Gitlab::Utils::StrongMemoize
Data = Struct.new(:pattern, :owner_line)
Data = Struct.new(:pattern, :owner_line, :section)
attr_reader :data
protected :data
delegate :pattern, :hash, :owner_line, to: :data
delegate :pattern, :hash, :owner_line, :section, to: :data
def initialize(pattern, owner_line)
@data = Data.new(pattern, owner_line)
def initialize(pattern, owner_line, section = "CODEOWNERS")
@data = Data.new(pattern, owner_line, section)
end
def all_users
......
......@@ -2,7 +2,13 @@
require 'spec_helper'
describe Gitlab::CodeOwners::Entry do
subject(:entry) { described_class.new('/**/file', '@user jane@gitlab.org @group @group/nested-group') }
subject(:entry) do
described_class.new(
"/**/file",
"@user jane@gitlab.org @group @group/nested-group",
"Documentation"
)
end
let(:user) { build(:user, username: 'user') }
let(:group_user) { create(:user) }
......@@ -13,7 +19,7 @@ describe Gitlab::CodeOwners::Entry do
end
it 'is uniq by the pattern and owner line' do
equal_entry = described_class.new('/**/file', '@user jane@gitlab.org @group @group/nested-group')
equal_entry = entry.clone
other_entry = described_class.new('/**/other_file', '@user jane@gitlab.org @group')
expect(equal_entry).to eq(entry)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment