Commit eb3bffcc authored by Kerri Miller's avatar Kerri Miller

Add section attribute to Entry

Extending this class to support a "section" attribute will allow us
to eventually support CODEOWNERS files that offer organizing entries
into different sections.
parent 68d82ed0
......@@ -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