parent
c312ff00f3
commit
5c444e62be
4 changed files with 19 additions and 18 deletions
|
|
@ -32,7 +32,7 @@ module Diaspora::Mentionable
|
||||||
name, diaspora_id = mention_attrs(match_str)
|
name, diaspora_id = mention_attrs(match_str)
|
||||||
person = people.find {|p| p.diaspora_handle == diaspora_id }
|
person = people.find {|p| p.diaspora_handle == diaspora_id }
|
||||||
|
|
||||||
ERB::Util.h(MentionsInternal.mention_link(person, name, diaspora_id, opts))
|
"@#{ERB::Util.h(MentionsInternal.mention_link(person, name, diaspora_id, opts))}"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ module Diaspora::Mentionable
|
||||||
if person && allowed_people.include?(person.id)
|
if person && allowed_people.include?(person.id)
|
||||||
match_str
|
match_str
|
||||||
else
|
else
|
||||||
MentionsInternal.profile_link(person, name, diaspora_id)
|
"@#{MentionsInternal.profile_link(person, name, diaspora_id)}"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ STR
|
||||||
fmt_msg = Diaspora::Mentionable.format(test_text_with_names, people)
|
fmt_msg = Diaspora::Mentionable.format(test_text_with_names, people)
|
||||||
|
|
||||||
[people, names].transpose.each do |person, name|
|
[people, names].transpose.each do |person, name|
|
||||||
expect(fmt_msg).to include person_link(person, class: "mention hovercardable", display_name: name)
|
link = person_link(person, class: "mention hovercardable", display_name: name)
|
||||||
|
expect(fmt_msg).to include "@#{link}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -52,7 +53,8 @@ STR
|
||||||
fmt_msg = Diaspora::Mentionable.format(test_text_without_names, people)
|
fmt_msg = Diaspora::Mentionable.format(test_text_without_names, people)
|
||||||
|
|
||||||
people.each do |person|
|
people.each do |person|
|
||||||
expect(fmt_msg).to include person_link(person, class: "mention hovercardable", display_name: person.name)
|
link = person_link(person, class: "mention hovercardable", display_name: person.name)
|
||||||
|
expect(fmt_msg).to include "@#{link}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -80,7 +82,7 @@ STR
|
||||||
fmt_msg = Diaspora::Mentionable.format(test_text_with_names, people, plain_text: true)
|
fmt_msg = Diaspora::Mentionable.format(test_text_with_names, people, plain_text: true)
|
||||||
|
|
||||||
names.each do |name|
|
names.each do |name|
|
||||||
expect(fmt_msg).to include CGI.escapeHTML(name)
|
expect(fmt_msg).to include "@#{CGI.escapeHTML(name)}"
|
||||||
end
|
end
|
||||||
expect(fmt_msg).not_to include "<a", "</a>", "hovercardable"
|
expect(fmt_msg).not_to include "<a", "</a>", "hovercardable"
|
||||||
end
|
end
|
||||||
|
|
@ -89,9 +91,9 @@ STR
|
||||||
it "leaves the names of people that cannot be found" do
|
it "leaves the names of people that cannot be found" do
|
||||||
test_txt_plain = <<-STR
|
test_txt_plain = <<-STR
|
||||||
This post contains a lot of mentions
|
This post contains a lot of mentions
|
||||||
one Alice A,
|
one @Alice A,
|
||||||
two Bob B and finally
|
two @Bob B and finally
|
||||||
three "Eve> E.
|
three @"Eve> E.
|
||||||
STR
|
STR
|
||||||
|
|
||||||
fmt_msg = Diaspora::Mentionable.format(test_text_with_names, [])
|
fmt_msg = Diaspora::Mentionable.format(test_text_with_names, [])
|
||||||
|
|
@ -101,9 +103,9 @@ STR
|
||||||
it "uses the diaspora ID when the person cannot be found" do
|
it "uses the diaspora ID when the person cannot be found" do
|
||||||
test_txt_plain = <<-STR
|
test_txt_plain = <<-STR
|
||||||
This post contains a lot of mentions
|
This post contains a lot of mentions
|
||||||
one #{people[0].diaspora_handle},
|
one @#{people[0].diaspora_handle},
|
||||||
two #{people[1].diaspora_handle} and finally
|
two @#{people[1].diaspora_handle} and finally
|
||||||
three #{people[2].diaspora_handle}.
|
three @#{people[2].diaspora_handle}.
|
||||||
STR
|
STR
|
||||||
|
|
||||||
fmt_msg = Diaspora::Mentionable.format(test_text_without_names, [])
|
fmt_msg = Diaspora::Mentionable.format(test_text_without_names, [])
|
||||||
|
|
@ -180,8 +182,7 @@ STR
|
||||||
user_a.aspects.where(name: "generic").first.contacts.map(&:person_id)
|
user_a.aspects.where(name: "generic").first.contacts.map(&:person_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(txt).to include("user C")
|
expect(txt).to include("@[user C](#{local_or_remote_person_path(user_c.person)}")
|
||||||
expect(txt).to include(local_or_remote_person_path(user_c.person))
|
|
||||||
expect(txt).not_to include("href")
|
expect(txt).not_to include("href")
|
||||||
expect(txt).not_to include(mention)
|
expect(txt).not_to include(mention)
|
||||||
end
|
end
|
||||||
|
|
@ -203,7 +204,7 @@ STR
|
||||||
mention = "@{non_existing_user@example.org}"
|
mention = "@{non_existing_user@example.org}"
|
||||||
txt = Diaspora::Mentionable.filter_people("mentioning #{mention}", [])
|
txt = Diaspora::Mentionable.filter_people("mentioning #{mention}", [])
|
||||||
|
|
||||||
expect(txt).to eq "mentioning non_existing_user@example.org"
|
expect(txt).to eq "mentioning @non_existing_user@example.org"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -195,17 +195,17 @@ describe Diaspora::MessageRenderer do
|
||||||
context "with mention" do
|
context "with mention" do
|
||||||
it "contains the name of the mentioned person" do
|
it "contains the name of the mentioned person" do
|
||||||
msg = message("@{#{alice.diaspora_handle}} is cool", mentioned_people: alice.person)
|
msg = message("@{#{alice.diaspora_handle}} is cool", mentioned_people: alice.person)
|
||||||
expect(msg.plain_text_without_markdown).to eq "#{alice.name} is cool"
|
expect(msg.plain_text_without_markdown).to eq "@#{alice.name} is cool"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uses the name from mention when the mention contains a name" do
|
it "uses the name from mention when the mention contains a name" do
|
||||||
msg = message("@{Alice; #{alice.diaspora_handle}} is cool", mentioned_people: alice.person)
|
msg = message("@{Alice; #{alice.diaspora_handle}} is cool", mentioned_people: alice.person)
|
||||||
expect(msg.plain_text_without_markdown).to eq "Alice is cool"
|
expect(msg.plain_text_without_markdown).to eq "@Alice is cool"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uses the diaspora ID when the person cannot be found" do
|
it "uses the diaspora ID when the person cannot be found" do
|
||||||
msg = message("@{#{alice.diaspora_handle}} is cool", mentioned_people: [])
|
msg = message("@{#{alice.diaspora_handle}} is cool", mentioned_people: [])
|
||||||
expect(msg.plain_text_without_markdown).to eq "#{alice.diaspora_handle} is cool"
|
expect(msg.plain_text_without_markdown).to eq "@#{alice.diaspora_handle} is cool"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ describe Publisher do
|
||||||
describe '#text' do
|
describe '#text' do
|
||||||
it 'is a formatted version of the prefill' do
|
it 'is a formatted version of the prefill' do
|
||||||
p = Publisher.new(alice, prefill: "@{alice; #{alice.diaspora_handle}}")
|
p = Publisher.new(alice, prefill: "@{alice; #{alice.diaspora_handle}}")
|
||||||
expect(p.text).to eq("alice")
|
expect(p.text).to eq("@alice")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue