Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

fix[Op-51021]: drive id message should include `ID`

Kabiru Mwenja6a1aff1e3330
diff --git a/modules/storages/app/contracts/storages/storages/one_drive_contract.rb b/modules/storages/app/contracts/storages/storages/one_drive_contract.rb
index f83fccf6307..1985a7d37fe 100644
--- a/modules/storages/app/contracts/storages/storages/one_drive_contract.rb
+++ b/modules/storages/app/contracts/storages/storages/one_drive_contract.rb
@@ -33,7 +33,7 @@ module Storages::Storages
attribute :host
validates :host, absence: true
attribute :tenant_id
- validates :tenant_id, format: { with: /\A(?:[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}|consumers)\z/i }
+ validates :tenant_id, presence: true
attribute :drive_id
validates :drive_id, presence: true, allow_nil: true
end
diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.yml
index 320bc99c953..9da518b1e4a 100644
--- a/modules/storages/config/locales/en.yml
+++ b/modules/storages/config/locales/en.yml
@@ -6,6 +6,7 @@ en:
origin_id: Origin Id
storages/storage:
creator: Creator
+ drive: Drive ID
host: Host
name: Name
provider_type: Provider type
diff --git a/modules/storages/spec/contracts/storages/storages/one_drive_contract_spec.rb b/modules/storages/spec/contracts/storages/storages/one_drive_contract_spec.rb
index befc0362011..6b8c7cc38cb 100644
--- a/modules/storages/spec/contracts/storages/storages/one_drive_contract_spec.rb
+++ b/modules/storages/spec/contracts/storages/storages/one_drive_contract_spec.rb
@@ -31,13 +31,13 @@
require 'spec_helper'
require_module_spec_helper
-RSpec.describe Storages::Storages::NextcloudContract, :storage_server_helpers, :webmock do
+RSpec.describe Storages::Storages::OneDriveContract, :storage_server_helpers, :webmock do
let(:current_user) { create(:admin) }
let(:storage) { build(:one_drive_storage) }
# As the OneDriveContract is selected by the BaseContract to make writable attributes available,
# the BaseContract needs to be instantiated here.
- subject { Storages::Storages::BaseContract.new(storage, current_user) }
+ subject(:contract) { Storages::Storages::BaseContract.new(storage, current_user) }
describe 'when a host is set' do
before do
@@ -45,7 +45,17 @@ RSpec.describe Storages::Storages::NextcloudContract, :storage_server_helpers, :
end
it 'must be invalid' do
- expect(subject).not_to be_valid
+ expect(contract).not_to be_valid
+ end
+ end
+
+ context 'with blank Drive ID' do
+ let(:storage) { build(:one_drive_storage, drive_id: '') }
+
+ it 'is invalid' do
+ expect(contract).not_to be_valid
+
+ expect(contract.errors[:drive_id]).to eq(["can't be blank."])
end
end
end
diff --git a/modules/storages/spec/features/admin_storages_spec.rb b/modules/storages/spec/features/admin_storages_spec.rb
index 4fd4776462e..76c2c5ac95e 100644
--- a/modules/storages/spec/features/admin_storages_spec.rb
+++ b/modules/storages/spec/features/admin_storages_spec.rb
@@ -315,7 +315,7 @@ RSpec.describe 'Admin storages',
fill_in 'storages_one_drive_storage_tenant_id', with: '029d4741-a4be-44c6-a8e4-e4eff7b19f65'
click_button 'Save and continue'
- expect(page).to have_text("Drive can't be blank.")
+ expect(page).to have_text("Drive ID can't be blank.")
fill_in 'storages_one_drive_storage_drive_id', with: '1234567890'
click_button 'Save and continue'
@@ -606,7 +606,7 @@ RSpec.describe 'Admin storages',
click_button 'Save and continue'
expect(page).to have_text("Name can't be blank.")
- expect(page).to have_text("Drive can't be blank.")
+ expect(page).to have_text("Drive ID can't be blank.")
click_link 'Cancel'
end