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

uclibs / aaec / 4683017e-399c-44a5-8f50-74219ba67d88

10 Oct 2023 02:18PM UTC coverage: 92.807% (-6.9%) from 99.716%
4683017e-399c-44a5-8f50-74219ba67d88

Pull #237

circleci

Thomas Scherz
Successfully node test command.
Pull Request #237: Upgrade webpack-cli to 5.1.4

658 of 709 relevant lines covered (92.81%)

15.95 hits per line

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

92.31
/app/controllers/admin_controller.rb
1
# frozen_string_literal: true
2

3
class AdminController < ApplicationController
1✔
4
  skip_before_action :check_date
1✔
5

6
  ALLOWED_CONTROLLERS_TO_MODELS = {
7
    'artworks' => Artwork,
1✔
8
    'books' => Book,
9
    'book_chapters' => BookChapter,
10
    'digital_projects' => DigitalProject,
11
    'editings' => Editing,
12
    'films' => Film,
13
    'journal_articles' => JournalArticle,
14
    'musical_scores' => MusicalScore,
15
    'photographies' => Photography,
16
    'physical_media' => PhysicalMedium,
17
    'plays' => Play,
18
    'public_performances' => PublicPerformance,
19
    'submitters' => Submitter,
20
    'other_publications' => OtherPublication
21
  }.freeze
22

23
  def login; end
1✔
24

25
  def validate
1✔
26
    if check_credentials(params[:username], params[:password])
3✔
27
      session[:admin] = true
2✔
28
      redirect_to publications_path
2✔
29
    else
30
      redirect_to manage_path, notice: 'Invalid Credentails'
1✔
31
    end
32
  end
33

34
  def csv
1✔
35
    if session[:admin] && params[:id].nil? && allowed_model
3✔
36
      begin
37
        @instance_variable = allowed_model.all
2✔
38
        respond_to do |format|
2✔
39
          format.html { redirect_to publications_path }
3✔
40
          format.csv { send_data @instance_variable.to_csv }
3✔
41
        end
42
      rescue StandardError => e
×
43
        logger.error "CSV generation failed: #{e}"
×
44
        redirect_to publications_path, notice: 'Something went wrong while generating the CSV.'
×
45
      end
46
    else
47
      redirect_to publications_path
1✔
48
    end
49
  end
50

51
  def citations
1✔
52
    if session[:admin]
2✔
53
      all = fetch_all_records
1✔
54
      @college_array = []
1✔
55
      (1..College.count).each do |i|
1✔
56
        @college_array << [i, all.select { |p| p.respond_to?(:college_ids) && p.college_ids.include?(i) }.group_by(&:uc_department)]
6✔
57
      end
58
    else
59
      redirect_to publications_path
1✔
60
    end
61
  end
62

63
  def toggle_links
1✔
64
    session[:links] = session[:links] == false
4✔
65
    redirect_to citations_path
4✔
66
  end
67

68
  private
1✔
69

70
  def check_credentials(username, password)
1✔
71
    username == ENV['ADMIN_USERNAME'] && password == ENV['ADMIN_PASSWORD']
3✔
72
  end
73

74
  def allowed_model
1✔
75
    ALLOWED_CONTROLLERS_TO_MODELS[params[:controller_name]]
4✔
76
  end
77

78
  def fetch_all_records
1✔
79
    all_records = []
2✔
80
    ALLOWED_CONTROLLERS_TO_MODELS.each_value do |model|
2✔
81
      all_records += model.all
4✔
82
    end
83
    all_records
2✔
84
  end
85
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