Fix `SocialHelper::TumblrMethods` tests so they work anywhere

This commit is contained in:
Andreas Nedbal 2021-12-27 14:15:19 +01:00 committed by Andreas Nedbal
parent 719e393ed1
commit 8dd14e4a05
1 changed files with 16 additions and 2 deletions

View File

@ -8,6 +8,20 @@ describe SocialHelper::TumblrMethods, :type => :helper do
content: 'aaaa',
question_content: 'q') }
before do
stub_const("APP_CONFIG", {
'hostname' => 'example.com',
'anonymous_name' => 'Anonymous',
'https' => true,
'items_per_page' => 5,
'sharing' => {
'tumblr' => {
'consumer_key' => 'AAA',
}
}
})
end
describe '#tumblr_title' do
context 'Asker is anonymous' do
subject { tumblr_title(answer) }
@ -36,7 +50,7 @@ describe SocialHelper::TumblrMethods, :type => :helper do
subject { tumblr_body(answer) }
it 'should return a proper body' do
expect(subject).to eq("aaaa\n\n[Smile or comment on the answer here](https://justask.rrerr.net/#{answer.user.screen_name}/a/#{answer.id})")
expect(subject).to eq("aaaa\n\n[Smile or comment on the answer here](https://example.com/#{answer.user.screen_name}/a/#{answer.id})")
end
end
@ -44,7 +58,7 @@ describe SocialHelper::TumblrMethods, :type => :helper do
subject { tumblr_share_url(answer) }
it 'should return a proper share link' do
expect(subject).to eq("https://www.tumblr.com/widgets/share/tool?shareSource=legacy&posttype=text&title=#{CGI.escape(tumblr_title(answer))}&url=#{CGI.escape("https://justask.rrerr.net/#{answer.user.screen_name}/a/#{answer.id}")}&caption=&content=#{CGI.escape(tumblr_body(answer))}")
expect(subject).to eq("https://www.tumblr.com/widgets/share/tool?shareSource=legacy&posttype=text&title=#{CGI.escape(tumblr_title(answer))}&url=#{CGI.escape("https://example.com/#{answer.user.screen_name}/a/#{answer.id}")}&caption=&content=#{CGI.escape(tumblr_body(answer))}")
end
end
end