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

pulibrary / tigerdata-app / c82158e6-9802-444d-b5c9-ae51639fc4e5

19 Dec 2025 08:33PM UTC coverage: 86.669% (-0.9%) from 87.588%
c82158e6-9802-444d-b5c9-ae51639fc4e5

Pull #2330

circleci

web-flow
Merge branch 'main' into 2117-Error_message_enhancements
Pull Request #2330: Error message enhancements in the wizard

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

338 existing lines in 28 files now uncovered.

2828 of 3263 relevant lines covered (86.67%)

473.13 hits per line

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

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

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

7
  def details
3✔
UNCOV
8
    return if project.blank?
16✔
9

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

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

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

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

UNCOV
24
    @project_session = "details"
15✔
25

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

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

48
  def show
3✔
UNCOV
49
    return if project.blank?
31✔
50

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

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

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

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

UNCOV
64
    @project_session = "content"
27✔
UNCOV
65
    respond_to do |format|
27✔
UNCOV
66
      format.html { render }
49✔
UNCOV
67
      format.xml { render xml: ProjectShowPresenter.new(project, current_user).to_xml
32✔
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
3✔
UNCOV
76
    project_id = params[:id]
2✔
UNCOV
77
    project = Project.find(project_id)
2✔
UNCOV
78
    respond_to do |format|
1✔
UNCOV
79
      format.xml do
1✔
UNCOV
80
        render xml: project.mediaflux_meta_xml(user: current_user)
1✔
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
3✔
UNCOV
90
    return if project.blank?
2✔
91

UNCOV
92
    project_job_service.list_contents_job(user: current_user)
2✔
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."
2✔
96
    }
UNCOV
97
    render json: json_response
2✔
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
3✔
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
3✔
118

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

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

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

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

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