chore: add more fields in get issue querey

This commit is contained in:
Muhsin Keloth
2024-05-10 16:53:01 +05:30
parent ecce6e021b
commit 5d48c2b1e5
3 changed files with 24 additions and 8 deletions
@@ -1,5 +1,5 @@
class Api::V1::Accounts::Integrations::LinearController < Api::V1::Accounts::BaseController
before_action :fetch_conversation, only: [:link_issue]
before_action :fetch_conversation, only: [:link_issue, :linked_issue]
def teams
teams = linear_processor_service.teams
@@ -51,10 +51,7 @@ class Api::V1::Accounts::Integrations::LinearController < Api::V1::Accounts::Bas
end
def linked_issue
render json: { error: 'Specify link with parameter link' }, status: :unprocessable_entity if params[:link].blank? && return
url = params[:link]
issues = linear_processor_service.linked_issue(url)
issues = linear_processor_service.linked_issue(conversation_link)
if issues.is_a?(Hash) && issues[:error]
render json: { error: issues[:error] }, status: :unprocessable_entity
+18
View File
@@ -68,8 +68,26 @@ module LinearQueries
title
issue {
id
identifier
title
description
priority
createdAt
state {
name
}
state {
name
}
assignee {
name
}
labels {
nodes{
id
name
}
}
}
}
}
@@ -222,7 +222,8 @@ RSpec.describe 'Linear Integration API', type: :request do
end
describe 'GET /api/v1/accounts/:account_id/integrations/linear/linked_issue' do
let(:link) { 'https://linear.app/issue1' }
let(:conversation) { create(:conversation, account: account) }
let(:link) { "#{ENV.fetch('FRONTEND_URL', nil)}/app/accounts/#{account.id}/conversations/#{conversation.display_id}" }
context 'when it is an authenticated user' do
context 'when linked issue is found' do
@@ -231,7 +232,7 @@ RSpec.describe 'Linear Integration API', type: :request do
it 'returns linked issue' do
allow(processor_service).to receive(:linked_issue).with(link).and_return(linked_issue)
get "/api/v1/accounts/#{account.id}/integrations/linear/linked_issue",
params: { link: link },
params: { conversation_id: conversation.display_id },
headers: agent.create_new_auth_token,
as: :json
expect(response).to have_http_status(:ok)
@@ -243,7 +244,7 @@ RSpec.describe 'Linear Integration API', type: :request do
it 'returns error message' do
allow(processor_service).to receive(:linked_issue).with(link).and_return(error: 'error message')
get "/api/v1/accounts/#{account.id}/integrations/linear/linked_issue",
params: { link: link },
params: { conversation_id: conversation.display_id },
headers: agent.create_new_auth_token,
as: :json
expect(response).to have_http_status(:unprocessable_entity)