Commit 3715c1cf authored by Felipe Artur's avatar Felipe Artur

Fix external issue trackers redirect

parent 05329d4a
......@@ -266,7 +266,7 @@ class Projects::IssuesController < Projects::ApplicationController
if action_name == 'new'
redirect_to external.new_issue_path
else
redirect_to external.project_path
redirect_to external.issue_tracker_path
end
end
......
......@@ -23,7 +23,7 @@ class GitlabIssueTrackerService < IssueTrackerService
project_issue_url(project, id: iid)
end
def project_path
def issue_tracker_path
project_issues_path(project)
end
......
......@@ -20,8 +20,8 @@ class IssueTrackerService < Service
self.issues_url.gsub(':id', iid.to_s)
end
def project_path
read_attribute(:project_url)
def issue_tracker_path
project_url
end
def new_issue_path
......
......@@ -7,14 +7,16 @@ describe Projects::IssuesController do
describe "GET #index" do
context 'external issue tracker' do
let!(:service) do
create(:custom_issue_tracker_service, project: project, title: 'Custom Issue Tracker', project_url: 'http://test.com')
end
it 'redirects to the external issue tracker' do
external = double(project_path: 'https://example.com/project')
allow(project).to receive(:external_issue_tracker).and_return(external)
controller.instance_variable_set(:@project, project)
get :index, namespace_id: project.namespace, project_id: project
expect(response).to redirect_to('https://example.com/project')
expect(response).to redirect_to(service.issue_tracker_path)
end
end
......@@ -139,19 +141,21 @@ describe Projects::IssuesController do
end
context 'external issue tracker' do
let!(:service) do
create(:custom_issue_tracker_service, project: project, title: 'Custom Issue Tracker', new_issue_url: 'http://test.com')
end
before do
sign_in(user)
project.team << [user, :developer]
end
it 'redirects to the external issue tracker' do
external = double(new_issue_path: 'https://example.com/issues/new')
allow(project).to receive(:external_issue_tracker).and_return(external)
controller.instance_variable_set(:@project, project)
get :new, namespace_id: project.namespace, project_id: project
expect(response).to redirect_to('https://example.com/issues/new')
expect(response).to redirect_to('http://test.com')
end
end
end
......
......@@ -43,7 +43,7 @@ describe GitlabIssueTrackerService, models: true do
end
it 'gives the correct path' do
expect(service.project_path).to eq("/gitlab/root/#{project.path_with_namespace}/issues")
expect(service.issue_tracker_path).to eq("/gitlab/root/#{project.path_with_namespace}/issues")
expect(service.new_issue_path).to eq("/gitlab/root/#{project.path_with_namespace}/issues/new")
expect(service.issue_path(432)).to eq("/gitlab/root/#{project.path_with_namespace}/issues/432")
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