A platform for community discussion. Free, open, simple.
FIX - downcase strings consistently (#10861)
jbrwa1918801a491
diff --git a/lib/topic_creator.rb b/lib/topic_creator.rbindex cfac39f6b31..993abba96de 100644--- a/lib/topic_creator.rb+++ b/lib/topic_creator.rb@@ -218,7 +218,7 @@ class TopicCreatornames = usernames.split(',').flatten.map(&:downcase)len = 0- User.includes(:user_option).where('lower(username) in (?)', names).find_each do |user|+ User.includes(:user_option).where('username_lower in (?)', names).find_each do |user|check_can_send_permission!(topic, user)@added_users << usertopic.topic_allowed_users.build(user_id: user.id)diff --git a/spec/requests/posts_controller_spec.rb b/spec/requests/posts_controller_spec.rbindex 500ba1e8148..486fa21498d 100644--- a/spec/requests/posts_controller_spec.rb+++ b/spec/requests/posts_controller_spec.rb@@ -1083,11 +1083,17 @@ describe PostsController douser_2 = Fabricate(:user)user_3 = Fabricate(:user, username: "foo_bar")+ # In certain edge cases, it's possible to end up with a username+ # containing characters that would normally fail to validate+ user_4 = Fabricate(:user, username: "Iyi_Iyi")+ user_4.update_attribute(:username, "İyi_İyi")+ user_4.update_attribute(:username_lower, "İyi_İyi".downcase)+post "/posts.json", params: {raw: 'this is the test content',archetype: 'private_message',title: "this is some post",- target_recipients: "#{user_2.username},Foo_Bar"+ target_recipients: "#{user_2.username},Foo_Bar,İyi_İyi"}expect(response.status).to eq(200)@@ -1097,7 +1103,7 @@ describe PostsController doexpect(new_post.user).to eq(user)expect(new_topic.private_message?).to eq(true)- expect(new_topic.allowed_users).to contain_exactly(user, user_2, user_3)+ expect(new_topic.allowed_users).to contain_exactly(user, user_2, user_3, user_4)endcontext "when target_recipients not provided" do