Commit 11525135 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch '223916-create-a-jira-issues-controller' into 'master'

Create a Jira Issues Controller

See merge request gitlab-org/gitlab!35273
parents f316f047 b8e27cb0
# frozen_string_literal: true
module Projects
module Integrations
module Jira
class IssuesController < Projects::ApplicationController
include RecordUserLastActivity
before_action :check_feature_enabled!
before_action :check_issues_available!
before_action do
push_frontend_feature_flag(:jira_integration, project)
push_frontend_feature_flag(:vue_issuables_list, project)
end
def index
end
protected
def check_feature_enabled!
return render_404 unless Feature.enabled?(:jira_integration, project)
end
end
end
end
end
- page_title _('Jira Issues')
.js-issuables-list{ data: { endpoint: expose_url(api_v4_groups_issues_path(id: @project.group.id)),
'can-bulk-edit': false,
'empty-svg-path': image_path('illustrations/issues.svg'),
'sort-key': @sort } }
...@@ -100,6 +100,12 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -100,6 +100,12 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :dependencies, only: [:index] resources :dependencies, only: [:index]
resources :licenses, only: [:index, :create, :update] resources :licenses, only: [:index, :create, :update]
resources :on_demand_scans, only: [:index], controller: :on_demand_scans resources :on_demand_scans, only: [:index], controller: :on_demand_scans
namespace :integrations do
namespace :jira do
resources :issues, only: [:index]
end
end
end end
# End of the /-/ scope. # End of the /-/ scope.
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::Integrations::Jira::IssuesController do
include ProjectForksHelper
let(:project) { create(:project) }
let(:user) { create(:user) }
describe 'GET #index' do
context 'external issue tracker' do
before do
sign_in(user)
project.add_developer(user)
create(:jira_service, project: project)
end
context 'when jira_integration feature disabled' do
it 'returns 404 status' do
stub_feature_flags(jira_integration: false)
get :index, params: { namespace_id: project.namespace, project_id: project }
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when GitLab issues disabled' do
it 'returns 404 status' do
project.issues_enabled = false
project.save!
get :index, params: { namespace_id: project.namespace, project_id: project }
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when GitLab issues enabled' do
it 'renders the "index" template' do
get :index, params: { namespace_id: project.namespace, project_id: project }
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
end
end
context 'when project has moved' do
let(:new_project) { create(:project) }
before do
project.route.destroy!
new_project.redirect_routes.create!(path: project.full_path)
new_project.add_developer(user)
end
it 'redirects to the new issue tracker from the old one' do
get :index, params: { namespace_id: project.namespace, project_id: project }
expect(response).to redirect_to(project_integrations_jira_issues_path(new_project))
expect(response).to have_gitlab_http_status(:found)
end
end
end
context 'external authorization' do
before do
sign_in user
project.add_developer(user)
end
it_behaves_like 'unauthorized when external service denies access' do
subject { get :index, params: { namespace_id: project.namespace, project_id: project } }
end
end
end
end
...@@ -58,4 +58,10 @@ RSpec.describe 'EE-specific project routing' do ...@@ -58,4 +58,10 @@ RSpec.describe 'EE-specific project routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/audit_events", "/gitlab/gitlabhq/-/audit_events" it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/audit_events", "/gitlab/gitlabhq/-/audit_events"
end end
end end
describe Projects::Integrations::Jira::IssuesController, 'routing', type: :routing do
it "to #index" do
expect(get("/gitlab/gitlabhq/-/integrations/jira/issues")).to route_to('projects/integrations/jira/issues#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
end
end
end end
...@@ -12716,6 +12716,9 @@ msgstr "" ...@@ -12716,6 +12716,9 @@ msgstr ""
msgid "January" msgid "January"
msgstr "" msgstr ""
msgid "Jira Issues"
msgstr ""
msgid "Jira import is already running." msgid "Jira import is already running."
msgstr "" msgstr ""
......
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