Improvements/adjustments for Mastodon integration #185

Merged
raucao merged 3 commits from chore/mastodon into master 2024-03-29 05:24:11 +00:00
2 changed files with 9 additions and 1 deletions
Showing only changes of commit 0367450c4b - Show all commits

View File

@@ -131,7 +131,7 @@ class User < ApplicationRecord
def mastodon_address
return nil unless Setting.mastodon_enabled?
"#{self.cn}@#{Setting.mastodon_address_domain}"
"#{self.cn.gsub("-", "_")}@#{Setting.mastodon_address_domain}"
end
def valid_attribute?(attribute_name)

View File

@@ -41,6 +41,14 @@ RSpec.describe User, type: :model do
expect(user.mastodon_address).to eq("jimmy@kosmos.social")
end
end
describe "username contains hyphen/dash" do
let(:jammy) { build :user, cn: "jammy-jellyfish", ou: "kosmos.org" }
it "returns the user address" do
expect(jammy.mastodon_address).to eq("jammy_jellyfish@kosmos.org")
end
end
end
end