Commit a7c823a5 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Give ProjectNotFound when the project is not readable

parent e7a6d17b
......@@ -25,7 +25,7 @@ module Gitlab
def validate_permission!(permission)
raise UserNotFoundError unless author
raise UserBlockedError if author.blocked?
# TODO: Give project not found error if author cannot read project
raise ProjectNotFound unless author.can?(:read_project, project)
raise UserNotAuthorizedError unless author.can?(permission, project)
end
......
......@@ -10,9 +10,6 @@ module Gitlab
end
def execute
# Must be private project without access
raise ProjectNotFound unless author.can?(:read_project, project)
validate_permission!(:create_issue)
validate_authentication_token!
......
......@@ -88,8 +88,8 @@ describe Gitlab::Email::Receiver, lib: true do
project.update_attribute(:visibility_level, Project::PRIVATE)
end
it "raises a UserNotAuthorizedError" do
expect { receiver.execute }.to raise_error(Gitlab::Email::UserNotAuthorizedError)
it "raises a ProjectNotFound" do
expect { receiver.execute }.to raise_error(Gitlab::Email::ProjectNotFound)
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