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

make rubocop happier

Christophe Bliarda16d1cda9a19
diff --git a/modules/storages/app/cells/storages/projects_storages_table_cell.rb b/modules/storages/app/cells/storages/projects_storages_table_cell.rb
index cd7ee97a76c..197037cd234 100644
--- a/modules/storages/app/cells/storages/projects_storages_table_cell.rb
+++ b/modules/storages/app/cells/storages/projects_storages_table_cell.rb
@@ -38,6 +38,5 @@ module Storages
['created_at', { caption: Storages::ProjectStorage.human_attribute_name(:created_at) }]
]
end
-
end
end
diff --git a/modules/storages/app/cells/storages/storages_row_cell.rb b/modules/storages/app/cells/storages/storages_row_cell.rb
index 515edc2e905..4a8188273ed 100644
--- a/modules/storages/app/cells/storages/storages_row_cell.rb
+++ b/modules/storages/app/cells/storages/storages_row_cell.rb
@@ -8,13 +8,8 @@ module Storages
link_to model.name, storage_path(model)
end
- def host
- model.host
- end
-
- def provider_type
- model.provider_type
- end
+ delegate :host, to: :model
+ delegate :provider_type, to: :model
def creator
icon = avatar model.creator, size: :mini
diff --git a/modules/storages/app/controllers/storages/admin/projects_storages_controller.rb b/modules/storages/app/controllers/storages/admin/projects_storages_controller.rb
index c148ecc4c3b..566252ba555 100644
--- a/modules/storages/app/controllers/storages/admin/projects_storages_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/projects_storages_controller.rb
@@ -61,7 +61,7 @@ class Storages::Admin::ProjectsStoragesController < Projects::SettingsController
end
def destroy
- Storages::FileLink.joins(:container).where("work_packages.project_id = ?", @project.id).delete_all
+ Storages::FileLink.joins(:container).where(work_packages: { project_id: @project.id }).delete_all
@object.destroy
redirect_to project_settings_projects_storages_path
diff --git a/modules/storages/app/models/storages/file_link.rb b/modules/storages/app/models/storages/file_link.rb
index cba5820f24f..305a8b36d0f 100644
--- a/modules/storages/app/models/storages/file_link.rb
+++ b/modules/storages/app/models/storages/file_link.rb
@@ -28,8 +28,8 @@
class Storages::FileLink < ApplicationRecord
belongs_to :storage
- belongs_to :creator, foreign_key: 'creator_id', class_name: 'User'
- belongs_to :container, foreign_key: 'container_id', class_name: 'WorkPackage' # This needs to become more flexible in the future
+ belongs_to :creator, class_name: 'User'
+ belongs_to :container, class_name: 'WorkPackage' # This needs to become more flexible in the future
scope :visible, ->(user = User.current) {
includes(:container)
diff --git a/modules/storages/spec/features/admin_storages_spec.rb b/modules/storages/spec/features/admin_storages_spec.rb
index 05afd2e65ba..e579b9b528e 100644
--- a/modules/storages/spec/features/admin_storages_spec.rb
+++ b/modules/storages/spec/features/admin_storages_spec.rb
@@ -95,6 +95,6 @@ describe 'Admin storages', type: :feature, js: true do
page.driver.browser.switch_to.alert.accept
expect(page).to have_current_path(storages_path)
- expect(page).to_not have_text("Other NC")
+ expect(page).not_to have_text("Other NC")
end
end
diff --git a/modules/storages/spec/models/storage_spec.rb b/modules/storages/spec/models/storage_spec.rb
index 5e437eba0ba..60be43572fb 100644
--- a/modules/storages/spec/models/storage_spec.rb
+++ b/modules/storages/spec/models/storage_spec.rb
@@ -43,34 +43,34 @@ describe ::Storages::Storage, type: :model do
expect(storage).to be_valid
end
- it "should fail the validation if name is empty string" do
+ it "fails the validation if name is empty string" do
expect(described_class.create(test_default_attributes.merge({ name: "" }))).to be_invalid
end
- it "should fail the validation if name is nil" do
+ it "fails the validation if name is nil" do
expect(described_class.create(test_default_attributes.merge({ name: nil }))).to be_invalid
end
- it "should fail the validation if host is empty string" do
+ it "fails the validation if host is empty string" do
expect(described_class.create(test_default_attributes.merge({ host: '' }))).to be_invalid
end
- it "should fail the validation if host is nil" do
+ it "fails the validation if host is nil" do
expect(described_class.create(test_default_attributes.merge({ host: nil }))).to be_invalid
end
- context "having already one instance" do
+ context "when having already one instance" do
let(:old_storage) { described_class.create test_default_attributes }
before do
old_storage
end
- it "should fail the validation if name is not unique" do
+ it "fails the validation if name is not unique" do
expect(described_class.create(test_default_attributes.merge({ host: 'https://example2.com' }))).to be_invalid
end
- it "should fail the validation if host is not unique" do
+ it "fails the validation if host is not unique" do
expect(described_class.create(test_default_attributes.merge({ name: 'NC 2' }))).to be_invalid
end
end
@@ -87,7 +87,7 @@ describe ::Storages::Storage, type: :model do
storage.destroy
end
- it "should destroy all associated ProjectStorage and FileLink records" do
+ it "destroys all associated ProjectStorage and FileLink records" do
expect(Storages::ProjectStorage.count).to be 0
expect(Storages::FileLink.count).to be 0
end