mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Address Rubocop complaints volume 1.
This commit is contained in:
@@ -78,13 +78,13 @@ module Import
|
||||
transition from: GROUPS_AND_USERS_FETCHING, to: [GROUPS_AND_USERS_FETCHING_ERROR,
|
||||
GROUPS_AND_USERS_FETCHING_CANCELLING,
|
||||
GROUPS_AND_USERS_FETCHING_DONE]
|
||||
transition from: GROUPS_AND_USERS_FETCHING_CANCELLING, to: [GROUPS_AND_USERS_FETCHING_CANCELLED]
|
||||
transition from: GROUPS_AND_USERS_FETCHING_CANCELLING, to: [GROUPS_AND_USERS_FETCHING_CANCELLED]
|
||||
transition from: GROUPS_AND_USERS_FETCHING_ERROR, to: [GROUPS_AND_USERS_FETCHING]
|
||||
transition from: GROUPS_AND_USERS_FETCHING_DONE, to: [GROUPS_AND_USERS_IMPORTING]
|
||||
transition from: GROUPS_AND_USERS_IMPORTING, to: [GROUPS_AND_USERS_IMPORTING_ERROR,
|
||||
GROUPS_AND_USERS_IMPORTING_DONE]
|
||||
transition from: GROUPS_AND_USERS_IMPORTING_ERROR, to: [GROUPS_AND_USERS_IMPORTING]
|
||||
transition from: GROUPS_AND_USERS_IMPORTING_DONE, to: [IMPORT_SCOPE]
|
||||
transition from: GROUPS_AND_USERS_IMPORTING, to: [GROUPS_AND_USERS_IMPORTING_ERROR,
|
||||
GROUPS_AND_USERS_IMPORTING_DONE]
|
||||
transition from: GROUPS_AND_USERS_IMPORTING_ERROR, to: [GROUPS_AND_USERS_IMPORTING]
|
||||
transition from: GROUPS_AND_USERS_IMPORTING_DONE, to: [IMPORT_SCOPE]
|
||||
transition from: IMPORT_SCOPE, to: [CONFIGURING]
|
||||
transition from: CONFIGURING, to: [PROJECTS_META_FETCHING]
|
||||
transition from: PROJECTS_META_FETCHING, to: [PROJECTS_META_DONE, PROJECTS_META_ERROR]
|
||||
@@ -98,35 +98,35 @@ module Import
|
||||
transition from: REVERT_CANCELLED, to: [REVERTING]
|
||||
transition from: REVERT_ERROR, to: [REVERTING]
|
||||
|
||||
after_transition(to: :groups_and_users_fetching) do |jira_import, transition|
|
||||
after_transition(to: :groups_and_users_fetching) do |jira_import, _transition|
|
||||
Import::JiraFetchGroupsAndUsersJob.perform_later(jira_import.id)
|
||||
end
|
||||
|
||||
after_transition(to: :groups_and_users_importing) do |jira_import, transition|
|
||||
after_transition(to: :groups_and_users_importing) do |jira_import, _transition|
|
||||
Import::JiraImportGroupsAndUsersJob.perform_later(jira_import.id)
|
||||
end
|
||||
|
||||
after_transition(to: :groups_and_users_fetching_done) do |jira_import, transition|
|
||||
after_transition(to: :groups_and_users_fetching_done) do |jira_import, _transition|
|
||||
jira_import.update_column(:cursor, nil)
|
||||
end
|
||||
|
||||
after_transition(to: :groups_and_users_importing_done) do |jira_import, transition|
|
||||
after_transition(to: :groups_and_users_importing_done) do |jira_import, _transition|
|
||||
jira_import.update_column(:cursor, nil)
|
||||
end
|
||||
|
||||
after_transition(to: :reverted) do |jira_import, transition|
|
||||
after_transition(to: :reverted) do |jira_import, _transition|
|
||||
jira_import.update_column(:cursor, nil)
|
||||
end
|
||||
|
||||
after_transition(to: :instance_meta_fetching) do |jira_import, transition|
|
||||
after_transition(to: :instance_meta_fetching) do |jira_import, _transition|
|
||||
Import::JiraInstanceMetaDataJob.perform_later(jira_import.id)
|
||||
end
|
||||
|
||||
after_transition(to: :projects_meta_fetching) do |jira_import, transition|
|
||||
after_transition(to: :projects_meta_fetching) do |jira_import, _transition|
|
||||
Import::JiraProjectsMetaDataJob.perform_later(jira_import.id)
|
||||
end
|
||||
|
||||
after_transition(to: :importing) do |jira_import, transition|
|
||||
after_transition(to: :importing) do |jira_import, _transition|
|
||||
Import::JiraFetchAndImportProjectsJob.perform_later(jira_import.id)
|
||||
end
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ module Import
|
||||
end
|
||||
|
||||
def to_op_attributes
|
||||
firstname = payload["displayName"].split(" ")[0..-2].join(" ")
|
||||
lastname = payload["displayName"].split(" ")[-1]
|
||||
firstname = payload["displayName"].split[0..-2].join(" ")
|
||||
lastname = payload["displayName"].split[-1]
|
||||
{
|
||||
login: payload["name"],
|
||||
password: SecureRandom.uuid,
|
||||
|
||||
@@ -33,7 +33,7 @@ module Import
|
||||
include JobIteration::Iteration
|
||||
|
||||
class GroupMembersEnumerator
|
||||
def initialize(jira_client, group_name:, page_size: 30, cursor:)
|
||||
def initialize(jira_client, group_name:, cursor:, page_size: 30)
|
||||
@jira_client = jira_client
|
||||
@group_name = group_name
|
||||
@page = @jira_client.group_members(group_name:, start_at: cursor, max_results: page_size)
|
||||
@@ -41,10 +41,10 @@ module Import
|
||||
# Jira DC has it is own page limit configuration.
|
||||
# Therefore it makes sense to respect it.
|
||||
server_page_size = @page["maxResults"]
|
||||
@page_size = if server_page_size != page_size
|
||||
server_page_size
|
||||
else
|
||||
@page_size = if server_page_size == page_size
|
||||
page_size
|
||||
else
|
||||
server_page_size
|
||||
end
|
||||
@cursor = cursor || 0
|
||||
end
|
||||
@@ -65,10 +65,10 @@ module Import
|
||||
# Jira DC has it is own page limit configuration.
|
||||
# Therefore it makes sense to respect it.
|
||||
server_page_size = @page["maxResults"]
|
||||
@page_size = if @page_size != server_page_size
|
||||
server_page_size
|
||||
else
|
||||
@page_size = if @page_size == server_page_size
|
||||
@page_size
|
||||
else
|
||||
server_page_size
|
||||
end
|
||||
|
||||
break if @page["isLast"]
|
||||
@@ -98,7 +98,7 @@ module Import
|
||||
|
||||
def build_enumerator(jira_import_id, cursor:)
|
||||
jira_import = Import::JiraImport.find(jira_import_id)
|
||||
group_names = jira_import.client.groups["groups"].map { |g| g["name"] }
|
||||
group_names = jira_import.client.groups["groups"].pluck("name")
|
||||
enumerator_builder.nested(
|
||||
[
|
||||
->(cursor) { enumerator_builder.array(group_names, cursor:) },
|
||||
@@ -121,7 +121,7 @@ module Import
|
||||
def each_iteration(users_batch, jira_import_id)
|
||||
jira_import = Import::JiraImport.find(jira_import_id)
|
||||
jira_client = jira_import.client
|
||||
updated_at = Time.now
|
||||
updated_at = Time.zone.now
|
||||
created_at = updated_at
|
||||
users_upsert_data = users_batch.map do |jira_user|
|
||||
jira_user_key = jira_user.fetch("key")
|
||||
@@ -137,7 +137,7 @@ module Import
|
||||
updated_at:
|
||||
}
|
||||
end
|
||||
Import::JiraUser.upsert_all(users_upsert_data, unique_by: [:jira_id, :jira_user_key])
|
||||
Import::JiraUser.upsert_all(users_upsert_data, unique_by: %i[jira_id jira_user_key])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ module Import
|
||||
project_ids = jira_import.project_ids
|
||||
jira = jira_import.jira
|
||||
jira_id = jira.id
|
||||
updated_at = Time.now
|
||||
updated_at = Time.zone.now
|
||||
created_at = updated_at
|
||||
jira_client = Import::JiraClient.new(url: jira.url, personal_access_token: jira.personal_access_token)
|
||||
|
||||
@@ -51,7 +51,7 @@ module Import
|
||||
updated_at:
|
||||
}
|
||||
end
|
||||
Import::JiraIssueType.upsert_all(issue_types_upsert_data, unique_by: [:jira_id, :jira_issue_type_id])
|
||||
Import::JiraIssueType.upsert_all(issue_types_upsert_data, unique_by: %i[jira_id jira_issue_type_id])
|
||||
|
||||
# PRIORITIES SYNC
|
||||
priorities = jira_client.priorities
|
||||
@@ -65,7 +65,7 @@ module Import
|
||||
updated_at:
|
||||
}
|
||||
end
|
||||
Import::JiraPriority.upsert_all(priorities_upsert_data, unique_by: [:jira_id, :jira_priority_id])
|
||||
Import::JiraPriority.upsert_all(priorities_upsert_data, unique_by: %i[jira_id jira_priority_id])
|
||||
|
||||
# STATUSES SYNC
|
||||
statuses = jira_client.statuses
|
||||
@@ -79,7 +79,7 @@ module Import
|
||||
updated_at:
|
||||
}
|
||||
end
|
||||
Import::JiraStatus.upsert_all(statuses_upsert_data, unique_by: [:jira_id, :jira_status_id])
|
||||
Import::JiraStatus.upsert_all(statuses_upsert_data, unique_by: %i[jira_id jira_status_id])
|
||||
|
||||
# PROJECTS SYNC
|
||||
projects_upsert_data = jira_client.projects.map do |p|
|
||||
@@ -92,10 +92,10 @@ module Import
|
||||
updated_at:
|
||||
}
|
||||
end
|
||||
Import::JiraProject.upsert_all(projects_upsert_data, unique_by: [:jira_id, :jira_project_id])
|
||||
Import::JiraProject.upsert_all(projects_upsert_data, unique_by: %i[jira_id jira_project_id])
|
||||
|
||||
# ISSUES SYNC
|
||||
Import::JiraProject.where(jira_id:, jira_project_id: project_ids).each do |jira_project|
|
||||
Import::JiraProject.where(jira_id:, jira_project_id: project_ids).find_each do |jira_project|
|
||||
jql = "project=#{jira_project.payload['key']}"
|
||||
result = jira_client.issues(jql:,
|
||||
start_at: 0,
|
||||
@@ -114,7 +114,7 @@ module Import
|
||||
updated_at:
|
||||
}
|
||||
end
|
||||
Import::JiraIssue.upsert_all(issues_upsert_data, unique_by: [:jira_id, :jira_issue_id])
|
||||
Import::JiraIssue.upsert_all(issues_upsert_data, unique_by: %i[jira_id jira_issue_id])
|
||||
while total > start_at + max_results
|
||||
start_at += max_results
|
||||
result = jira_client.issues(jql:,
|
||||
@@ -134,7 +134,7 @@ module Import
|
||||
updated_at:
|
||||
}
|
||||
end
|
||||
Import::JiraIssue.upsert_all(issues_upsert_data, unique_by: [:jira_id, :jira_issue_id])
|
||||
Import::JiraIssue.upsert_all(issues_upsert_data, unique_by: %i[jira_id jira_issue_id])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -68,7 +68,7 @@ module Import
|
||||
call = Users::CreateService
|
||||
.new(user: User.system)
|
||||
.call(jira_user.to_op_attributes)
|
||||
call.on_success do |result|
|
||||
call.on_success do |_result|
|
||||
create_reference!(
|
||||
op_leg: call.result,
|
||||
jira_leg: jira_user,
|
||||
@@ -76,7 +76,7 @@ module Import
|
||||
uses_existing: false
|
||||
)
|
||||
end
|
||||
call.on_failure do |result|
|
||||
call.on_failure do |_result|
|
||||
if call.errors.find { |error| error.type == :taken }.present?
|
||||
user = jira_user.try_to_find_existing_op_users.first
|
||||
if user.present?
|
||||
@@ -94,9 +94,7 @@ module Import
|
||||
end
|
||||
end
|
||||
|
||||
jira_user_groups = jira_user.payload["groups"]["items"].map do |item|
|
||||
item["name"]
|
||||
end
|
||||
jira_user_groups = jira_user.payload["groups"]["items"].pluck("name")
|
||||
|
||||
jira_user_groups.each do |group_name|
|
||||
call = Groups::CreateService
|
||||
@@ -111,7 +109,7 @@ module Import
|
||||
uses_existing: false
|
||||
)
|
||||
end
|
||||
call.on_failure do |result|
|
||||
call.on_failure do |_result|
|
||||
if call.errors.find { |error| error.type == :taken }.present?
|
||||
group = Group.where(name: group_name).first
|
||||
if group.present?
|
||||
@@ -132,7 +130,7 @@ module Import
|
||||
jira_import_id:,
|
||||
jira_entity_id: jira_user.id,
|
||||
jira_entity_class: jira_user.class.to_s
|
||||
).pluck(:op_entity_id).first
|
||||
).pick(:op_entity_id)
|
||||
group = Group.find_by!(name: group_name)
|
||||
Groups::AddUsersService
|
||||
.new(group, current_user: User.system)
|
||||
|
||||
@@ -46,11 +46,11 @@ module Import
|
||||
|
||||
service_call = Roles::CreateService.new(user:).call(
|
||||
name: "JiraMember",
|
||||
permissions: [:add_work_packages,
|
||||
:view_work_packages,
|
||||
:add_work_package_comments,
|
||||
:add_work_package_attachments,
|
||||
:work_package_assigned]
|
||||
permissions: %i[add_work_packages
|
||||
view_work_packages
|
||||
add_work_package_comments
|
||||
add_work_package_attachments
|
||||
work_package_assigned]
|
||||
)
|
||||
if service_call.success?
|
||||
create_reference!(
|
||||
@@ -64,7 +64,7 @@ module Import
|
||||
end
|
||||
project_role = Role.find_by!(name: "JiraMember")
|
||||
|
||||
Import::JiraProject.where(jira_id:, jira_project_id: project_ids).each do |jira_project|
|
||||
Import::JiraProject.where(jira_id:, jira_project_id: project_ids).find_each do |jira_project|
|
||||
### PROJECT
|
||||
service_call = Projects::CreateService
|
||||
.new(user:)
|
||||
@@ -90,7 +90,7 @@ module Import
|
||||
jira_import:,
|
||||
uses_existing: false
|
||||
)
|
||||
Import::JiraIssue.where(jira_id:, jira_project_id: jira_project.id).each do |jira_issue|
|
||||
Import::JiraIssue.where(jira_id:, jira_project_id: jira_project.id).find_each do |jira_issue|
|
||||
### TYPE
|
||||
issue_type = jira_issue.payload["fields"]["issuetype"]
|
||||
type = Type.where("LOWER(name) = LOWER(?)", issue_type["name"]).first
|
||||
|
||||
@@ -35,13 +35,13 @@ module Import
|
||||
def create_reference!(op_leg:, jira_leg:, jira_import:, uses_existing:)
|
||||
Import::JiraOpenProjectReference.insert_all(
|
||||
[
|
||||
op_entity_id: op_leg.id,
|
||||
op_entity_class: op_leg.class.to_s,
|
||||
jira_entity_id: jira_leg&.id,
|
||||
jira_entity_class: jira_leg&.class&.to_s,
|
||||
jira_import_id: jira_import.id,
|
||||
jira_id: jira_import.jira.id,
|
||||
uses_existing:
|
||||
{ op_entity_id: op_leg.id,
|
||||
op_entity_class: op_leg.class.to_s,
|
||||
jira_entity_id: jira_leg&.id,
|
||||
jira_entity_class: jira_leg&.class&.to_s,
|
||||
jira_import_id: jira_import.id,
|
||||
jira_id: jira_import.jira.id,
|
||||
uses_existing: }
|
||||
],
|
||||
unique_by: %i[op_entity_id op_entity_class]
|
||||
)
|
||||
|
||||
@@ -83,9 +83,9 @@ module Import
|
||||
.where(jira_import_id: @jira_import.id)
|
||||
.where(op_entity_class: "Project")
|
||||
.find_each do |ref|
|
||||
op_leg = ref.op_leg
|
||||
service_call = ::Projects::DeleteService.new(user: @user, model: op_leg).call
|
||||
raise service_call.message if service_call.failure?
|
||||
op_leg = ref.op_leg
|
||||
service_call = ::Projects::DeleteService.new(user: @user, model: op_leg).call
|
||||
raise service_call.message if service_call.failure?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -94,9 +94,9 @@ module Import
|
||||
.where(jira_import_id: @jira_import.id)
|
||||
.where(op_entity_class: ["Type", "IssuePriority", "Status"])
|
||||
.find_each do |ref|
|
||||
op_leg = ref.op_leg
|
||||
uses_existing = ref.uses_existing
|
||||
op_leg.destroy! unless uses_existing
|
||||
op_leg = ref.op_leg
|
||||
uses_existing = ref.uses_existing
|
||||
op_leg.destroy! unless uses_existing
|
||||
end
|
||||
end
|
||||
|
||||
@@ -105,10 +105,10 @@ module Import
|
||||
.where(jira_import_id: @jira_import.id)
|
||||
.where(op_entity_class: "User")
|
||||
.find_each do |ref|
|
||||
op_leg = ref.op_leg
|
||||
# EmptyContract is used to make deletion not dependent on Setting.users_deletable_by_admins
|
||||
service_call = ::Users::DeleteService.new(user: @user, model: op_leg, contract_class: EmptyContract).call
|
||||
raise service_call.message if service_call.failure?
|
||||
op_leg = ref.op_leg
|
||||
# EmptyContract is used to make deletion not dependent on Setting.users_deletable_by_admins
|
||||
service_call = ::Users::DeleteService.new(user: @user, model: op_leg, contract_class: EmptyContract).call
|
||||
raise service_call.message if service_call.failure?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -117,9 +117,9 @@ module Import
|
||||
.where(jira_import_id: @jira_import.id)
|
||||
.where(op_entity_class: "Group")
|
||||
.find_each do |ref|
|
||||
op_leg = ref.op_leg
|
||||
service_call = ::Groups::DeleteService.new(user: @user, model: op_leg).call
|
||||
raise service_call.message if service_call.failure?
|
||||
op_leg = ref.op_leg
|
||||
service_call = ::Groups::DeleteService.new(user: @user, model: op_leg).call
|
||||
raise service_call.message if service_call.failure?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -128,9 +128,9 @@ module Import
|
||||
.where(jira_import_id: @jira_import.id)
|
||||
.where(op_entity_class: "ProjectRole")
|
||||
.find_each do |ref|
|
||||
op_leg = ref.op_leg
|
||||
service_call = ::Roles::DeleteService.new(user: @user, model: op_leg).call
|
||||
raise service_call.message if service_call.failure?
|
||||
op_leg = ref.op_leg
|
||||
service_call = ::Roles::DeleteService.new(user: @user, model: op_leg).call
|
||||
raise service_call.message if service_call.failure?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Possible events related to job-iteration.
|
||||
# https://github.com/Shopify/job-iteration/blob/main/guides/best-practices.md#instrumentation
|
||||
# build_enumerator.iteration
|
||||
@@ -15,6 +17,6 @@ ActiveSupport::Notifications.monotonic_subscribe("each_iteration.iteration") do
|
||||
max_iteration_runtime = 3.minutes
|
||||
if elapsed >= max_iteration_runtime
|
||||
Rails.logger.warn "[Iteration] job_class=#{tags[:job_class]} " \
|
||||
"each_iteration runtime exceeded limit of #{max_iteration_runtime}s"
|
||||
"each_iteration runtime exceeded limit of #{max_iteration_runtime}s"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# config/initializers/statesman.rb
|
||||
Statesman.configure do
|
||||
storage_adapter(Statesman::Adapters::ActiveRecord)
|
||||
|
||||
@@ -30,7 +30,7 @@ class CreateJiraMigrationTables < ActiveRecord::Migration[8.0]
|
||||
t.string :jira_project_id
|
||||
t.references :jira, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.references :jira_import, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.index [:jira_id, :jira_project_id], unique: true
|
||||
t.index %i[jira_id jira_project_id], unique: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
@@ -48,7 +48,7 @@ class CreateJiraMigrationTables < ActiveRecord::Migration[8.0]
|
||||
t.string :jira_issue_id
|
||||
t.references :jira, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.references :jira_import, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.index [:jira_id, :jira_issue_id], unique: true
|
||||
t.index %i[jira_id jira_issue_id], unique: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
@@ -58,7 +58,7 @@ class CreateJiraMigrationTables < ActiveRecord::Migration[8.0]
|
||||
t.string :jira_issue_type_id
|
||||
t.references :jira, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.references :jira_import, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.index [:jira_id, :jira_issue_type_id], unique: true
|
||||
t.index %i[jira_id jira_issue_type_id], unique: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
@@ -68,7 +68,7 @@ class CreateJiraMigrationTables < ActiveRecord::Migration[8.0]
|
||||
t.string :jira_priority_id
|
||||
t.references :jira, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.references :jira_import, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.index [:jira_id, :jira_priority_id], unique: true
|
||||
t.index %i[jira_id jira_priority_id], unique: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
@@ -78,7 +78,7 @@ class CreateJiraMigrationTables < ActiveRecord::Migration[8.0]
|
||||
t.string :jira_status_id
|
||||
t.references :jira, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.references :jira_import, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.index [:jira_id, :jira_status_id], unique: true
|
||||
t.index %i[jira_id jira_status_id], unique: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
@@ -88,7 +88,7 @@ class CreateJiraMigrationTables < ActiveRecord::Migration[8.0]
|
||||
t.string :jira_status_category_id
|
||||
t.references :jira, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.references :jira_import, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.index [:jira_id, :jira_status_category_id], unique: true
|
||||
t.index %i[jira_id jira_status_category_id], unique: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
@@ -98,7 +98,7 @@ class CreateJiraMigrationTables < ActiveRecord::Migration[8.0]
|
||||
t.string :jira_field_id
|
||||
t.references :jira, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.references :jira_import, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.index [:jira_id, :jira_field_id], unique: true
|
||||
t.index %i[jira_id jira_field_id], unique: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
@@ -108,7 +108,7 @@ class CreateJiraMigrationTables < ActiveRecord::Migration[8.0]
|
||||
t.string :jira_user_key
|
||||
t.references :jira, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.references :jira_import, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.index [:jira_id, :jira_user_key], unique: true
|
||||
t.index %i[jira_id jira_user_key], unique: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
@@ -121,7 +121,7 @@ class CreateJiraMigrationTables < ActiveRecord::Migration[8.0]
|
||||
t.boolean :uses_existing
|
||||
t.references :jira, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.references :jira_import, foreign_key: { on_delete: :cascade, on_update: :cascade }
|
||||
t.index [:op_entity_id, :op_entity_class], unique: true
|
||||
t.index %i[op_entity_id op_entity_class], unique: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
@@ -132,7 +132,7 @@ class JiraProjectCreator
|
||||
"This is a duplicate of the %s issue.",
|
||||
"Closing as won't fix. The %s behavior is expected.",
|
||||
"Reopening this - the fix didn't fully address %s.",
|
||||
"Updated the priority based on customer feedback.",
|
||||
"Updated the priority based on customer feedback."
|
||||
].freeze
|
||||
|
||||
PROJECT_CATEGORIES = [
|
||||
@@ -496,15 +496,14 @@ class JiraProjectCreator
|
||||
created_users = create_users(num_users)
|
||||
@users += created_users
|
||||
puts "Created #{created_users.length.to_s.green} users"
|
||||
puts
|
||||
else
|
||||
# Fetch existing users to use for assignments
|
||||
puts "Fetching existing users...".cyan
|
||||
existing_users = @dry_run ? sample_users : fetch_users
|
||||
@users += existing_users
|
||||
puts "Found #{existing_users.length.to_s.green} existing users"
|
||||
puts
|
||||
end
|
||||
puts
|
||||
|
||||
# Fetch available statuses
|
||||
statuses = @dry_run ? sample_statuses : fetch_statuses
|
||||
@@ -626,7 +625,8 @@ class JiraProjectCreator
|
||||
begin
|
||||
result = post("/rest/api/2/user", payload)
|
||||
# Store password for later use with basic auth (for comments)
|
||||
{ "name" => result["name"], "displayName" => result["displayName"], "emailAddress" => result["emailAddress"], "password" => password }
|
||||
{ "name" => result["name"], "displayName" => result["displayName"], "emailAddress" => result["emailAddress"],
|
||||
"password" => password }
|
||||
rescue StandardError => e
|
||||
puts "⚠ Warning:".yellow + " Could not create user #{username}: #{e.message}"
|
||||
nil
|
||||
@@ -666,9 +666,12 @@ class JiraProjectCreator
|
||||
|
||||
def sample_users
|
||||
[
|
||||
{ "name" => "john.smith", "displayName" => "John Smith", "emailAddress" => "john.smith@example.com", "password" => "password123" },
|
||||
{ "name" => "jane.doe", "displayName" => "Jane Doe", "emailAddress" => "jane.doe@example.com", "password" => "password123" },
|
||||
{ "name" => "bob.wilson", "displayName" => "Bob Wilson", "emailAddress" => "bob.wilson@example.com", "password" => "password123" }
|
||||
{ "name" => "john.smith", "displayName" => "John Smith", "emailAddress" => "john.smith@example.com",
|
||||
"password" => "password123" },
|
||||
{ "name" => "jane.doe", "displayName" => "Jane Doe", "emailAddress" => "jane.doe@example.com",
|
||||
"password" => "password123" },
|
||||
{ "name" => "bob.wilson", "displayName" => "Bob Wilson", "emailAddress" => "bob.wilson@example.com",
|
||||
"password" => "password123" }
|
||||
]
|
||||
end
|
||||
|
||||
|
||||
@@ -492,8 +492,9 @@ RSpec.describe Admin::Import::Jira::InstancesController do
|
||||
|
||||
it "uses the stored token when personal_access_token param is blank" do
|
||||
post :test, params: { id: jira_with_token.id, url: "https://jira.example.com", personal_access_token: "" },
|
||||
format: :turbo_stream
|
||||
expect(Import::JiraClient).to have_received(:new).with(url: "https://jira.example.com", personal_access_token: "stored_token")
|
||||
format: :turbo_stream
|
||||
expect(Import::JiraClient).to have_received(:new).with(url: "https://jira.example.com",
|
||||
personal_access_token: "stored_token")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -70,16 +70,16 @@ require "paper_trail/frameworks/rspec"
|
||||
require_relative "support/parallel_helper"
|
||||
require_relative "support/download_list"
|
||||
require_relative "support/capybara"
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require_relative f }
|
||||
Dir[Rails.root.join("spec/features/support/**/*.rb")].sort.each { |f| require f }
|
||||
Dir[Rails.root.join("spec/lib/api/v3/support/**/*.rb")].sort.each { |f| require f }
|
||||
Dir[Rails.root.join("spec/requests/api/v3/support/**/*.rb")].sort.each { |f| require f }
|
||||
Rails.root.glob("spec/support/**/*.rb").each { |f| require_relative f }
|
||||
Rails.root.glob("spec/features/support/**/*.rb").each { |f| require f }
|
||||
Rails.root.glob("spec/lib/api/v3/support/**/*.rb").each { |f| require f }
|
||||
Rails.root.glob("spec/requests/api/v3/support/**/*.rb").each { |f| require f }
|
||||
|
||||
# Checks for pending migration and applies them before tests are run.
|
||||
# If you are not using ActiveRecord, you can remove this line.
|
||||
ActiveRecord::Migration.maintain_test_schema! unless ENV["CI"]
|
||||
|
||||
ActiveRecord::Base.logger = ActiveSupport::Logger.new(STDOUT, level: :debug) if ENV["SQL_DEBUG_OUTPUT"]
|
||||
ActiveRecord::Base.logger = ActiveSupport::Logger.new($stdout, level: :debug) if ENV["SQL_DEBUG_OUTPUT"]
|
||||
|
||||
RSpec.configure do |config|
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
|
||||
@@ -466,9 +466,9 @@ RSpec.describe Import::JiraWikiMarkupConverter do
|
||||
end
|
||||
let(:output) do
|
||||
"panel text\n" \
|
||||
"panel text\n" \
|
||||
"panel text\n" \
|
||||
"panel text"
|
||||
"panel text\n" \
|
||||
"panel text\n" \
|
||||
"panel text"
|
||||
end
|
||||
|
||||
it "does produce all code blocks" do
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user