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

pulibrary / tigerdata-app / 86b0b6de-1ed1-428a-906f-f693f615c015

18 Dec 2025 06:52PM UTC coverage: 46.921% (-30.6%) from 77.536%
86b0b6de-1ed1-428a-906f-f693f615c015

push

circleci

kelynch
Fixing tests

11 of 12 new or added lines in 5 files covered. (91.67%)

849 existing lines in 32 files now uncovered.

1707 of 3638 relevant lines covered (46.92%)

109.64 hits per line

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

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

UNCOV
4
  before_action :set_breadcrumbs
×
UNCOV
5
  before_action :authenticate_user!
×
6

UNCOV
7
  def details
×
8
    return if project.blank?
×
9

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

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

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

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

UNCOV
24
    @project_session = "details"
×
25

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

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

48
  def show
×
49
    return if project.blank?
×
50

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

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

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

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

UNCOV
64
    @project_session = "content"
×
UNCOV
65
    respond_to do |format|
×
UNCOV
66
      format.html { render }
×
UNCOV
67
      format.xml { render xml: ProjectShowPresenter.new(project, current_user).to_xml
×
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
×
UNCOV
76
    project_id = params[:id]
×
UNCOV
77
    project = Project.find(project_id)
×
UNCOV
78
    respond_to do |format|
×
UNCOV
79
      format.xml do
×
UNCOV
80
        render xml: project.mediaflux_meta_xml(user: current_user)
×
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}"
×
UNCOV
85
    flash[:alert] = "Error fetching Mediaflux XML for this project"
×
UNCOV
86
    redirect_to project_path(project_id)
×
UNCOV
87
  end
×
88

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

92
    project_job_service.list_contents_job(user: current_user)
×
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."
×
UNCOV
96
    }
×
UNCOV
97
    render json: json_response
×
98
  rescue => ex
×
UNCOV
99
    message = "Error producing document list (project id: #{project&.id}): #{ex.message}"
×
100
    Rails.logger.error(message)
×
UNCOV
101
    Honeybadger.notify(message)
×
UNCOV
102
    render json: { message: "Document list could not be generated." }
×
103
  end
×
104

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

UNCOV
117
  private
×
118

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

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

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

UNCOV
141
    def set_breadcrumbs
×
UNCOV
142
      add_breadcrumb("Dashboard",dashboard_path)
×
143
    end
×
144

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