Commit 7339464e authored by Jacob Vosmaer's avatar Jacob Vosmaer

Fail faster on an invalid target_type

parent e5cf5f4f
...@@ -12,6 +12,8 @@ class NotesFinder ...@@ -12,6 +12,8 @@ class NotesFinder
project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh
when "snippet" when "snippet"
project.snippets.find(target_id).notes.fresh project.snippets.find(target_id).notes.fresh
else
raise 'invalid target_type'
end end
end end
end end
...@@ -22,5 +22,10 @@ describe NotesFinder do ...@@ -22,5 +22,10 @@ describe NotesFinder do
notes = NotesFinder.new.execute(project, user, params) notes = NotesFinder.new.execute(project, user, params)
notes.size.should eq(2) notes.size.should eq(2)
end 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
end end
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