Skip to content

Commit

Permalink
Add fix to adding admin user as private user to a private process wit…
Browse files Browse the repository at this point in the history
…h case-insensitive input
  • Loading branch information
JoonasAapro committed Sep 11, 2024
1 parent 1fb220b commit 3cc2dd8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def existing_user
return @existing_user if defined?(@existing_user)

@existing_user = User.find_by(
email: form.email,
email: form.email.downcase,
organization: private_user_to.organization
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ module Decidim::Admin
end
end

context "when email is input with case-insensitive letters" do
let!(:admin) { create(:user, :admin, email: "[email protected]", organization: privatable_to.organization) }
let!(:email) { "[email protected]" }

it "still finds the user" do
expect { subject.call }.to broadcast(:ok)

participatory_space_private_users = Decidim::ParticipatorySpacePrivateUser.where(user: admin)
participatory_space_admin = Decidim::User.where(email: "[email protected]")

expect(participatory_space_private_users.count).to eq 1
expect(participatory_space_admin.first.admin?).to be true
end
end

context "when the user has not accepted the invitation" do
before do
user.invite!
Expand Down

0 comments on commit 3cc2dd8

Please sign in to comment.