diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-07-19 12:11:33 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-07-19 12:11:33 +0300 |
commit | 75275d972619992ec41c6b72297984b463aa9656 (patch) | |
tree | 0086b5092ec1cdc0b81eab096b8134d43666e03e | |
parent | fca7a77a23ac6e1723a6449287f731634d735b23 (diff) | |
parent | 3715c1cfb5bf3d904e7d2b0f40c8b64f09a7e231 (diff) |
Merge branch 'issue_35132' into 'master'
Fix external issue trackers redirect
Closes #35132
See merge request !12923
5 files changed, 15 insertions, 11 deletions
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 13f03e7e63e..0ac9da2ff0f 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -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 diff --git a/app/models/project_services/gitlab_issue_tracker_service.rb b/app/models/project_services/gitlab_issue_tracker_service.rb index 420102875a5..88c428b4aae 100644 --- a/app/models/project_services/gitlab_issue_tracker_service.rb +++ b/app/models/project_services/gitlab_issue_tracker_service.rb @@ -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 diff --git a/app/models/project_services/issue_tracker_service.rb b/app/models/project_services/issue_tracker_service.rb index 1fa4cd4db30..6d6a3ae3647 100644 --- a/app/models/project_services/issue_tracker_service.rb +++ b/app/models/project_services/issue_tracker_service.rb @@ -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 diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 22aad0b3225..1f9ca765233 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -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 diff --git a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb index 6ee30e86495..d45e0a441d4 100644 --- a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb +++ b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb @@ -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 |