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