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 ...@@ -84,6 +84,8 @@ module Gitlab
end end
def valid_project_slug?(found_project) def valid_project_slug?(found_project)
return false unless found_project
project_slug == found_project.full_path_slug project_slug == found_project.full_path_slug
end end
......
...@@ -128,6 +128,14 @@ RSpec.describe Gitlab::Email::Handler::CreateIssueHandler do ...@@ -128,6 +128,14 @@ RSpec.describe Gitlab::Email::Handler::CreateIssueHandler do
expect { receiver.execute }.to raise_error(Gitlab::Email::ProjectNotFound) expect { receiver.execute }.to raise_error(Gitlab::Email::ProjectNotFound)
end end
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 end
def email_fixture(path) 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