From 0f04414a4f56d1d2c2ab5e131b70616f4210624e Mon Sep 17 00:00:00 2001 From: cmrd Senya Date: Wed, 9 Mar 2016 23:14:16 +0300 Subject: [PATCH] Fix usage of hard-coded pod URI in rspec testsuite --- spec/helpers/posts_helper_spec.rb | 2 +- spec/lib/diaspora/markdownify_email_spec.rb | 13 ++++++++++--- spec/lib/diaspora/taggable_spec.rb | 8 +++++--- spec/mailers/notifier_spec.rb | 4 +++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/spec/helpers/posts_helper_spec.rb b/spec/helpers/posts_helper_spec.rb index d1624f8dc..a6ca72c07 100644 --- a/spec/helpers/posts_helper_spec.rb +++ b/spec/helpers/posts_helper_spec.rb @@ -32,7 +32,7 @@ describe PostsHelper, :type => :helper do end it "returns an iframe containing the post" do - expect(post_iframe_url(@post.id)).to include "src='http://localhost:9887#{post_path(@post)}'" + expect(post_iframe_url(@post.id)).to include "src='#{AppConfig.url_to(post_path(@post))}'" end end end diff --git a/spec/lib/diaspora/markdownify_email_spec.rb b/spec/lib/diaspora/markdownify_email_spec.rb index 6c4b69e17..5d4ae7186 100644 --- a/spec/lib/diaspora/markdownify_email_spec.rb +++ b/spec/lib/diaspora/markdownify_email_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe Diaspora::Markdownify::Email do + include Rails.application.routes.url_helpers + describe '#preprocess' do before do @html = Diaspora::Markdownify::Email.new @@ -8,12 +10,14 @@ describe Diaspora::Markdownify::Email do it 'should autolink a hashtag' do markdownified = @html.preprocess("#tag") - expect(markdownified).to eq("[#tag](http://localhost:9887/tags/tag)") + expect(markdownified).to eq("[#tag](#{AppConfig.url_to(tag_path('tag'))})") end it 'should autolink multiple hashtags' do markdownified = @html.preprocess("oh #l #loL") - expect(markdownified).to eq("oh [#l](http://localhost:9887/tags/l) [#loL](http://localhost:9887/tags/lol)") + expect(markdownified).to eq( + "oh [#l](#{AppConfig.url_to(tag_path('l'))}) [#loL](#{AppConfig.url_to(tag_path('lol'))})" + ) end it 'should not autolink headers' do @@ -30,7 +34,10 @@ describe Diaspora::Markdownify::Email do it 'should render the message' do rendered = @markdown.render(@sample_text).strip - expect(rendered).to eq("

Header

\n\n

#messages containing #hashtags should render properly

") + expect(rendered).to eq( + "

Header

\n\n

#messages\ + containing #hashtags should render properly

" + ) end end end diff --git a/spec/lib/diaspora/taggable_spec.rb b/spec/lib/diaspora/taggable_spec.rb index bd4ab617f..bbc557d6e 100644 --- a/spec/lib/diaspora/taggable_spec.rb +++ b/spec/lib/diaspora/taggable_spec.rb @@ -1,6 +1,8 @@ require "spec_helper" describe Diaspora::Taggable do + include Rails.application.routes.url_helpers + describe "#format_tags" do context "when there are no tags in the text" do it "returns the input text" do @@ -40,19 +42,19 @@ describe Diaspora::Taggable do context "when there is a tag in the text" do it "autolinks and normalizes the hashtag" do text = Diaspora::Taggable.format_tags_for_mail("There is a #hashTag.") - expect(text).to eq("There is a [#hashTag](http://localhost:9887/tags/hashtag).") + expect(text).to eq("There is a [#hashTag](#{AppConfig.url_to(tag_path('hashtag'))}).") end it "autolinks #<3" do text = Diaspora::Taggable.format_tags_for_mail("#<3") - expect(text).to eq("[#<3](http://localhost:9887/tags/%3C3)") + expect(text).to eq("[#<3](#{AppConfig.url_to(tag_path('<3'))})") end end context "with multiple tags" do it "autolinks the hashtags" do text = Diaspora::Taggable.format_tags_for_mail("#l #lol") - expect(text).to eq("[#l](http://localhost:9887/tags/l) [#lol](http://localhost:9887/tags/lol)") + expect(text).to eq("[#l](#{AppConfig.url_to(tag_path('l'))}) [#lol](#{AppConfig.url_to(tag_path('lol'))})") end end end diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 7ba777de8..c3f80f5d2 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -444,7 +444,9 @@ describe Notifier, type: :mailer do mails = Notifier.admin("#Welcome to bureaucracy!", [bob]) expect(mails.length).to eq(1) mail = mails.first - expect(mail.body.encoded).to match "

#Welcome to bureaucracy!

" + expect(mail.body.encoded).to match( + "

#Welcome to bureaucracy!

" + ) end end