• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / tigerdata-app / 740457a7-d6b1-4658-852f-0f55ab03d22e

18 Dec 2025 09:41PM UTC coverage: 78.723% (-9.3%) from 87.984%
740457a7-d6b1-4658-852f-0f55ab03d22e

Pull #2330

circleci

kelynch
Added parent folder error check
Pull Request #2330: Error message enhancements in the wizard

7 of 14 new or added lines in 1 file covered. (50.0%)

560 existing lines in 34 files now uncovered.

2638 of 3351 relevant lines covered (78.72%)

361.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.17
/app/controllers/projects_controller.rb
1
# frozen_string_literal: true
UNCOV
2
class ProjectsController < ApplicationController
2✔
3

UNCOV
4
  before_action :set_breadcrumbs
2✔
UNCOV
5
  before_action :authenticate_user!
2✔
6

UNCOV
7
  def details
2✔
8
    return if project.blank?
5✔
9

10
    add_breadcrumb(@presenter.title, project_path)
4✔
11
    add_breadcrumb("Details")
4✔
12

13
    project_metadata = @project.metadata
4✔
14
    storage_capacity = project_metadata[:storage_capacity]
4✔
15
    size = storage_capacity[:size]
4✔
16
    unit = storage_capacity[:unit]
4✔
17

18
    @requested_size = size[:requested]
4✔
19
    @requested_unit = unit[:requested]
4✔
20

21
    @approved_size = size[:approved]
4✔
22
    @approved_unit = unit[:approved]
4✔
23

24
    @project_session = "details"
4✔
25

26
    respond_to do |format|
4✔
27
      format.html do
4✔
28
        render
1✔
UNCOV
29
      end
30
      format.json do
4✔
31
        render json: project.to_json
2✔
UNCOV
32
      end
33
      format.xml do
4✔
34
        render xml: @presenter.to_xml
1✔
UNCOV
35
      end
UNCOV
36
    end
UNCOV
37
  end
38

UNCOV
39
  def index
2✔
40
    if current_user.eligible_sysadmin?
4✔
41
      search_projects
3✔
UNCOV
42
    else
43
      flash[:alert] = I18n.t(:access_denied)
1✔
44
      redirect_to dashboard_path
1✔
UNCOV
45
    end
UNCOV
46
  end
47

UNCOV
48
  def show
2✔
UNCOV
49
    return if project.blank?
9✔
50

UNCOV
51
    add_breadcrumb(@presenter.title, project_path)
4✔
UNCOV
52
    add_breadcrumb("Contents")
4✔
53

UNCOV
54
    @latest_completed_download = current_user.user_requests.where(project_id: @project.id, state: "completed").order(:completion_time).last
4✔
UNCOV
55
    @storage_usage = project.storage_usage(session_id: current_user.mediaflux_session)
4✔
UNCOV
56
    @storage_capacity = project.storage_capacity(session_id: current_user.mediaflux_session)
4✔
57

UNCOV
58
    @num_files = project.asset_count(session_id: current_user.mediaflux_session)
4✔
59

UNCOV
60
    @file_list = project.file_list(session_id: current_user.mediaflux_session, size: 100)
4✔
UNCOV
61
    @files = @file_list[:files]
4✔
UNCOV
62
    @files.sort_by!(&:path)
4✔
63

UNCOV
64
    @project_session = "content"
4✔
UNCOV
65
    respond_to do |format|
4✔
UNCOV
66
      format.html { render }
6✔
UNCOV
67
      format.xml { render xml: ProjectShowPresenter.new(project, current_user).to_xml
6✔
UNCOV
68
    }
UNCOV
69
    end
UNCOV
70
  end
71

72
  # GET "projects/:id/:id-mf"
73
  #
74
  # This action is used to render the mediaflux metadata for a project.
UNCOV
75
  def show_mediaflux
2✔
UNCOV
76
    project_id = params[:id]
4✔
UNCOV
77
    project = Project.find(project_id)
4✔
UNCOV
78
    respond_to do |format|
3✔
UNCOV
79
      format.xml do
3✔
UNCOV
80
        render xml: project.mediaflux_meta_xml(user: current_user)
3✔
UNCOV
81
      end
UNCOV
82
    end
UNCOV
83
  rescue => ex
UNCOV
84
    Rails.logger.error "Error getting MediaFlux XML for project #{project_id}, user #{current_user.uid}: #{ex.message}"
1✔
UNCOV
85
    flash[:alert] = "Error fetching Mediaflux XML for this project"
1✔
UNCOV
86
    redirect_to project_path(project_id)
1✔
UNCOV
87
  end
88

UNCOV
89
  def list_contents
2✔
90
    return if project.blank?
2✔
91

92
    project_job_service.list_contents_job(user: current_user)
1✔
93

UNCOV
94
    json_response = {
95
      message: "File list for \"#{project.title}\" is being generated in the background. A link to the downloadable file list will be available in the \"Recent Activity\" section of your dashboard when it is available. You may safely navigate away from this page or close this tab."
1✔
UNCOV
96
    }
97
    render json: json_response
1✔
UNCOV
98
  rescue => ex
99
    message = "Error producing document list (project id: #{project&.id}): #{ex.message}"
×
100
    Rails.logger.error(message)
×
101
    Honeybadger.notify(message)
×
102
    render json: { message: "Document list could not be generated." }
×
UNCOV
103
  end
104

UNCOV
105
  def file_list_download
2✔
106
    job_id = params[:job_id]
×
107
    user_request = FileInventoryRequest.where(job_id:job_id).first
×
108
    if user_request.nil?
×
109
      # TODO: handle error
110
      redirect_to "/"
×
UNCOV
111
    else
112
      filename = user_request.output_file
×
113
      send_data File.read(filename), type: "text/plain", filename: "filelist.csv", disposition: "attachment"
×
UNCOV
114
    end
UNCOV
115
  end
116

UNCOV
117
  private
2✔
118

UNCOV
119
    def project_job_service
2✔
120
      @project_job_service ||= ProjectJobService.new(project:)
1✔
UNCOV
121
    end
122

UNCOV
123
    def project
2✔
UNCOV
124
      @project ||= begin
38✔
UNCOV
125
        project = Project.find(params[:id])
16✔
UNCOV
126
        @presenter = ProjectShowPresenter.new(project, current_user)
16✔
UNCOV
127
        if project&.mediaflux_id != nil && @presenter.user_has_access?(user: current_user)
12✔
UNCOV
128
          project
9✔
UNCOV
129
        else
130
          flash[:alert] = I18n.t(:access_denied)
3✔
131
          redirect_to dashboard_path
3✔
132
          nil
3✔
UNCOV
133
        end
UNCOV
134
      end
UNCOV
135
    end
136

UNCOV
137
    def eligible_editor?
2✔
138
      return true if current_user.eligible_sponsor? or current_user.eligible_manager?
×
UNCOV
139
    end
140

UNCOV
141
    def set_breadcrumbs
2✔
UNCOV
142
      add_breadcrumb("Dashboard",dashboard_path)
28✔
UNCOV
143
    end
144

UNCOV
145
    def search_projects
2✔
146
      @title_query = if params[:title_query].present?
3✔
147
        params[:title_query]
2✔
UNCOV
148
      else
149
        "*" # default to all projects
1✔
UNCOV
150
      end
151
      result =  ProjectSearch.new.call(search_string: @title_query, requestor: current_user)
3✔
152
      if result.success?
3✔
153
        flash[:notice] = "Successful search in Mediaflux for #{@title_query}"
3✔
154
        @project_presenters = result.value!
3✔
UNCOV
155
      else
156
        flash[:notice] = "Error searching projects for #{@title_query}.  Error: #{result.failure}"
×
157
        @project_presenters = []
×
UNCOV
158
      end
UNCOV
159
    end
UNCOV
160
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc