Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBenjamin Neff <benjamin@coding4coffee.ch>2022-07-13 06:05:58 +0300
committerBenjamin Neff <benjamin@coding4coffee.ch>2022-07-16 05:34:07 +0300
commitdd3bc39c97e6b6d17646c8cbf33e13c252e0c2e4 (patch)
tree41be18c4c3244506b4abe7a7bc023fa1e5c139ae /spec
parent3c02a1f067b718e2d1806b65eef5bc9d9f446757 (diff)
Render markdown to html for notifications
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/notifier_helper_spec.rb28
-rw-r--r--spec/lib/diaspora/message_renderer_spec.rb8
-rw-r--r--spec/mailers/notifier_spec.rb6
3 files changed, 23 insertions, 19 deletions
diff --git a/spec/helpers/notifier_helper_spec.rb b/spec/helpers/notifier_helper_spec.rb
index 946753aa8..6f0b6a795 100644
--- a/spec/helpers/notifier_helper_spec.rb
+++ b/spec/helpers/notifier_helper_spec.rb
@@ -5,18 +5,23 @@
# the COPYRIGHT file.
describe NotifierHelper, :type => :helper do
- describe '#post_message' do
+ describe "#post_message" do
before do
# post for markdown test
@markdown_post = FactoryGirl.create(:status_message,
- text: "[link](http://diasporafoundation.org) **bold text** *other text*", public: true)
- @striped_markdown_post = "link (http://diasporafoundation.org) bold text other text"
+ text: "[link](https://diasporafoundation.org) **bold text** *other text*",
+ public: true)
+ @striped_markdown_post = "link (https://diasporafoundation.org) bold text other text"
end
- it 'strip markdown in the post' do
+ it "strip markdown in the post" do
expect(post_message(@markdown_post)).to eq(@striped_markdown_post)
end
+ it "renders markdown as html" do
+ expect(post_message(@markdown_post, html: true)).to include("<a href=\"https://diasporafoundation.org\">link</a>")
+ end
+
it "falls back to the title if the post has no text" do
photo = FactoryGirl.build(:photo, public: true)
photo_post = FactoryGirl.build(:status_message, author: photo.author, text: "", photos: [photo], public: true)
@@ -32,13 +37,13 @@ describe NotifierHelper, :type => :helper do
end
end
- describe '#comment_message' do
+ describe "#comment_message" do
before do
# comment for markdown test
@markdown_comment = FactoryGirl.create(:comment)
@markdown_comment.post.public = true
- @markdown_comment.text = "[link](http://diasporafoundation.org) **bold text** *other text*"
- @striped_markdown_comment = "link (http://diasporafoundation.org) bold text other text"
+ @markdown_comment.text = "[link](https://diasporafoundation.org) **bold text** *other text*"
+ @striped_markdown_comment = "link (https://diasporafoundation.org) bold text other text"
# comment for limited post
@limited_comment = FactoryGirl.create(:comment)
@@ -46,11 +51,16 @@ describe NotifierHelper, :type => :helper do
@limited_comment.text = "This is top secret comment. Shhhhhhhh!!!"
end
- it 'strip markdown in the comment' do
+ it "strip markdown in the comment" do
expect(comment_message(@markdown_comment)).to eq(@striped_markdown_comment)
end
- it 'hides the private content' do
+ it "renders markdown as html" do
+ expect(comment_message(@markdown_comment, html: true))
+ .to include("<a href=\"https://diasporafoundation.org\">link</a>")
+ end
+
+ it "hides the private content" do
expect(comment_message(@limited_comment)).not_to include("secret comment")
end
end
diff --git a/spec/lib/diaspora/message_renderer_spec.rb b/spec/lib/diaspora/message_renderer_spec.rb
index 11bffbbcb..44dc9e2d8 100644
--- a/spec/lib/diaspora/message_renderer_spec.rb
+++ b/spec/lib/diaspora/message_renderer_spec.rb
@@ -78,12 +78,6 @@ describe Diaspora::MessageRenderer do
end
context 'linking all mentions' do
- it 'makes plain links for people not in the post aspects' do
- message = message("@{Bob; #{bob.person.diaspora_handle}}", link_all_mentions: true).html
- expect(message).to_not include 'hovercard'
- expect(message).to include "/people/#{bob.person.guid}"
- end
-
it "makes no hovercards if they're disabled" do
message = message(
"@{Bob; #{bob.person.diaspora_handle}}",
@@ -91,7 +85,7 @@ describe Diaspora::MessageRenderer do
disable_hovercards: true
).html
expect(message).to_not include 'hovercard'
- expect(message).to include "/people/#{bob.person.guid}"
+ expect(message).to include AppConfig.url_to("/people/#{bob.person.guid}")
end
end
end
diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb
index 7e0830f41..8129b1d36 100644
--- a/spec/mailers/notifier_spec.rb
+++ b/spec/mailers/notifier_spec.rb
@@ -555,9 +555,9 @@ describe Notifier, type: :mailer do
describe "hashtags" do
it "escapes hashtags" do
- mails = Notifier.admin("#Welcome to bureaucracy!", [bob])
- expect(mails.length).to eq(1)
- mail = mails.first
+ status = FactoryGirl.create(:status_message, author: alice.person, text: "#Welcome to bureaucracy!", public: true)
+ like = status.likes.create!(author: bob.person)
+ mail = Notifier.send_notification("liked", alice.id, like.author.id, like.id)
expect(mail.body.encoded).to match(
"<p><a href=\"#{AppConfig.url_to(tag_path('welcome'))}\">#Welcome</a> to bureaucracy!</p>"
)