diff options
-rw-r--r-- | app/finders/notes_finder.rb | 2 | ||||
-rw-r--r-- | spec/finders/notes_finder_spec.rb | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/app/finders/notes_finder.rb b/app/finders/notes_finder.rb index 384316e14b7..4e80bd81757 100644 --- a/app/finders/notes_finder.rb +++ b/app/finders/notes_finder.rb @@ -12,6 +12,8 @@ class NotesFinder project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh when "snippet" project.snippets.find(target_id).notes.fresh + else + raise 'invalid target_type' end end end diff --git a/spec/finders/notes_finder_spec.rb b/spec/finders/notes_finder_spec.rb index 3b28070ffaa..27eaba8dfa1 100644 --- a/spec/finders/notes_finder_spec.rb +++ b/spec/finders/notes_finder_spec.rb @@ -22,5 +22,10 @@ describe NotesFinder do notes = NotesFinder.new.execute(project, user, params) notes.size.should eq(2) end + + it 'should raise an exception for an invalid target_type' do + params = { target_id: commit.id, target_type: 'invalid' } + expect { NotesFinder.new.execute(project, user, params) }.to raise_error('invalid target_type') + end end end |