Fix answers from other stackexchange sites have the wrong link (#4615) [ci skip]

This commit is contained in:
Huynh Tan 2019-10-31 02:01:29 +07:00 committed by Mac Siri
parent fba9446e17
commit b6a731276e
3 changed files with 36 additions and 23 deletions

View file

@ -5,7 +5,7 @@ class StackexchangeTag < LiquidTagBase
# Filter codes come from the example tools in the docs. For example: https://api.stackexchange.com/docs/posts-by-ids
FILTERS = {
"post" => "!3tz1WbZW5JxrG-f99",
"answer" => "!Fcb(61J.xH9ZW2D7KF1bbM_J7X",
"answer" => "!.Fjr38AQkcvWfJTF-2exSL50At_pT",
"question" => "!*1SgQGDOL9bPBHULz9sKS.y6qv7V9fYNszvdhDuv5",
"site" => "!mWxO_PNa4i"
}.freeze

View file

@ -24,11 +24,15 @@ RSpec.describe StackexchangeTag, type: :liquid_template, vcr: vcr_option do
it "renders basic html" do
liquid = generate_new_liquid(valid_id)
expect(liquid.render).to include("ltag__stackexchange")
expected_answer_url = "https://stackoverflow.com/questions/57496168/use-where-and-limit-to-child-in-foreach"
expect(liquid.render).to include("<a href=\"#{expected_answer_url}\"")
end
it "renders basic exchange html" do
liquid = generate_exchange_liquid(exchange_id)
expect(liquid.render).to include("stackexchange-logo")
expected_answer_url = "https://askubuntu.com/questions/885432/help-setting-up-sshfs/1163633#1163633"
expect(liquid.render).to include("<a href=\"#{expected_answer_url}\"")
end
it "rejects invalid id" do

View file

@ -31,14 +31,14 @@ http_interactions:
X-Content-Type-Options:
- nosniff
Date:
- Wed, 14 Aug 2019 16:26:27 GMT
- Sun, 27 Oct 2019 10:55:25 GMT
Content-Length:
- '134'
- '136'
body:
encoding: ASCII-8BIT
string: '{"items":[{"last_activity_date":1565796374,"post_type":"question","post_id":57496168}],"has_more":false,"quota_max":300,"quota_remaining":97}'
http_version:
recorded_at: Wed, 14 Aug 2019 16:26:28 GMT
string: '{"items":[{"last_activity_date":1565806685,"post_type":"question","post_id":57496168}],"has_more":false,"quota_max":10000,"quota_remaining":9960}'
http_version:
recorded_at: Sun, 27 Oct 2019 10:55:25 GMT
- request:
method: get
uri: https://api.stackexchange.com/2.2/questions/57496168?filter=!*1SgQGDOL9bPBHULz9sKS.y6qv7V9fYNszvdhDuv5&key=&site=stackoverflow
@ -70,20 +70,20 @@ http_interactions:
X-Content-Type-Options:
- nosniff
Date:
- Wed, 14 Aug 2019 16:26:27 GMT
- Sun, 27 Oct 2019 10:55:26 GMT
Content-Length:
- '516'
- '522'
body:
encoding: ASCII-8BIT
string: '{"items":[{"tags":["laravel","foreach","view","relationship"],"comment_count":1,"view_count":34,"answer_count":3,"score":0,"last_activity_date":1565796374,"creation_date":1565790943,"question_id":57496168,"link":"https://stackoverflow.com/questions/57496168/use-where-and-limit-to-child-in-foreach","title":"Use
string: '{"items":[{"tags":["laravel","foreach","view","relationship"],"comment_count":1,"view_count":59,"answer_count":4,"score":0,"last_activity_date":1565806685,"creation_date":1565790943,"question_id":57496168,"link":"https://stackoverflow.com/questions/57496168/use-where-and-limit-to-child-in-foreach","title":"Use
&quot;where&quot; and &quot;limit&quot; to child in @foreach","body":"<p>I
want to display all user''s profile into views and they posts. It''s pretty
simple:</p>\n\n<pre><code>@foreach($profiles as $profile)\n{{ $profile-&gt;name
}}\n @foreach($profile-&gt;posts as $post)\n {{$post-&gt;title}}\n @endforeach\n@endforeach\n</code></pre>\n\n<p>But
I want to display only the latests posts (->orderBy(''created_at'', ''desc'')->limit(4)
) and only accepted posts (->where(''accept'', 1)). How can I do that?</p>\n"}],"has_more":false,"quota_max":300,"quota_remaining":97}'
http_version:
recorded_at: Wed, 14 Aug 2019 16:26:28 GMT
) and only accepted posts (->where(''accept'', 1)). How can I do that?</p>\n"}],"has_more":false,"quota_max":10000,"quota_remaining":9959}'
http_version:
recorded_at: Sun, 27 Oct 2019 10:55:26 GMT
- request:
method: get
uri: https://api.stackexchange.com/2.2/posts/1163633?filter=!3tz1WbZW5JxrG-f99&key=&site=askubuntu
@ -115,17 +115,17 @@ http_interactions:
X-Content-Type-Options:
- nosniff
Date:
- Wed, 14 Aug 2019 16:26:27 GMT
- Sun, 27 Oct 2019 10:56:06 GMT
Content-Length:
- '145'
- '134'
body:
encoding: ASCII-8BIT
string: '{"items": [{"last_activity_date": 1565109531,"post_type": "answer","post_id": 1163633}],"has_more": false,"quota_max": 300,"quota_remaining": 94}'
http_version:
recorded_at: Wed, 14 Aug 2019 16:26:28 GMT
string: '{"items":[{"last_activity_date":1565109531,"post_type":"answer","post_id":1163633}],"has_more":false,"quota_max":10000,"quota_remaining":9958}'
http_version:
recorded_at: Sun, 27 Oct 2019 10:56:07 GMT
- request:
method: get
uri: https://api.stackexchange.com/2.2/answers/1163633?filter=!Fcb(61J.xH9ZW2D7KF1bbM_J7X&key=&site=askubuntu
uri: https://api.stackexchange.com/2.2/answers/1163633?filter=!.Fjr38AQkcvWfJTF-2exSL50At_pT&key=&site=askubuntu
body:
encoding: US-ASCII
string: ''
@ -154,12 +154,21 @@ http_interactions:
X-Content-Type-Options:
- nosniff
Date:
- Wed, 14 Aug 2019 16:26:27 GMT
- Sun, 27 Oct 2019 10:56:08 GMT
Content-Length:
- '1024'
- '599'
body:
encoding: ASCII-8BIT
string: '{"items": [{"tags": [ ],"comment_count": 3,"is_accepted": false,"score": 1,"last_activity_date": 1565109531,"last_edit_date": 1565109531,"creation_date": 1565033637,"answer_id": 1163633,"question_id": 885432,"title": "Help setting up sshfs","body": "<p>As you are getting the following error message:</p> <blockquote> <p>gpasswd: groupfuse does not exist in /etc/group</p> </blockquote> <p>This indicates that there is no such group, yet!<br> Please test if there is and subsequently alleviate the problem as described below:</p> <ol> <li><p>check if there is a fuse group with: </p> <pre><code>cat /etc/group | grep fuse </code></pre></li> <li><p>If there is it would look like: </p> <pre><code>fuse:x:1001: </code></pre></li> <li><p>If there isnt, add one like this: </p> <pre><code>sudo groupadd fuse </code></pre></li> <li><p>At this point you can add yourself to the group with: </p> <pre><code>sudo usermod -a -G fuse your_username </code></pre></li> </ol> "}],"has_more": false,"quota_max": 300,"quota_remaining": 93}'
http_version:
recorded_at: Wed, 14 Aug 2019 16:26:28 GMT
string: '{"items":[{"tags":[],"comment_count":3,"is_accepted":false,"score":1,"last_activity_date":1565109531,"last_edit_date":1565109531,"creation_date":1565033637,"answer_id":1163633,"question_id":885432,"link":"https://askubuntu.com/questions/885432/help-setting-up-sshfs/1163633#1163633","title":"Help
setting up sshfs","body":"<p>As you are getting the following error message:</p>\n\n<blockquote>\n <p>gpasswd:
group''fuse'' does not exist in /etc/group</p>\n</blockquote>\n\n<p>This indicates
that there is no such group, yet!<br>\nPlease test if there is and subsequently
alleviate the problem as described below:</p>\n\n<ol>\n<li><p>check if there
is a fuse group with: </p>\n\n<pre><code>cat /etc/group | grep ''fuse'' \n</code></pre></li>\n<li><p>If
there is it would look like: </p>\n\n<pre><code>fuse:x:1001: \n</code></pre></li>\n<li><p>If
there isn''t, add one like this: </p>\n\n<pre><code>sudo groupadd fuse \n</code></pre></li>\n<li><p>At
this point you can add yourself to the group with: </p>\n\n<pre><code>sudo
usermod -a -G fuse your_username \n</code></pre></li>\n</ol>\n"}],"has_more":false,"quota_max":10000,"quota_remaining":9957}'
http_version:
recorded_at: Sun, 27 Oct 2019 10:56:08 GMT
recorded_with: VCR 5.0.0