diff --git a/app/models/frame.rb b/app/models/frame.rb index 5d6c6cd07..c19fa50f0 100644 --- a/app/models/frame.rb +++ b/app/models/frame.rb @@ -11,13 +11,12 @@ class Frame < ApplicationRecord # rubocop:disable Metrics/ClassLength belongs_to :bay - has_one :islet, through: :bay - has_one :room, through: :islet - has_many :materials, -> { order("servers.position desc") }, class_name: "Server", dependent: :restrict_with_error has_many :pdus, -> { only_pdus }, class_name: "Server", dependent: :restrict_with_error has_many :servers, -> { no_pdus.order("servers.position desc") }, class_name: "Server", dependent: :restrict_with_error + has_one :islet, through: :bay + has_one :room, through: :islet delegate :name, to: :room, prefix: true, allow_nil: true validates :position, uniqueness: { scope: :bay_id } diff --git a/app/models/permission_scope_domain.rb b/app/models/permission_scope_domain.rb index 2063d9d18..8b01e7518 100644 --- a/app/models/permission_scope_domain.rb +++ b/app/models/permission_scope_domain.rb @@ -3,4 +3,6 @@ class PermissionScopeDomain < ApplicationRecord belongs_to :permission_scope belongs_to :domaine + + delegate :to_s, to: :permission_scope end diff --git a/app/models/server.rb b/app/models/server.rb index fffec8ead..60971d5f6 100644 --- a/app/models/server.rb +++ b/app/models/server.rb @@ -8,11 +8,11 @@ class Server < ApplicationRecord # rubocop:disable Metrics/ClassLength has_changelog belongs_to :frame - belongs_to :modele, counter_cache: true belongs_to :gestion, optional: true, counter_cache: true belongs_to :domaine, optional: true, counter_cache: true belongs_to :cluster, optional: true, counter_cache: true belongs_to :stack, optional: true, counter_cache: true + belongs_to :modele, counter_cache: true has_one :bay, through: :frame has_one :islet, through: :frame @@ -27,6 +27,7 @@ class Server < ApplicationRecord # rubocop:disable Metrics/ClassLength has_many :cables, through: :connections has_many :moves, as: :moveable, dependent: :destroy has_many :documents, dependent: :restrict_with_error + # TODO: should be plural has_many :external_app_record, dependent: :destroy has_one_attached :photo diff --git a/app/views/rooms/destroy.html.erb b/app/views/rooms/destroy.html.erb index 349b907a0..9d119945b 100644 --- a/app/views/rooms/destroy.html.erb +++ b/app/views/rooms/destroy.html.erb @@ -8,8 +8,8 @@
<%= render DeleteDependencyComponent.new( - @room, - except: %i[cluster_rooms], - confirmation_path: room_path(@room, confirm: true), - ) %> + @room, + except: %i[cluster_rooms], + confirmation_path: room_path(@room, confirm: true) + ) %>
diff --git a/config/locales/activerecord.en.yml b/config/locales/activerecord.en.yml index 5bef4f495..afa992af4 100644 --- a/config/locales/activerecord.en.yml +++ b/config/locales/activerecord.en.yml @@ -38,6 +38,7 @@ en: stack: Stack user: User permission_scope: Permission Scope + permission_scope_domain: Permission Scope attributes: bay: diff --git a/config/locales/activerecord.fr.yml b/config/locales/activerecord.fr.yml index b5ee0a6c4..bf7758bb0 100644 --- a/config/locales/activerecord.fr.yml +++ b/config/locales/activerecord.fr.yml @@ -54,6 +54,7 @@ fr: contact_role: RĂ´le contact_assignment: Assignation permission_scope: Permission + permission_scope_domain: Permission attributes: room: diff --git a/spec/models/server_spec.rb b/spec/models/server_spec.rb index c3be4736c..2b67594ec 100644 --- a/spec/models/server_spec.rb +++ b/spec/models/server_spec.rb @@ -13,9 +13,9 @@ it { is_expected.to belong_to(:frame) } it { is_expected.to belong_to(:gestion).optional(true) } it { is_expected.to belong_to(:domaine).optional(true) } - it { is_expected.to belong_to(:modele) } it { is_expected.to belong_to(:cluster).optional(true) } it { is_expected.to belong_to(:stack).optional(true) } + it { is_expected.to belong_to(:modele) } it { is_expected.to have_one(:bay).through(:frame) } it { is_expected.to have_one(:islet).through(:frame) } @@ -30,6 +30,7 @@ it { is_expected.to have_many(:cables).through(:connections) } it { is_expected.to have_many(:moves).dependent(:destroy) } it { is_expected.to have_many(:documents) } + it { is_expected.to have_many(:external_app_record) } end describe "attachement" do