make rubocop happier

pull/10133/head
Christophe Bliard 3 years ago
parent b5ce5bf737
commit a16d1cda9a
No known key found for this signature in database
GPG Key ID: 2BC07603210C3FA4
  1. 1
      modules/storages/app/cells/storages/projects_storages_table_cell.rb
  2. 9
      modules/storages/app/cells/storages/storages_row_cell.rb
  3. 2
      modules/storages/app/controllers/storages/admin/projects_storages_controller.rb
  4. 4
      modules/storages/app/models/storages/file_link.rb
  5. 2
      modules/storages/spec/features/admin_storages_spec.rb
  6. 16
      modules/storages/spec/models/storage_spec.rb

@ -38,6 +38,5 @@ module Storages
['created_at', { caption: Storages::ProjectStorage.human_attribute_name(:created_at) }] ['created_at', { caption: Storages::ProjectStorage.human_attribute_name(:created_at) }]
] ]
end end
end end
end end

@ -8,13 +8,8 @@ module Storages
link_to model.name, storage_path(model) link_to model.name, storage_path(model)
end end
def host delegate :host, to: :model
model.host delegate :provider_type, to: :model
end
def provider_type
model.provider_type
end
def creator def creator
icon = avatar model.creator, size: :mini icon = avatar model.creator, size: :mini

@ -61,7 +61,7 @@ class Storages::Admin::ProjectsStoragesController < Projects::SettingsController
end end
def destroy 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 @object.destroy
redirect_to project_settings_projects_storages_path redirect_to project_settings_projects_storages_path

@ -28,8 +28,8 @@
class Storages::FileLink < ApplicationRecord class Storages::FileLink < ApplicationRecord
belongs_to :storage belongs_to :storage
belongs_to :creator, foreign_key: 'creator_id', class_name: 'User' belongs_to :creator, class_name: 'User'
belongs_to :container, foreign_key: 'container_id', class_name: 'WorkPackage' # This needs to become more flexible in the future belongs_to :container, class_name: 'WorkPackage' # This needs to become more flexible in the future
scope :visible, ->(user = User.current) { scope :visible, ->(user = User.current) {
includes(:container) includes(:container)

@ -95,6 +95,6 @@ describe 'Admin storages', type: :feature, js: true do
page.driver.browser.switch_to.alert.accept page.driver.browser.switch_to.alert.accept
expect(page).to have_current_path(storages_path) 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
end end

@ -43,34 +43,34 @@ describe ::Storages::Storage, type: :model do
expect(storage).to be_valid expect(storage).to be_valid
end 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 expect(described_class.create(test_default_attributes.merge({ name: "" }))).to be_invalid
end 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 expect(described_class.create(test_default_attributes.merge({ name: nil }))).to be_invalid
end 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 expect(described_class.create(test_default_attributes.merge({ host: '' }))).to be_invalid
end 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 expect(described_class.create(test_default_attributes.merge({ host: nil }))).to be_invalid
end end
context "having already one instance" do context "when having already one instance" do
let(:old_storage) { described_class.create test_default_attributes } let(:old_storage) { described_class.create test_default_attributes }
before do before do
old_storage old_storage
end 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 expect(described_class.create(test_default_attributes.merge({ host: 'https://example2.com' }))).to be_invalid
end 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 expect(described_class.create(test_default_attributes.merge({ name: 'NC 2' }))).to be_invalid
end end
end end
@ -87,7 +87,7 @@ describe ::Storages::Storage, type: :model do
storage.destroy storage.destroy
end 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::ProjectStorage.count).to be 0
expect(Storages::FileLink.count).to be 0 expect(Storages::FileLink.count).to be 0
end end

Loading…
Cancel
Save