Commit da6bd2eb authored by Stan Hu's avatar Stan Hu

Handle invalid project ID in reply-by-email

When an invalid project ID were supplied, the reply processor would
quietly fail with an error:

```
undefined method `full_path_slug' for nil:NilClass
```

This commit checks for a nil Project and ensures the proper exception is
thrown.

Changelog: fixed
parent 4f68daee
......@@ -84,6 +84,8 @@ module Gitlab
end
def valid_project_slug?(found_project)
return false unless found_project
project_slug == found_project.full_path_slug
end
......
......@@ -128,6 +128,14 @@ RSpec.describe Gitlab::Email::Handler::CreateIssueHandler do
expect { receiver.execute }.to raise_error(Gitlab::Email::ProjectNotFound)
end
end
context 'when project ID is invalid' do
it 'raises a ProjectNotFound' do
handler = described_class.new(email_raw, "gitlabhq-gitlabhq-#{Gitlab::Database::MAX_INT_VALUE}-#{user.incoming_email_token}-issue")
expect { handler.execute }.to raise_error(Gitlab::Email::ProjectNotFound)
end
end
end
def email_fixture(path)
......
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