diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-04-07 00:27:28 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-05-17 00:27:16 +0300 |
commit | 8156475ea501221c3ba1bf3280e8368b354839bc (patch) | |
tree | cd54d29751e40ab8423bf8cdf324a7548f73acf4 /spec/lib/gitlab/email | |
parent | 30b34437795eec6f55fb269cb6eff4a4f9da9cfc (diff) |
Report better errors. TODO: Enable skipped test
Diffstat (limited to 'spec/lib/gitlab/email')
-rw-r--r-- | spec/lib/gitlab/email/receiver_spec.rb | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/spec/lib/gitlab/email/receiver_spec.rb b/spec/lib/gitlab/email/receiver_spec.rb index d1b52b9d086..c0fc18a9f83 100644 --- a/spec/lib/gitlab/email/receiver_spec.rb +++ b/spec/lib/gitlab/email/receiver_spec.rb @@ -210,10 +210,12 @@ describe Gitlab::Email::Receiver, lib: true do end context "something is wrong" do + before do + project + end + context "when the issue could not be saved" do before do - project - allow_any_instance_of(Issue).to receive(:persisted?).and_return(false) end @@ -225,11 +227,24 @@ describe Gitlab::Email::Receiver, lib: true do context "when the authentication_token token didn't match" do let!(:email_raw) { fixture_file("emails/wrong_authentication_token.eml") } - before do - project + it "raises an UserNotAuthorizedError" do + expect { receiver.execute }.to raise_error(Gitlab::Email::Receiver::UserNotAuthorizedError) end + end + + context "when project is private" do + let(:project) { create(:project, :private, namespace: namespace) } + + it "raises a ProjectNotFound if the user is not a member" do + expect { receiver.execute }.to raise_error(Gitlab::Email::Receiver::ProjectNotFound) + end + + it "raises a UserNotAuthorizedError if the user has no sufficient permission" do + skip("Find a role which can :read_project but can't :create_issue") + + project.update(group: create(:group)) + project.group.add_guest(user) - it "raises an UserNotAuthorizedError" do expect { receiver.execute }.to raise_error(Gitlab::Email::Receiver::UserNotAuthorizedError) end end |