diff --git a/app/controllers/my_module_repositories_controller.rb b/app/controllers/my_module_repositories_controller.rb index b41711d39..9a4bd5455 100644 --- a/app/controllers/my_module_repositories_controller.rb +++ b/app/controllers/my_module_repositories_controller.rb @@ -115,7 +115,7 @@ class MyModuleRepositoriesController < ApplicationController end def load_repository - @repository = Repository.find_by(id: params[:id]) + @repository = Repository.with_archived.find_by(id: params[:id]) render_404 unless @repository end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index b4278bea2..277e06d9f 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -351,11 +351,7 @@ class RepositoriesController < ApplicationController def load_repositories @repositories = Repository.accessible_by_teams(current_team).order('repositories.created_at ASC') - @repositories = if params[:archived] - @repositories.archived - else - @repositories - end + @repositories = @repositories.archived if params[:archived] end def set_inline_name_editing diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb index b0c1dea55..910341f0c 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -123,7 +123,7 @@ module ReportsHelper end def assign_repository_or_snapshot(my_module, element_id, snapshot, repository) - original_repository = Repository.find_by(id: element_id) if element_id + original_repository = Repository.with_archived.find_by(id: element_id) if element_id repository ||= snapshot repository || my_module.active_snapshot_or_live(original_repository) || original_repository end diff --git a/app/models/repository_snapshot.rb b/app/models/repository_snapshot.rb index d7383a557..6197c1d6f 100644 --- a/app/models/repository_snapshot.rb +++ b/app/models/repository_snapshot.rb @@ -5,10 +5,12 @@ class RepositorySnapshot < RepositoryBase after_save :refresh_report_references, if: :saved_change_to_selected before_destroy :refresh_report_references_for_destroy, prepend: true - belongs_to :original_repository, foreign_key: :parent_id, - class_name: 'Repository', - inverse_of: :repository_snapshots, - optional: true + belongs_to :original_repository, -> { unscope(where: :archived) }, + foreign_key: :parent_id, + class_name: 'Repository', + inverse_of: :repository_snapshots, + optional: true + belongs_to :my_module, optional: true validates :name, presence: true, length: { maximum: Constants::NAME_MAX_LENGTH } diff --git a/app/views/reports/new/modal/_module_contents_inner.html.erb b/app/views/reports/new/modal/_module_contents_inner.html.erb index d131d7783..9e5e836b8 100644 --- a/app/views/reports/new/modal/_module_contents_inner.html.erb +++ b/app/views/reports/new/modal/_module_contents_inner.html.erb @@ -69,7 +69,7 @@ <%= form.check_box :module_activity, label: t("projects.reports.elements.modals.module_contents_inner.activity") %> <% # List all repositories, no matter whether rows are assigned or not %> - <% Repository.accessible_by_teams(@project.team).order(created_at: :asc).select(:id, :name).find_each do |repository| %> + <% Repository.accessible_by_teams(@project.team).with_archived.order(created_at: :asc).select(:id, :name).find_each do |repository| %>
  • <%= form.check_box "module_repository_#{repository.id}", label: repository.name.capitalize, data: { id: repository.id } %>