bullet_train 1.35.0 → 1.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25534acd68cfd6da1b0e05199b35c0795bbd98d9fa1314fd1c1180b154e7c043
4
- data.tar.gz: cc0cad473683e187e5dcaeca068748a3fe979cf7ebca0687766d4710e97cb164
3
+ metadata.gz: 5c1d33c15093050889618d0a58e53899f22dbbee55e6792adad049b36107eec6
4
+ data.tar.gz: a7a547ddbb60545ee9b2f37e984aa1b293a84ddd231a3233542ea85e5a2c5a61
5
5
  SHA512:
6
- metadata.gz: a221a9c961bbd7f379d340f9a97d98cdaa4c4c74b88c593778d4b81e517b73e863a497a739fc465fb77d2ff6751e29d0d851b118e67957c1ffac4d82396a9690
7
- data.tar.gz: c94b9763df8e2182a9f041771921c1d0299fcfdec7618ff44f167249378f9879ca21521c58d9903bdc09a501c42e1100d79c53f9c9ded2030e117a4b561bdb63
6
+ metadata.gz: dafe1f7e4ec075acbd7fd8417a2080b7dc51c496eaf2b8d3b63e14262d9a43b2bce61e8ed8b42678688ba48c4346026c2ae3ce87e4b778532e7bec7931dab8e7
7
+ data.tar.gz: f25805b74ba7e7f77ccadfe2404350a312f6de5d4f223b4940f8a881c5017cccc4aa2d348fa9fca3acd3a247d2fd9b994b85dfa63b1d0c46727ee683ea85e9e8
@@ -14,6 +14,8 @@ module Invitations::Base
14
14
  after_create :set_added_by_membership
15
15
  after_create :send_invitation_email
16
16
 
17
+ after_validation :hoist_membership_email_error
18
+
17
19
  attribute :uuid, default: -> { SecureRandom.hex }
18
20
 
19
21
  def roles
@@ -44,4 +46,13 @@ module Invitations::Base
44
46
  def is_for?(user)
45
47
  user.email.downcase.strip == email.downcase.strip
46
48
  end
49
+
50
+ def hoist_membership_email_error
51
+ # This is special handling for the email field because we have a uniqueness validation in the
52
+ # `Membership` model for the `user_email` field. Since we copy the value from `invitation.email`
53
+ # into `invitation.membership.user_email` the error isn't passed through to the form in the normal way.
54
+ errors[:"membership.user_email"]&.each do |error|
55
+ errors.add(:email, error)
56
+ end
57
+ end
47
58
  end
@@ -44,6 +44,7 @@ module Users::Base
44
44
  # callbacks
45
45
  after_validation :remove_profile_photo, if: :profile_photo_removal?
46
46
  after_update :set_teams_time_zone
47
+ after_update :set_memberships_email
47
48
  end
48
49
 
49
50
  def email_is_oauth_placeholder?
@@ -159,6 +160,12 @@ module Users::Base
159
160
  end
160
161
  end
161
162
 
163
+ def set_memberships_email
164
+ if email_previously_changed?
165
+ memberships.where.not(user_email: email).update(user_email: email)
166
+ end
167
+ end
168
+
162
169
  def profile_photo_removal?
163
170
  profile_photo_removal.present?
164
171
  end
@@ -1,3 +1,3 @@
1
1
  module BulletTrain
2
- VERSION = "1.35.0"
2
+ VERSION = "1.36.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.35.0
4
+ version: 1.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver