Last active
July 8, 2019 22:28
-
-
Save akiko-pusu/4c2b0e53cf0da6c50cc831bc57eeb106 to your computer and use it in GitHub Desktop.
Redmineのfeature specでのエラー
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% bundle exec rspec -I plugins/redmine_issue_badge/spec -e 'When Administrator' \ | |
--format documentation plugins/redmine_issue_badge/spec/features/badge_spec.rb | |
Run options: include {:full_description=>/When\ Administrator/} | |
IssueBadge | |
When Administrator | |
Global settings for badge option is displayed. | |
Badge is displayed if global settings badge option is activated. (FAILED - 1) | |
Badge is not displayed if global settings badge option is dectivated. (FAILED - 2) | |
Issue badge block is displayed if global settings badge option is activated and click badge. (FAILED - 3) | |
Issue badge polling is activate if polling option clicked. (FAILED - 4) | |
Failures: | |
1) IssueBadge When Administrator Badge is displayed if global settings badge option is activated. | |
Failure/Error: security_notification(user, sender, options).deliver_later | |
ActiveJob::DeserializationError: | |
Error while trying to deserialize arguments: Couldn't find AnonymousUser with 'id'=2 [WHERE "users"."type" IN ('AnonymousUser')] | |
# ./app/models/mailer.rb:493:in `block in deliver_security_notification' | |
# ./app/models/mailer.rb:492:in `each' | |
# ./app/models/mailer.rb:492:in `deliver_security_notification' | |
# ./app/models/user.rb:929:in `deliver_security_notification' | |
# ./plugins/redmine_issue_badge/spec/features/badge_spec.rb:139:in `block (3 levels) in <top (required)>' | |
# ------------------ | |
# --- Caused by: --- | |
# ActiveRecord::RecordNotFound: | |
# Couldn't find AnonymousUser with 'id'=2 [WHERE "users"."type" IN ('AnonymousUser')] | |
# ./app/models/mailer.rb:493:in `block in deliver_security_notification' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Send a security notification to all admins if the user has gained/lost admin privileges | |
def deliver_security_notification | |
options = { | |
field: :field_admin, | |
value: login, | |
title: :label_user_plural, | |
url: {controller: 'users', action: 'index'} | |
} | |
deliver = false | |
if (admin? && saved_change_to_id? && active?) || # newly created admin | |
(admin? && saved_change_to_admin? && active?) || # regular user became admin | |
(admin? && saved_change_to_status? && active?) # locked admin became active again | |
deliver = true | |
options[:message] = :mail_body_security_notification_add | |
elsif (admin? && destroyed? && active?) || # active admin user was deleted | |
(!admin? && saved_change_to_admin? && active?) || # admin is no longer admin | |
(admin? && saved_change_to_status? && !active?) # admin was locked | |
deliver = true | |
options[:message] = :mail_body_security_notification_remove | |
end | |
if deliver | |
users = User.active.where(admin: true).to_a | |
Mailer.deliver_security_notification(users, User.current, options) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment