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

curationexperts / laevigata / 19c4769a-6b0c-4fcc-b3f5-2c857d0a297f

12 Apr 2026 10:25AM UTC coverage: 97.442%. Remained the same
19c4769a-6b0c-4fcc-b3f5-2c857d0a297f

Pull #2492

circleci

web-flow
Bump axios from 1.13.5 to 1.15.0

Bumps [axios](https://github.com/axios/axios) from 1.13.5 to 1.15.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.13.5...v1.15.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-version: 1.15.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #2492: Bump axios from 1.13.5 to 1.15.0

2857 of 2932 relevant lines covered (97.44%)

50.77 hits per line

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

100.0
/lib/workflow_setup.rb
1
# Set up the AdminSets and Workflow for Laevigata
2
require File.expand_path('../../config/environment', __FILE__)
4✔
3
require 'yaml'
4✔
4

5
# Set up the application's initial state: load required roles, create required AdminSets, load appropriate users and workflows
6
class WorkflowSetup
4✔
7
  include SemanticLogger::Loggable
4✔
8

9
  attr_reader :admin_set_owner
4✔
10
  attr_reader :admin_sets_config
4✔
11
  attr_accessor :superusers_config
4✔
12
  ADMIN_SET_OWNER = "admin_set_owner".freeze
4✔
13
  NOTIFICATION_OWNER = "notification_owner".freeze
4✔
14
  DEFAULT_SUPERUSERS_CONFIG = "#{::Rails.root}/config/emory/superusers.yml".freeze
4✔
15
  DEFAULT_ADMIN_SETS_CONFIG = "#{::Rails.root}/config/emory/admin_sets.yml".freeze
4✔
16

17
  # Set up the parameters for
18
  # @param [String] superusers_config a file containing the email addresses of the application's superusers
19
  # @param [String] config_file_dir the directory where the config files reside
20
  # @param [String] schools_config
21
  # @param [String] log_location where should the log files write? Default is STDOUT. /dev/null is also an option for CI builds
22
  def initialize(superusers_config = DEFAULT_SUPERUSERS_CONFIG, admin_sets_config = DEFAULT_ADMIN_SETS_CONFIG, _log_location = STDOUT)
4✔
23
    raise "File #{superusers_config} does not exist" unless File.exist?(superusers_config)
68✔
24
    @superusers_config = YAML.safe_load(File.read(superusers_config))
68✔
25
    raise "File #{admin_sets_config} does not exist" unless File.exist?(admin_sets_config)
68✔
26
    @admin_sets_config = YAML.safe_load(File.read(admin_sets_config))
68✔
27
    logger.info "Initializing new workflow setup with superusers file #{superusers_config} and admin_sets_config files from #{admin_sets_config}"
68✔
28
    Hyrax::RoleRegistry.new.persist_registered_roles! # Ensure we have a managing and a depositing role
68✔
29
    @admin_set_owner = make_superuser(ADMIN_SET_OWNER)
68✔
30
  end
31

32
  # Load the superusers
33
  # Make an AdminSet for each school, with the proper workflow
34
  # Allow any registered user to deposit into any of the AdminSets
35
  # Give superusers every available role in all workflows in all AdminSets
36
  def setup
4✔
37
    make_notification_owner
46✔
38
    load_superusers
46✔
39
    admin_sets.each do |as|
46✔
40
      logger.debug "Attempting to make admin set for #{as}"
54✔
41
      make_admin_set_from_config(as)
54✔
42
    end
43
    everyone_can_deposit_everywhere
46✔
44
    give_superusers_superpowers
46✔
45
  end
46

47
  # A ::User to own notifications
48
  def make_notification_owner
4✔
49
    u = ::User.find_or_create_by(uid: NOTIFICATION_OWNER)
47✔
50
    u.ppid = NOTIFICATION_OWNER
47✔
51
    u.display_name = "ETD Notification System"
47✔
52
    u.save
47✔
53
  end
54

55
  # Make an AdminSet and assign it a one step mediated deposit workflow
56
  # @param [String] admin_set_title The title of the admin set to create
57
  # @param [String] workflow_name The name of the mediated deposit workflow to enable
58
  def make_mediated_deposit_admin_set(admin_set_title, workflow_name = "emory_one_step_approval")
4✔
59
    a = make_admin_set(admin_set_title)
62✔
60
    activate_mediated_deposit(a, workflow_name)
62✔
61
    a
62✔
62
  end
63

64
  # Given an admin set and a role, return relevant Array of Sipity::Users for the
65
  # currently active workflow
66
  # @param [AdminSet] admin_set
67
  # @param [String|Sipity::Role] role e.g., "approving" "depositing" "managing"
68
  # @return [Array<Sipity::Agent>] An array of Sipity::Agent objects
69
  def users_in_role(admin_set, role)
4✔
70
    return [] unless admin_set.permission_template.available_workflows.exists?(active: true)
231✔
71

72
    role     = Sipity::Role.find_by!(name: role) unless role.is_a?(Sipity::Role)
231✔
73
    workflow = admin_set.permission_template.available_workflows.find_by(active: true)
231✔
74
    wf_role  = Sipity::WorkflowRole.find_by(workflow: workflow, role_id: role)
231✔
75
    return [] unless wf_role
231✔
76

77
    Sipity::Agent.where(id: wf_role.workflow_responsibilities.pluck(:agent_id),
231✔
78
                        proxy_for_type: 'User').to_a
79
  end
80

81
  # Read a config file to figure out what workflow to enable and how to grant approving_role
82
  # @param [String] admin_set_title
83
  # @return [AdminSet]
84
  def make_admin_set_from_config(admin_set_title)
4✔
85
    config = admin_set_config(admin_set_title)
59✔
86
    config["workflow"] || config["workflow"] = "emory_one_step_approval"
59✔
87
    admin_set = make_mediated_deposit_admin_set(admin_set_title, config["workflow"])
59✔
88
    approving_users = []
59✔
89
    config["approving"].each do |approver_uid|
59✔
90
      u = ::User.find_or_create_by(uid: approver_uid)
108✔
91
      u.password = "123456" if set_default_password?
108✔
92
      u.provider = "shibboleth"
108✔
93
      u.ppid = approver_uid # temporary ppid, will get replaced when user signs in with shibboleth
108✔
94
      u.save
108✔
95
      approving_users << u.to_sipity_agent
108✔
96
    end
97
    approval_role = Sipity::Role.find_by!(name: 'approving')
59✔
98
    workflow = admin_set.active_workflow
59✔
99
    workflow.update_responsibilities(role: approval_role, agents: (approving_users.concat users_in_role(admin_set, "approving")))
59✔
100
    if workflow.workflow_roles.map { |workflow_role| workflow_role.role.name }.include?("reviewing")
295✔
101
      reviewing_role = Sipity::Role.find_by!(name: 'reviewing')
59✔
102
      workflow.update_responsibilities(role: reviewing_role, agents: (approving_users.concat users_in_role(admin_set, "reviewing")))
59✔
103
    end
104
    admin_set
59✔
105
  end
106

107
  # Create the admin role, or find it if it exists already
108
  # @return [Role] the admin Role
109
  def admin_role
4✔
110
    Role.find_or_create_by(name: "admin")
1,185✔
111
  end
112

113
  # Load the superusers from a config file
114
  def load_superusers
4✔
115
    admin_role.users = [] # Remove all the admin users every time you reload
57✔
116
    admin_role.save
57✔
117
    @superusers_config["superusers"].each_key do |provider|
57✔
118
      @superusers_config["superusers"][provider].each do |s|
114✔
119
        make_superuser(s, provider)
171✔
120
      end
121
    end
122
  end
123

124
  # Make a superuser
125
  # @param [String] the uid of the superuser
126
  # @return [User] the superuser who was just created
127
  def make_superuser(uid, provider = "database")
4✔
128
    logger.debug "Making superuser #{uid}"
245✔
129
    admin_user = ::User.find_or_create_by(uid: uid)
245✔
130
    admin_user.password = "123456" if set_default_password?
245✔
131
    admin_user.ppid = uid # temporary ppid, will get replaced when user signs in with shibboleth
245✔
132
    admin_user.provider = provider
245✔
133
    admin_user.save
245✔
134
    admin_role.users << admin_user
245✔
135
    admin_role.save
245✔
136
    admin_user
245✔
137
  end
138

139
  # Don't set default passwords in production mode
140
  def set_default_password?
4✔
141
    AuthConfig.use_database_auth? && !Rails.env.production?
353✔
142
  end
143

144
  # return an array of all current superusers
145
  # @return [Array(User)]
146
  def superusers
4✔
147
    raise "No superusers are defined" unless admin_role.users.count > 0
289✔
148
    admin_role.users
289✔
149
  end
150

151
  # Allow anyone with a registered account to deposit into any of the AdminSets
152
  def everyone_can_deposit_everywhere
4✔
153
    AdminSet.all.each do |admin_set|
47✔
154
      next if Hyrax::PermissionTemplateAccess
55✔
155
                .find_by(permission_template_id: admin_set.permission_template.id,
156
                         agent_id:   'registered',
157
                         access:     'deposit',
158
                         agent_type: 'group')
159

160
      admin_set.permission_template.access_grants.create(agent_type: 'group', agent_id: 'registered', access: 'deposit')
55✔
161
      deposit = Sipity::Role.find_by!(name: 'depositing')
55✔
162
      admin_set.permission_template.available_workflows.each do |workflow|
55✔
163
        workflow.update_responsibilities(role: deposit, agents: Hyrax::Group.new('registered'))
110✔
164
      end
165
    end
166
  end
167

168
  # Give superusers the managing role in all AdminSets
169
  # Also give them all workflow roles for all AdminSets
170
  def give_superusers_superpowers
4✔
171
    logger.info "Giving superuser powers to #{superusers.pluck(:ppid)}"
48✔
172
    give_superusers_managing_role
48✔
173
    give_superusers_workflow_roles
48✔
174
  end
175

176
  def superusers_as_sipity_agents
4✔
177
    superusers.map(&:to_sipity_agent)
224✔
178
  end
179

180
  # Give all superusers the managing role all workflows
181
  def give_superusers_managing_role
4✔
182
    AdminSet.all.each do |admin_set|
48✔
183
      admin_set.permission_template.available_workflows.each do |workflow| # .where(active: true) ?
56✔
184
        workflow.update_responsibilities(role: Sipity::Role.where(name: "managing").first, agents: superusers_as_sipity_agents)
112✔
185
      end
186
    end
187
  end
188

189
  def give_superusers_workflow_roles
4✔
190
    AdminSet.all.each do |admin_set|
48✔
191
      admin_set.permission_template.available_workflows.where(active: true).each do |workflow|
56✔
192
        workflow_roles = Sipity::WorkflowRole.where(workflow_id: workflow.id)
56✔
193
        workflow_roles.each do |workflow_role|
56✔
194
          workflow_role_name = Sipity::Role.where(id: workflow_role.role_id).first.name
224✔
195
          next if workflow_role_name == "depositing" || workflow_role_name == "managing"
224✔
196
          union_of_users = superusers_as_sipity_agents.concat(users_in_role(admin_set, workflow_role_name)).uniq
112✔
197
          logger.debug "Granting #{workflow_role_name} to #{union_of_users.map { |u| User.where(id: u.proxy_for_id).first.ppid }.to_sentence}"
760✔
198
          workflow.update_responsibilities(role: Sipity::Role.where(id: workflow_role.role_id), agents: union_of_users)
112✔
199
        end
200
      end
201
    end
202
  end
203

204
  # Make an AdminSet with the given title, belonging to the @admin_set_owner
205
  # @return [AdminSet] the admin set that was just created, or the one that existed already
206
  def make_admin_set(admin_set_title)
4✔
207
    if AdminSet.where(title_sim: admin_set_title).count > 0
66✔
208
      logger.debug "AdminSet #{admin_set_title} already exists."
1✔
209
      return AdminSet.where(title_sim: admin_set_title).first
1✔
210
    end
211
    a = AdminSet.create(title: [admin_set_title])
65✔
212
    Hyrax::AdminSetCreateService.call(admin_set: a, creating_user: @admin_set_owner)
65✔
213
    a
65✔
214
  end
215

216
  # Activate a mediated deposit workflow for the given admin_set.
217
  # Default is emory_one_step_approval, but a different value can be passed in.
218
  # The activate! method will DEactivate it if it was already active, so be careful.
219
  # @return [Boolean] true if successful
220
  def activate_mediated_deposit(admin_set, workflow_name = "emory_one_step_approval")
4✔
221
    osmd = admin_set.permission_template.available_workflows.where(name: workflow_name).first
63✔
222
    if osmd.active == true
63✔
223
      logger.debug "AdminSet #{admin_set.title.first} already had workflow #{admin_set.permission_template.available_workflows.where(active: true).first.name}. Not making any changes."
47✔
224
      return true
47✔
225
    end
226
    Sipity::Workflow.activate!(
16✔
227
      permission_template: admin_set.permission_template,
228
      workflow_id: osmd.id
229
    )
230
    logger.debug "AdminSet #{admin_set.title.first} has workflow #{admin_set.permission_template.available_workflows.where(active: true).first.name}"
16✔
231
    true
16✔
232
  end
233

234
  # Return an array of AdminSets that should be set up for the initial workflow
235
  # @return [Array(String)]
236
  def admin_sets
4✔
237
    @admin_sets_config.keys
54✔
238
  end
239

240
  # Given the name of a school, read its config into a Hash
241
  # @param [String] the name of an admin_set
242
  # @return [Hash] a Hash containing approvers and (optionally) workflow for this school
243
  def admin_set_config(school_name)
4✔
244
    raise "Couldn't find expected config for #{school_name}" unless @admin_sets_config[school_name]
61✔
245
    @admin_sets_config[school_name]
60✔
246
  end
247
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