chore: rename from team_entites to team_entities

This commit is contained in:
Muhsin Keloth
2024-05-10 15:16:56 +05:30
parent b25e395bf7
commit 4d47fc1c25
10 changed files with 71 additions and 20 deletions
@@ -8,9 +8,9 @@ class Api::V1::Accounts::Integrations::LinearController < Api::V1::Accounts::Bas
end
end
def team_entites
def team_entities
team_id = params[:team_id]
entites = linear_processor_service.team_entites(team_id)
entites = linear_processor_service.team_entities(team_id)
if entites.is_a?(Hash) && entites[:error]
render json: { error: entites[:error] }, status: :unprocessable_entity
else
@@ -203,6 +203,47 @@
"API_SUCCESS": "Dashboard app deleted successfully",
"API_ERROR": "We couldn't delete the app. Please try again later"
}
},
"LINEAR": {
"ADD_OR_LINK": {
"TITLE": "Create/link linear issue",
"DESCRIPTION": "Create or link a linear issue to the conversation",
"FORM": {
"TITLE": {
"LABEL": "Title",
"PLACEHOLDER": "Enter title",
"REQUIRED_ERROR": "Title is required"
},
"DESCRIPTION": {
"LABEL": "Description",
"PLACEHOLDER": "SLA for premium customers"
},
"TEAM": {
"LABEL": "Team",
"REQUIRED_ERROR": "Team is required"
},
"ASSIGNEE": {
"LABEL": "Assignee"
},
"PRIORITY": {
"LABEL": "Priority"
},
"LABEL": {
"LABEL": "Label"
},
"STATUS": {
"LABEL": "Status"
},
"PROJECT": {
"LABEL": "Project"
}
},
"CREATE": "Create",
"CANCEL": "Cancel",
"CREATE_ERROR": "There was an error creating the issue, please try again",
"LOADING_TEAM_ERROR": "There was an error fetching the teams, please try again",
"LOADING_TEAM_ENTITIES_ERROR": "There was an error fetching the team entities, please try again"
}
}
}
}
@@ -0,0 +1,10 @@
import { required } from 'vuelidate/lib/validators';
export default {
title: {
required,
},
teamId: {
required,
},
};
+1 -1
View File
@@ -230,7 +230,7 @@ Rails.application.routes.draw do
resource :linear, controller: 'linear', only: [] do
collection do
get :teams
get :team_entites
get :team_entities
post :create_issue
post :link_issue
post :unlink_issue
+2 -2
View File
@@ -8,8 +8,8 @@ class Integrations::Linear::ProcessorService
response['teams']['nodes'].map(&:as_json)
end
def team_entites(team_id)
response = linear_client.team_entites(team_id)
def team_entities(team_id)
response = linear_client.team_entities(team_id)
return response if response[:error]
{
+2 -2
View File
@@ -23,10 +23,10 @@ class Linear
execute_query(LinearQueries::TEAMS_QUERY)
end
def team_entites(team_id)
def team_entities(team_id)
raise ArgumentError, 'Missing team id' if team_id.blank?
execute_query(LinearQueries.team_entites_query(team_id))
execute_query(LinearQueries.team_entities_query(team_id))
end
def search_issue(term)
+1 -1
View File
@@ -10,7 +10,7 @@ module LinearQueries
}
GRAPHQL
def self.team_entites_query(team_id)
def self.team_entities_query(team_id)
<<~GRAPHQL
query {
users {
@@ -40,7 +40,7 @@ RSpec.describe 'Linear Integration API', type: :request do
end
end
describe 'GET /api/v1/accounts/:account_id/integrations/linear/team_entites' do
describe 'GET /api/v1/accounts/:account_id/integrations/linear/team_entities' do
let(:team_id) { 'team1' }
context 'when it is an authenticated user' do
@@ -55,8 +55,8 @@ RSpec.describe 'Linear Integration API', type: :request do
end
it 'returns team entities data' do
allow(processor_service).to receive(:team_entites).with(team_id).and_return(team_entities_data)
get "/api/v1/accounts/#{account.id}/integrations/linear/team_entites",
allow(processor_service).to receive(:team_entities).with(team_id).and_return(team_entities_data)
get "/api/v1/accounts/#{account.id}/integrations/linear/team_entities",
params: { team_id: team_id },
headers: agent.create_new_auth_token,
as: :json
@@ -70,8 +70,8 @@ RSpec.describe 'Linear Integration API', type: :request do
context 'when data retrieval fails' do
it 'returns error message' do
allow(processor_service).to receive(:team_entites).with(team_id).and_return(error: 'error message')
get "/api/v1/accounts/#{account.id}/integrations/linear/team_entites",
allow(processor_service).to receive(:team_entities).with(team_id).and_return(error: 'error message')
get "/api/v1/accounts/#{account.id}/integrations/linear/team_entities",
params: { team_id: team_id },
headers: agent.create_new_auth_token,
as: :json
@@ -35,7 +35,7 @@ describe Integrations::Linear::ProcessorService do
end
end
describe '#team_entites' do
describe '#team_entities' do
let(:team_id) { 'team1' }
let(:entities_response) do
{
@@ -48,8 +48,8 @@ describe Integrations::Linear::ProcessorService do
context 'when Linear client returns valid data' do
it 'returns parsed entity data' do
allow(linear_client).to receive(:team_entites).with(team_id).and_return(entities_response)
result = service.team_entites(team_id)
allow(linear_client).to receive(:team_entities).with(team_id).and_return(entities_response)
result = service.team_entities(team_id)
expect(result).to have_key(:users)
expect(result).to have_key(:projects)
expect(result).to have_key(:states)
@@ -61,8 +61,8 @@ describe Integrations::Linear::ProcessorService do
let(:error_response) { { error: 'Some error message' } }
it 'returns the error' do
allow(linear_client).to receive(:team_entites).with(team_id).and_return(error_response)
result = service.team_entites(team_id)
allow(linear_client).to receive(:team_entities).with(team_id).and_return(error_response)
result = service.team_entities(team_id)
expect(result).to eq(error_response)
end
end
+2 -2
View File
@@ -57,7 +57,7 @@ describe Linear do
end
it 'returns team entities' do
response = linear_client.team_entites(team_id)
response = linear_client.team_entities(team_id)
expect(response).to eq({
'users' => { 'nodes' => [{ 'id' => 'user1', 'name' => 'User One' }] },
'projects' => { 'nodes' => [{ 'id' => 'project1', 'name' => 'Project One' }] },
@@ -75,7 +75,7 @@ describe Linear do
end
it 'raises an exception' do
response = linear_client.team_entites(team_id)
response = linear_client.team_entities(team_id)
expect(response).to eq({ :error => 'Error: the server responded with status 422' })
end
end