File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
spec/lib/code_ownership/private/validations Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 1+ 3.2.2
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ def for_file(file)
3939
4040 Mapper . all . each do |mapper |
4141 owner = mapper . map_file_to_owner ( file )
42- break if owner
42+ break if owner # TODO: what if there are multiple owners? Should we respond with an error instead of the first match?
4343 end
4444
4545 @for_file [ file ] = owner
Original file line number Diff line number Diff line change @@ -90,6 +90,37 @@ module CodeOwnership
9090 end
9191 end
9292 end
93+
94+ context 'with mutliple directory ownership files' do
95+ before do
96+ write_configuration
97+
98+ write_file ( 'config/teams/bar.yml' , <<~CONTENTS )
99+ name: Bar
100+ CONTENTS
101+
102+ write_file ( 'config/teams/foo.yml' , <<~CONTENTS )
103+ name: Foo
104+ CONTENTS
105+
106+ write_file ( 'app/services/exciting/some_other_file.rb' , <<~YML )
107+ class Exciting::SomeOtherFile; end
108+ YML
109+
110+ write_file ( 'app/services/exciting/.codeowner' , <<~YML )
111+ Bar
112+ YML
113+
114+ write_file ( 'app/services/.codeowner' , <<~YML )
115+ Foo
116+ YML
117+ end
118+
119+ it 'allows multiple .codeowner ancestor files' do
120+ expect ( CodeOwnership . for_file ( 'app/services/exciting/some_other_file.rb' ) . name ) . to eq 'Bar'
121+ expect { CodeOwnership . validate! } . to_not raise_error
122+ end
123+ end
93124 end
94125 end
95126end
You can’t perform that action at this time.
0 commit comments