diff --git a/app/services/group_message.rb b/app/services/group_message.rb index 47ee093a3fd..c55c9c66a9f 100644 --- a/app/services/group_message.rb +++ b/app/services/group_message.rb @@ -78,7 +78,10 @@ class GroupMessage begin h = { base_url: Discourse.base_url }.merge(@opts[:message_params] || {}) if @opts[:user] - h.merge!(username: @opts[:user].username, user_url: user_path(@opts[:user].username)) + h.merge!( + username: @opts[:user].username, + user_url: user_path(@opts[:user].encoded_username(lower: true)), + ) end h end diff --git a/app/views/about/index.html.erb b/app/views/about/index.html.erb index 52bd1a5b9bb..a9219b05e4f 100644 --- a/app/views/about/index.html.erb +++ b/app/views/about/index.html.erb @@ -14,8 +14,8 @@
<% @about.admins.each do |user| %>
- - + + @@ -35,8 +35,8 @@
<% @about.moderators.each do |user| %>
- - + + diff --git a/spec/requests/about_controller_spec.rb b/spec/requests/about_controller_spec.rb index eb719ae9f7d..73bda70105b 100644 --- a/spec/requests/about_controller_spec.rb +++ b/spec/requests/about_controller_spec.rb @@ -38,6 +38,14 @@ RSpec.describe AboutController do expect(response.status).to eq(200) expect(response.body).to include("/u/anadminuser") end + + it "supports unicode usernames" do + SiteSetting.unicode_usernames = true + Fabricate(:admin, username: "martínez") + get "/about", headers: { "HTTP_USER_AGENT" => "Googlebot" } + expect(response.status).to eq(200) + expect(response.body).to include("/u/mart%25C3%25ADnez") + end end it "serializes stats when 'Guardian#can_see_about_stats?' is true" do diff --git a/spec/services/group_message_spec.rb b/spec/services/group_message_spec.rb index 4cd007becfc..76a4011ddb8 100644 --- a/spec/services/group_message_spec.rb +++ b/spec/services/group_message_spec.rb @@ -7,8 +7,8 @@ RSpec.describe GroupMessage do let(:moderators_group) { Group[:moderators].name } - let!(:admin) { Fabricate.build(:admin, id: 999) } - let!(:user) { Fabricate.build(:user, id: 111) } + fab!(:admin) + fab!(:user) before { Discourse.stubs(:system_user).returns(admin) } @@ -57,11 +57,10 @@ RSpec.describe GroupMessage do end describe "message_params" do - let(:user) { Fabricate.build(:user, id: 123_123) } shared_examples "common message params for group messages" do it "returns the correct params" do expect(message_params[:username]).to eq(user.username) - expect(message_params[:user_url]).to be_present + expect(message_params[:user_url]).to eq("/u/#{user.username}") end end @@ -87,8 +86,6 @@ RSpec.describe GroupMessage do GroupMessage.new(moderators_group, :user_automatically_silenced, user: user) end - let(:user) { Fabricate.build(:user, id: 123_123) } - before do PostCreator.stubs(:create).returns(stub_everything) group_message.stubs(:sent_recently_key).returns("the_key")