Commit 6d0d3bfe authored by Arturo Herrero's avatar Arturo Herrero Committed by Tom Quirk

Fix instance variable and build

parent 672fb06c
......@@ -14,7 +14,6 @@ module Projects
before_action :check_feature_enabled!
before_action :check_issues_show_enabled!, only: :show
before_action :issue_json, only: :show
before_action do
push_frontend_feature_flag(:jira_issues_integration, project, type: :licensed, default_enabled: true)
......@@ -39,7 +38,9 @@ module Projects
def show
respond_to do |format|
format.html
format.html do
@issue_json = issue_json
end
format.json do
render json: issue_json
end
......@@ -65,8 +66,8 @@ module Projects
end
def issue_json
@issue_json ||= ::Integrations::Jira::IssueDetailSerializer.new
.represent(project.jira_service.find_issue(params[:id], rendered_fields: true), project: project)
::Integrations::Jira::IssueDetailSerializer.new
.represent(project.jira_service.find_issue(params[:id], rendered_fields: true), project: project)
end
def finder
......
......@@ -195,29 +195,33 @@ RSpec.describe Projects::Integrations::Jira::IssuesController do
end
context 'when `jira_issues_show_integration` feature is enabled' do
let(:jira_issue) { {} }
let(:jira_issue) { { 'from' => 'jira' } }
let(:issue_json) { { 'from' => 'backend' } }
before do
stub_feature_flags(jira_issues_show_integration: true)
expect_next_found_instance_of(JiraService) do |service|
expect(service).to receive(:find_issue).with('1', rendered_fields: true).and_return(jira_issue)
end
expect_next_instance_of(Integrations::Jira::IssueDetailSerializer) do |serializer|
expect(serializer).to receive(:represent).with(jira_issue, project: project).and_return(issue_json)
end
end
it 'renders `show` template' do
get :show, params: { namespace_id: project.namespace, project_id: project, id: 1 }
expect(assigns(:issue_json)).to eq(issue_json)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:show)
end
it 'returns JSON response' do
expect_next_found_instance_of(JiraService) do |service|
expect(service).to receive(:find_issue).with('1', rendered_fields: true).and_return(jira_issue)
end
expect_next_instance_of(Integrations::Jira::IssueDetailSerializer) do |serializer|
expect(serializer).to receive(:represent).with(jira_issue, project: project)
end
get :show, params: { namespace_id: project.namespace, project_id: project, id: 1, format: :json }
expect(json_response).to eq(issue_json)
end
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