@@ -87,8 +87,27 @@ module CodeOwnership
8787 expect ( CodeOwnership . for_file ( 'frontend/javascripts/packages/my_package/[formID]/owned_file.jsx' ) . name ) . to eq 'Bar'
8888 end
8989 end
90+
91+ context 'haml owned file' do
92+ before do
93+ write_configuration
94+ write_file ( 'config/teams/bar.yml' , <<~CONTENTS )
95+ name: Bar
96+ CONTENTS
97+
98+ write_file ( 'packs/my_pack/owned_file.html.haml' , <<~CONTENTS )
99+ -# @team Bar
100+ CONTENTS
101+ end
102+
103+ it 'can find the owner of a haml file with file annotations' do
104+ expect ( CodeOwnership . for_file ( 'packs/my_pack/owned_file.html.haml' ) . name ) . to eq 'Bar'
105+ end
106+ end
90107 end
91108
109+
110+
92111 describe '.remove_file_annotation!' do
93112 subject ( :remove_file_annotation ) do
94113 CodeOwnership . remove_file_annotation! ( filename )
@@ -195,6 +214,43 @@ module CodeOwnership
195214 end
196215 end
197216
217+ context 'haml has annotation' do
218+ let ( :filename ) { 'app.my_file.html.haml' }
219+
220+ before do
221+ write_file ( filename , <<~CONTENTS )
222+ -# @team Foo
223+
224+ -# Some content
225+ CONTENTS
226+
227+ write_file ( 'package.yml' , <<~CONTENTS )
228+ enforce_dependency: true
229+ enforce_privacy: true
230+ CONTENTS
231+ end
232+
233+ it 'removes the annotation' do
234+ current_ownership = CodeOwnership . for_file ( filename )
235+ expect ( current_ownership &.name ) . to eq 'Foo'
236+ expect ( File . read ( filename ) ) . to eq <<~HAML
237+ -# @team Foo
238+
239+ -# Some content
240+ HAML
241+
242+ remove_file_annotation
243+
244+ new_ownership = CodeOwnership . for_file ( filename )
245+ expect ( new_ownership ) . to eq nil
246+ expected_output = <<~HAML
247+ -# Some content
248+ HAML
249+
250+ expect ( File . read ( filename ) ) . to eq expected_output
251+ end
252+ end
253+
198254 context 'file has new lines after the annotation' do
199255 let ( :filename ) { 'app/my_file.rb' }
200256
0 commit comments