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

pulibrary / tigerdata-app / c56a318b-c930-4c46-8af1-a844f60687b3

04 Aug 2025 04:55PM UTC coverage: 77.664% (-0.03%) from 77.691%
c56a318b-c930-4c46-8af1-a844f60687b3

push

circleci

web-flow
Do not modify the Rails configuration when generating test projects (#1676)

fixes #1663

0 of 3 new or added lines in 1 file covered. (0.0%)

1 existing line in 1 file now uncovered.

2201 of 2834 relevant lines covered (77.66%)

324.28 hits per line

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

25.0
/app/services/test_project_generator.rb
1
# frozen_string_literal: true
2
class TestProjectGenerator
1✔
3
  attr_reader :user, :number, :sequence, :project_prefix
1✔
4

5
  def initialize(user:, number:, project_prefix:)
1✔
6
    @user = user
×
7
    @number = number
×
8
    @sequence = number.to_s.rjust(5, "0")
×
9
    @project_prefix = project_prefix
×
10
  end
11

12
  def generate
1✔
13
    project = create_project
×
14
    project.approve!(current_user: user)
×
15
    project.save!
×
16
    project
×
17
  end
18

19
  private
1✔
20

21
    def create_project
1✔
22
      # create a duplicate copy of the configuration so we do not modify the rails defaults
NEW
23
      capacity = Rails.configuration.project_defaults[:storage_capacity].deep_dup
×
24
      # For testing purposes we use the same size as the requested values
NEW
25
      capacity[:size][:approved] = capacity[:size][:requested]
×
NEW
26
      capacity[:unit][:approved] = capacity[:unit][:requested]
×
27

28
      metadata = {
29
        created_on: Time.current.in_time_zone("America/New_York").iso8601,
×
30
        created_by: user.uid,
31
        data_sponsor: sponsor.uid,
32
        data_manager: sponsor.uid,
33
        data_user_read_only: [],
34
        data_user_read_write: [user.uid],
35
        departments: departments,
36
        project_directory: "#{project_prefix}-#{sequence}",
37
        title: "Project #{project_prefix} #{sequence}",
38
        description: "Description of project #{project_prefix} #{sequence}",
39
        project_id: project_id,
40
        storage_capacity: capacity,
41
        project_purpose: Rails.configuration.project_defaults[:project_purpose],
42
        storage_performance_expectations: Rails.configuration.project_defaults[:storage_performance_expectations],
43
        status: Project::PENDING_STATUS
44
      }
UNCOV
45
      project = Project.new(metadata: )
×
46
      project.save!
×
47
      project
×
48
    end
49

50
    def sponsor
1✔
51
      return User.where(uid: "hc8719").first
×
52
    end
53

54
    def departments
1✔
55
      ldepartments = []
×
56
      ldepartments << Affiliation.all[3][:code] if (number % 7) == 0
×
57
      ldepartments << Affiliation.all[2][:code] if (number % 3) == 0
×
58
      ldepartments << Affiliation.all[1][:code] if (number % 5) == 0
×
59
      ldepartments << Affiliation.all[0][:code] if ldepartments.count == 0
×
60
      ldepartments
×
61
    end
62

63
    def project_id
1✔
64
      part1 = rand(1...99).to_s.rjust(2, "0")
×
65
      part2 = rand(1...99999).to_s.rjust(5, "0")
×
66
      part3 = rand(1...9999).to_s.rjust(4, "0")
×
67
      part4 = rand(1...9999).to_s.rjust(4, "0")
×
68
      "#{part1}.#{part2}/#{part3}-#{part4}"
×
69
    end
70
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