Skip to content

Commit

Permalink
Rename batchuser and audituser to batch_user and audit_user
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed May 18, 2016
1 parent d75a318 commit 8e0c601
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
Expand Up @@ -50,8 +50,8 @@ def authorize_and_return_grantor
def send_proxy_depositor_added_messages(grantor, grantee)
message_to_grantee = "#{grantor.name} has assigned you as a proxy depositor"
message_to_grantor = "You have assigned #{grantee.name} as a proxy depositor"
::User.batchuser.send_message(grantor, message_to_grantor, "Proxy Depositor Added")
::User.batchuser.send_message(grantee, message_to_grantee, "Proxy Depositor Added")
::User.batch_user.send_message(grantor, message_to_grantor, "Proxy Depositor Added")
::User.batch_user.send_message(grantee, message_to_grantee, "Proxy Depositor Added")
end
end
end
22 changes: 14 additions & 8 deletions app/models/concerns/sufia/user.rb
Expand Up @@ -2,6 +2,8 @@

module Sufia::User
extend ActiveSupport::Concern
extend Deprecation
self.deprecation_horizon = 'Sufia version 8.0.0'

included do
# Adds acts_as_messageable for user mailboxes
Expand Down Expand Up @@ -153,22 +155,26 @@ def current=(user)
end

# Override this method if you aren't using email/password
def audituser
User.find_by_user_key(audituser_key) || User.create!(Devise.authentication_keys.first => audituser_key, password: Devise.friendly_token[0, 20])
def audit_user
User.find_by_user_key(audit_user_key) || User.create!(Devise.authentication_keys.first => audit_user_key, password: Devise.friendly_token[0, 20])
end

# Override this method if you aren't using email as the userkey
def audituser_key
alias audituser audit_user
deprecation_deprecate audituser: 'use audit_user instead'

def audit_user_key
Sufia.config.audit_user_key
end

# Override this method if you aren't using email/password
def batchuser
User.find_by_user_key(batchuser_key) || User.create!(Devise.authentication_keys.first => batchuser_key, password: Devise.friendly_token[0, 20])
def batch_user
User.find_by_user_key(batch_user_key) || User.create!(Devise.authentication_keys.first => batch_user_key, password: Devise.friendly_token[0, 20])
end

# Override this method if you aren't using email as the userkey
def batchuser_key
alias batchuser batch_user
deprecation_deprecate batchuser: 'use batch_user instead'

def batch_user_key
Sufia.config.batch_user_key
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/proxy_deposit_request.rb
Expand Up @@ -38,11 +38,11 @@ def should_not_be_already_part_of_a_transfer
def send_request_transfer_message
if updated_at == created_at
message = "#{link_to(sending_user.name, Sufia::Engine.routes.url_helpers.profile_path(sending_user.user_key))} wants to transfer a work to you. Review all <a href='#{Sufia::Engine.routes.url_helpers.transfers_path}'>transfer requests</a>"
User.batchuser.send_message(receiving_user, message, "Ownership Change Request")
User.batch_user.send_message(receiving_user, message, "Ownership Change Request")
else
message = "Your transfer request was #{status}."
message += " Comments: #{receiver_comment}" unless receiver_comment.blank?
User.batchuser.send_message(sending_user, message, "Ownership Change #{status}")
User.batch_user.send_message(sending_user, message, "Ownership Change #{status}")
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/services/sufia/message_user_service.rb
Expand Up @@ -24,7 +24,7 @@ def subject
private

def job_user
::User.audituser
::User.audit_user
end
end
end
8 changes: 4 additions & 4 deletions spec/factories/users.rb
Expand Up @@ -8,17 +8,17 @@
# Create examples of single file successes and failures
(1..10).each do |number|
file = MockFile.new(number.to_s, "Single File #{number}")
User.batchuser.send_message(user, 'File 1 could not be updated. You do not have sufficient privileges to edit it.', file.to_s, false)
User.batchuser.send_message(user, 'File 1 has been saved', file.to_s, false)
User.batch_user.send_message(user, 'File 1 could not be updated. You do not have sufficient privileges to edit it.', file.to_s, false)
User.batch_user.send_message(user, 'File 1 has been saved', file.to_s, false)
end

# Create examples of mulitple file successes and failures
files = []
(1..50).each do |number|
files << MockFile.new(number.to_s, "File #{number}")
end
User.batchuser.send_message(user, 'These files could not be updated. You do not have sufficient privileges to edit them.', 'Batch upload permission denied', false)
User.batchuser.send_message(user, 'These files have been saved', 'Batch upload complete', false)
User.batch_user.send_message(user, 'These files could not be updated. You do not have sufficient privileges to edit them.', 'Batch upload permission denied', false)
User.batch_user.send_message(user, 'These files have been saved', 'Batch upload complete', false)
end
end
end
Expand Down

0 comments on commit 8e0c601

Please sign in to comment.