Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def switch_to_classic
.call(work_packages_identifier: Setting::WorkPackageIdentifier::CLASSIC)
call.on_success do
unless ProjectIdentifiers::IdentifierAutofix.job_in_progress?
ProjectIdentifiers::RevertInstanceToClassicIdsJob.perform_later
ProjectIdentifiers::ConvertInstanceToClassicIdsJob.perform_later
end
redirect_to action: "show"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module ProjectIdentifiers
# WP sequence_number/identifier, WorkPackageSemanticAlias rows, and
# wp_sequence_counter are intentionally left intact so that a back-switch to
# semantic mode can resume without data loss.
class RevertProjectToClassicService
class ConvertProjectToClassicService
def initialize(project)
@project = project
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/project_identifiers/identifier_autofix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module IdentifierAutofix
].freeze

REVERSION_JOB_CLASSES = [
ProjectIdentifiers::RevertInstanceToClassicIdsJob.name
ProjectIdentifiers::ConvertInstanceToClassicIdsJob.name
].freeze

def self.job_in_progress?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#
# The global Setting.work_packages_identifier is expected to already be "classic"
# before this job runs — it is set by the controller before enqueueing.
class ProjectIdentifiers::RevertInstanceToClassicIdsJob < ApplicationJob
class ProjectIdentifiers::ConvertInstanceToClassicIdsJob < ApplicationJob
include GoodJob::ActiveJobExtensions::Concurrency

good_job_control_concurrency_with(total_limit: 1)
Expand All @@ -46,7 +46,7 @@ def perform
Project.find_each do |project|
next if Project.classic_identifier_format?(project.identifier)

ProjectIdentifiers::RevertProjectToClassicService.new(project).call
ProjectIdentifiers::ConvertProjectToClassicService.new(project).call
end
end
end
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ en:
success_banner: Successfully updated work package identifier format.
in_progress:
converting_banner_message: Project identifiers are currently being converted to semantic format. This may take some time.
reverting_banner_message: Project identifiers are currently being reverted to classic format. This may take some time.
reverting_banner_message: Project identifiers are currently being converted to classic format. This may take some time.
workflows:
tabs:
default_transitions: "Default transitions"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@
end

context "when work_packages_identifier is 'classic'" do
it "updates the setting to classic, enqueues RevertInstanceToClassicIdsJob, and redirects" do
it "updates the setting to classic, enqueues ConvertInstanceToClassicIdsJob, and redirects" do
expect do
patch :update, params: { settings: { work_packages_identifier: "classic" } }
end.to have_enqueued_job(ProjectIdentifiers::RevertInstanceToClassicIdsJob)
end.to have_enqueued_job(ProjectIdentifiers::ConvertInstanceToClassicIdsJob)

expect(Setting.work_packages_identifier).to eq("classic")
expect(response).to redirect_to(action: "show")
Expand All @@ -79,7 +79,7 @@
it "does not enqueue another job but still updates the setting and redirects" do
expect do
patch :update, params: { settings: { work_packages_identifier: "classic" } }
end.not_to have_enqueued_job(ProjectIdentifiers::RevertInstanceToClassicIdsJob)
end.not_to have_enqueued_job(ProjectIdentifiers::ConvertInstanceToClassicIdsJob)

expect(Setting.work_packages_identifier).to eq("classic")
expect(response).to redirect_to(action: "show")
Expand All @@ -93,7 +93,7 @@

expect(response).to have_http_status(:bad_request)
expect(ProjectIdentifiers::ConvertInstanceToSemanticIdsJob).not_to have_been_enqueued
expect(ProjectIdentifiers::RevertInstanceToClassicIdsJob).not_to have_been_enqueued
expect(ProjectIdentifiers::ConvertInstanceToClassicIdsJob).not_to have_been_enqueued
end
end

Expand All @@ -103,7 +103,7 @@

expect(response).to have_http_status(:bad_request)
expect(ProjectIdentifiers::ConvertInstanceToSemanticIdsJob).not_to have_been_enqueued
expect(ProjectIdentifiers::RevertInstanceToClassicIdsJob).not_to have_been_enqueued
expect(ProjectIdentifiers::ConvertInstanceToClassicIdsJob).not_to have_been_enqueued
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

require "rails_helper"

RSpec.describe ProjectIdentifiers::RevertProjectToClassicService do
RSpec.describe ProjectIdentifiers::ConvertProjectToClassicService do
describe "#call" do
context "when the project has a classic identifier in FriendlyId history" do
let!(:project) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

require "rails_helper"

RSpec.describe ProjectIdentifiers::RevertInstanceToClassicIdsJob do
RSpec.describe ProjectIdentifiers::ConvertInstanceToClassicIdsJob do
describe "#perform" do
context "when the setting is not classic" do
before { allow(Setting::WorkPackageIdentifier).to receive(:classic?).and_return(false) }
Expand All @@ -51,10 +51,10 @@
end
end

it "calls RevertProjectToClassicService for each project" do
it "calls ConvertProjectToClassicService for each project" do
services = projects.map do |project|
instance_double(ProjectIdentifiers::RevertProjectToClassicService, call: nil).tap do |service|
allow(ProjectIdentifiers::RevertProjectToClassicService).to receive(:new).with(project).and_return(service)
instance_double(ProjectIdentifiers::ConvertProjectToClassicService, call: nil).tap do |service|
allow(ProjectIdentifiers::ConvertProjectToClassicService).to receive(:new).with(project).and_return(service)
end
end

Expand All @@ -67,18 +67,18 @@
context "when a project already has a classic identifier" do
let!(:project) { create(:project) }

it "skips it and does not call RevertProjectToClassicService" do
allow(ProjectIdentifiers::RevertProjectToClassicService).to receive(:new)
it "skips it and does not call ConvertProjectToClassicService" do
allow(ProjectIdentifiers::ConvertProjectToClassicService).to receive(:new)
described_class.new.perform
expect(ProjectIdentifiers::RevertProjectToClassicService).not_to have_received(:new)
expect(ProjectIdentifiers::ConvertProjectToClassicService).not_to have_received(:new)
end
end

context "when there are no projects" do
it "does not call RevertProjectToClassicService" do
allow(ProjectIdentifiers::RevertProjectToClassicService).to receive(:new)
it "does not call ConvertProjectToClassicService" do
allow(ProjectIdentifiers::ConvertProjectToClassicService).to receive(:new)
described_class.new.perform
expect(ProjectIdentifiers::RevertProjectToClassicService).not_to have_received(:new)
expect(ProjectIdentifiers::ConvertProjectToClassicService).not_to have_received(:new)
end
end

Expand Down
Loading