From 53719ecb80b757a2096e55cd3da995ac9db8d3b8 Mon Sep 17 00:00:00 2001
From: Yorick Peterse <yorickpeterse@gmail.com>
Date: Wed, 9 Mar 2016 15:38:07 +0100
Subject: [PATCH] Handle permissions for ExternalIssue instances

This fixes the remainder of the GitPushService specs.
---
 app/models/ability.rb                  | 5 +++++
 spec/services/git_push_service_spec.rb | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/app/models/ability.rb b/app/models/ability.rb
index f34554d557..fe9e0aab71 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -9,6 +9,7 @@ class Ability
       when CommitStatus then commit_status_abilities(user, subject)
       when Project then project_abilities(user, subject)
       when Issue then issue_abilities(user, subject)
+      when ExternalIssue then external_issue_abilities(user, subject)
       when Note then note_abilities(user, subject)
       when ProjectSnippet then project_snippet_abilities(user, subject)
       when PersonalSnippet then personal_snippet_abilities(user, subject)
@@ -424,6 +425,10 @@ class Ability
       end
     end
 
+    def external_issue_abilities(user, subject)
+      project_abilities(user, subject.project)
+    end
+
     private
 
     def named_abilities(name)
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb
index 7fee16a058..82813cee22 100644
--- a/spec/services/git_push_service_spec.rb
+++ b/spec/services/git_push_service_spec.rb
@@ -367,7 +367,7 @@ describe GitPushService, services: true do
             }
           }.to_json
 
-          execute_service(project, user, @oldrev, @newrev, @ref )
+          execute_service(project, commit_author, @oldrev, @newrev, @ref )
           expect(WebMock).to have_requested(:post, jira_api_transition_url).with(
             body: transition_body
           ).once
@@ -378,7 +378,7 @@ describe GitPushService, services: true do
             body: "Issue solved with [#{closing_commit.id}|http://localhost/#{project.path_with_namespace}/commit/#{closing_commit.id}]."
           }.to_json
 
-          execute_service(project, user, @oldrev, @newrev, @ref )
+          execute_service(project, commit_author, @oldrev, @newrev, @ref )
           expect(WebMock).to have_requested(:post, jira_api_comment_url).with(
             body: comment_body
           ).once
-- 
2.30.9