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

pulibrary / tigerdata-app / 699c2139-839b-4593-bb89-b830acc958af

24 Nov 2025 05:25PM UTC coverage: 91.333% (+20.9%) from 70.412%
699c2139-839b-4593-bb89-b830acc958af

Pull #2235

circleci

carolyncole
Do not redirect from home page when login is disabled

fixes #2188
Pull Request #2235: Do not redirect from home page when login is disabled

1 of 5 new or added lines in 2 files covered. (20.0%)

580 existing lines in 35 files now uncovered.

2898 of 3173 relevant lines covered (91.33%)

570.28 hits per line

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

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

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

7
  def details
4✔
UNCOV
8
    return if project.blank?
19✔
9

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

UNCOV
13
    @provenance_events = project.provenance_events.where.not(event_type: ProvenanceEvent::STATUS_UPDATE_EVENT_TYPE)
17✔
14

UNCOV
15
    @project_eligible_to_edit = true if project.status == Project::APPROVED_STATUS && eligible_editor?
17✔
16

UNCOV
17
    @project_metadata = @project.metadata
17✔
UNCOV
18
    @storage_capacity = @project_metadata[:storage_capacity]
17✔
UNCOV
19
    @size = @storage_capacity[:size]
17✔
UNCOV
20
    @unit = @storage_capacity[:unit]
17✔
21

UNCOV
22
    @requested_size = @size[:requested]
17✔
UNCOV
23
    @requested_unit = @unit[:requested]
17✔
24

UNCOV
25
    @approved_size = @size[:approved]
17✔
UNCOV
26
    @approved_unit = @unit[:approved]
17✔
27

UNCOV
28
    @storage_expectations = @project_metadata[:storage_performance_expectations]
17✔
UNCOV
29
    @requested_storage_expectations = @storage_expectations[:requested]
17✔
UNCOV
30
    @approved_storage_expectations = @storage_expectations[:approved]
17✔
31

UNCOV
32
    @project_session = "details"
17✔
33

UNCOV
34
    respond_to do |format|
17✔
UNCOV
35
      format.html do
17✔
UNCOV
36
        render
14✔
37
      end
UNCOV
38
      format.json do
17✔
UNCOV
39
        render json: project.to_json
2✔
40
      end
UNCOV
41
      format.xml do
17✔
UNCOV
42
        render xml: @presenter.to_xml
1✔
43
      end
44
    end
45
  end
46

47
  def index
4✔
UNCOV
48
    if current_user.eligible_sysadmin?
10✔
UNCOV
49
      search_projects
6✔
50
    else
UNCOV
51
      flash[:alert] = I18n.t(:access_denied)
4✔
UNCOV
52
      redirect_to dashboard_path
4✔
53
    end
54
  end
55

56
  def show
4✔
UNCOV
57
    return if project.blank?
39✔
58

UNCOV
59
    add_breadcrumb(@presenter.title, project_path)
31✔
UNCOV
60
    add_breadcrumb("Contents")
31✔
61

UNCOV
62
    @latest_completed_download = current_user.user_requests.where(project_id: @project.id, state: "completed").order(:completion_time).last
31✔
UNCOV
63
    @storage_usage = project.storage_usage(session_id: current_user.mediaflux_session)
31✔
UNCOV
64
    @storage_capacity = project.storage_capacity(session_id: current_user.mediaflux_session)
31✔
65

UNCOV
66
    @num_files = project.asset_count(session_id: current_user.mediaflux_session)
31✔
67

UNCOV
68
    @file_list = project.file_list(session_id: current_user.mediaflux_session, size: 100)
31✔
UNCOV
69
    @files = @file_list[:files]
31✔
UNCOV
70
    @files.sort_by!(&:path)
31✔
71

UNCOV
72
    @project_session = "content"
31✔
UNCOV
73
    respond_to do |format|
31✔
UNCOV
74
      format.html { render }
56✔
UNCOV
75
      format.xml { render xml: ProjectShowPresenter.new(project, current_user).to_xml
37✔
76
    }
77
    end
78
  end
79

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

97
  def list_contents
4✔
UNCOV
98
    return if project.blank?
4✔
99

UNCOV
100
    project_job_service.list_contents_job(user: current_user)
3✔
101

102
    json_response = {
UNCOV
103
      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✔
104
    }
UNCOV
105
    render json: json_response
3✔
106
  rescue => ex
107
    message = "Error producing document list (project id: #{project&.id}): #{ex.message}"
×
108
    Rails.logger.error(message)
×
109
    Honeybadger.notify(message)
×
110
    render json: { message: "Document list could not be generated." }
×
111
  end
112

113
  def file_list_download
4✔
114
    job_id = params[:job_id]
×
115
    user_request = FileInventoryRequest.where(job_id:job_id).first
×
116
    if user_request.nil?
×
117
      # TODO: handle error
118
      redirect_to "/"
×
119
    else
120
      filename = user_request.output_file
×
121
      send_data File.read(filename), type: "text/plain", filename: "filelist.csv", disposition: "attachment"
×
122
    end
123
  end
124

125
  private
4✔
126

127
    def project_job_service
4✔
UNCOV
128
      @project_job_service ||= ProjectJobService.new(project:)
3✔
129
    end
130

131

132
    def build_new_project
4✔
133
      @project ||= Project.new
×
134
    end
135

136
    def project
4✔
UNCOV
137
      @project ||= begin
234✔
UNCOV
138
        project = Project.find(params[:id])
62✔
UNCOV
139
        @presenter = ProjectShowPresenter.new(project, current_user)
62✔
UNCOV
140
        if project&.mediaflux_id != nil && @presenter.user_has_access?(user: current_user)
58✔
UNCOV
141
          project
51✔
142
        else
UNCOV
143
          flash[:alert] = I18n.t(:access_denied)
7✔
UNCOV
144
          redirect_to dashboard_path
7✔
UNCOV
145
          nil
7✔
146
        end
147
      end
148
    end
149

150
    def eligible_editor?
4✔
151
      return true if current_user.eligible_sponsor? or current_user.eligible_manager?
3✔
152
    end
153

154
    def set_breadcrumbs
4✔
UNCOV
155
      add_breadcrumb("Dashboard",dashboard_path)
82✔
156
    end
157

158
    def search_projects
4✔
UNCOV
159
      @title_query = if params[:title_query].present?
6✔
UNCOV
160
        params[:title_query]
4✔
161
      else
UNCOV
162
        "*" # default to all projects
2✔
163
      end
UNCOV
164
      result =  ProjectSearch.new.call(search_string: @title_query, requestor: current_user)
6✔
UNCOV
165
      if result.success?
6✔
UNCOV
166
        flash[:notice] = "Successful search in Mediaflux for #{@title_query}"
6✔
167
        # As of today the search results and the Dashboard show similar information (a list of projects)
168
        # and it makes sense to use the same presenter. If once we flesh out the search feature the
169
        # results become too different from each other we can create a specific presenter for the search
170
        # results.
UNCOV
171
        @project_presenters = result.value!.map { |project| ProjectDashboardPresenter.new(project, current_user) }
18✔
172
      else
173
        flash[:notice] = "Error searching projects for #{@title_query}.  Error: #{result.failure}"
×
174
        @project_presenters = []
×
175
      end
176
    end
177
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

© 2025 Coveralls, Inc