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

pulibrary / tigerdata-app / e457975b-1bc0-4fc1-85bd-1b018d482b21

22 Dec 2025 01:52PM UTC coverage: 90.89% (+3.3%) from 87.588%
e457975b-1bc0-4fc1-85bd-1b018d482b21

push

circleci

web-flow
Error message enhancements in the wizard (#2330)

Advances #2117

9 of 14 new or added lines in 1 file covered. (64.29%)

573 existing lines in 39 files now uncovered.

2963 of 3260 relevant lines covered (90.89%)

607.66 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
2
class ProjectsController < ApplicationController
5✔
3

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

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

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

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

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

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

UNCOV
24
    @project_session = "details"
19✔
25

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

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

48
  def show
5✔
49
    return if project.blank?
38✔
50

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

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

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

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

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

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

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

UNCOV
92
    project_job_service.list_contents_job(user: current_user)
3✔
93

94
    json_response = {
UNCOV
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."
3✔
96
    }
UNCOV
97
    render json: json_response
3✔
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." }
×
103
  end
104

105
  def file_list_download
5✔
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 "/"
×
111
    else
112
      filename = user_request.output_file
×
113
      send_data File.read(filename), type: "text/plain", filename: "filelist.csv", disposition: "attachment"
×
114
    end
115
  end
116

117
  private
5✔
118

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

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

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

141
    def set_breadcrumbs
5✔
142
      add_breadcrumb("Dashboard",dashboard_path)
83✔
143
    end
144

145
    def search_projects
5✔
UNCOV
146
      @title_query = if params[:title_query].present?
6✔
UNCOV
147
        params[:title_query]
4✔
148
      else
UNCOV
149
        "*" # default to all projects
2✔
150
      end
UNCOV
151
      result =  ProjectSearch.new.call(search_string: @title_query, requestor: current_user)
6✔
UNCOV
152
      if result.success?
6✔
UNCOV
153
        flash[:notice] = "Successful search in Mediaflux for #{@title_query}"
6✔
UNCOV
154
        @project_presenters = result.value!
6✔
155
      else
156
        flash[:notice] = "Error searching projects for #{@title_query}.  Error: #{result.failure}"
×
157
        @project_presenters = []
×
158
      end
159
    end
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