Skip to content

Commit

Permalink
Merge pull request #2376 from alphagov/fix-for-fix-for-migration-that…
Browse files Browse the repository at this point in the history
…-stripped-whitespace-from-biu-organisation-slug

Handle nil name in BatchInvitationUser#strip_whitespace_from_name
  • Loading branch information
floehopper authored Sep 25, 2023
2 parents afe562d + 12f0417 commit b6c7bf1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/batch_invitation_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def sanitise_attributes_for_inviting_user_role(raw_attributes, inviting_user)
end

def strip_whitespace_from_name
name.strip!
name&.strip!
end

def strip_whitespace_from_email
Expand Down
6 changes: 6 additions & 0 deletions test/models/batch_invitation_user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class BatchInvitationUserTest < ActiveSupport::TestCase

assert_equal "cabinet-office", user.organisation_slug
end

should "strip unwanted whitespace from organisation_slug before persisting even if name is nil" do
user = create(:batch_invitation_user, organisation_slug: " cabinet-office ", name: nil)

assert_equal "cabinet-office", user.organisation_slug
end
end

context "validations" do
Expand Down

0 comments on commit b6c7bf1

Please sign in to comment.