diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/delete.xml | 39 | ||||
-rw-r--r-- | test/fixtures/httpoison_mock/sakamoto.atom | 1 | ||||
-rw-r--r-- | test/fixtures/httpoison_mock/sakamoto_eal_feed.atom | 1 | ||||
-rw-r--r-- | test/support/factory.ex | 4 | ||||
-rw-r--r-- | test/support/httpoison_mock.ex | 22 | ||||
-rw-r--r-- | test/upload_test.exs | 5 | ||||
-rw-r--r-- | test/user_test.exs | 69 | ||||
-rw-r--r-- | test/web/ostatus/activity_representer_test.exs | 21 | ||||
-rw-r--r-- | test/web/ostatus/incoming_documents/delete_handling_test.exs | 28 | ||||
-rw-r--r-- | test/web/ostatus/ostatus_test.exs | 11 | ||||
-rw-r--r-- | test/web/twitter_api/twitter_api_controller_test.exs | 36 | ||||
-rw-r--r-- | test/web/twitter_api/twitter_api_test.exs | 13 | ||||
-rw-r--r-- | test/web/twitter_api/twitter_api_utils_test.exs | 2 | ||||
-rw-r--r-- | test/web/twitter_api/views/user_view_test.exs | 2 |
14 files changed, 244 insertions, 10 deletions
diff --git a/test/fixtures/delete.xml b/test/fixtures/delete.xml new file mode 100644 index 000000000..731e1c204 --- /dev/null +++ b/test/fixtures/delete.xml @@ -0,0 +1,39 @@ +<?xml version="1.0"?> +<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:media="http://purl.org/syndication/atommedia" xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:mastodon="http://mastodon.social/schema/1.0"> + <id>https://mastodon.sdf.org/users/snowdusk.atom</id> + <title>snowdusk</title> + <subtitle>Amateur live performance DJ/radio DJ on SDF's underground Internet radio http://aNONradio.net (LIVE Sat Sun Mon Tue 23:00-24:00 UTC) - http://snowdusk.sdf.org</subtitle> + <updated>2017-06-17T04:14:34Z</updated> + <logo>https://mastodon.sdf.org/system/accounts/avatars/000/000/002/original/405a7652d5f60449.jpg?1497672873</logo> + <author> + <id>https://mastodon.sdf.org/users/snowdusk</id> + <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type> + <uri>https://mastodon.sdf.org/users/snowdusk</uri> + <name>snowdusk</name> + <email>snowdusk@mastodon.sdf.org</email> + <summary type="html"><p>Amateur live performance DJ/radio DJ on SDF&apos;s underground Internet radio <a href="http://anonradio.net/" rel="nofollow noopener" target="_blank"><span class="invisible">http://</span><span class="">anonradio.net/</span><span class="invisible"></span></a> (LIVE Sat Sun Mon Tue 23:00-24:00 UTC) - <a href="http://snowdusk.sdf.org/" rel="nofollow noopener" target="_blank"><span class="invisible">http://</span><span class="">snowdusk.sdf.org/</span><span class="invisible"></span></a></p></summary> + <link rel="alternate" type="text/html" href="https://mastodon.sdf.org/@snowdusk"/> + <link rel="avatar" type="image/jpeg" media:width="120" media:height="120" href="https://mastodon.sdf.org/system/accounts/avatars/000/000/002/original/405a7652d5f60449.jpg?1497672873"/> + <link rel="header" type="image/jpeg" media:width="700" media:height="335" href="https://mastodon.sdf.org/system/accounts/headers/000/000/002/original/f1e9b0fb21b4e5a0.jpeg?1495793472"/> + <poco:preferredUsername>snowdusk</poco:preferredUsername> + <poco:displayName>snowdusk</poco:displayName> + <poco:note>Amateur live performance DJ/radio DJ on SDF's underground Internet radio http://aNONradio.net (LIVE Sat Sun Mon Tue 23:00-24:00 UTC) - http://snowdusk.sdf.org</poco:note> + <mastodon:scope>public</mastodon:scope> + </author> + <link rel="alternate" type="text/html" href="https://mastodon.sdf.org/@snowdusk"/> + <link rel="self" type="application/atom+xml" href="https://mastodon.sdf.org/users/snowdusk.atom"/> + <link rel="next" type="application/atom+xml" href="https://mastodon.sdf.org/users/snowdusk.atom?max_id=7592"/> + <link rel="hub" href="https://mastodon.sdf.org/api/push"/> + <link rel="salmon" href="https://mastodon.sdf.org/api/salmon/2"/> + <entry> + <id>tag:mastodon.sdf.org,2017-06-10:objectId=310513:objectType=Status</id> + <published>2017-06-10T22:02:31Z</published> + <updated>2017-06-10T22:02:31Z</updated> + <title>snowdusk deleted status</title> + <activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type> + <activity:verb>http://activitystrea.ms/schema/1.0/delete</activity:verb> + <content>Deleted status</content> + <link rel="alternate" type="text/html" href="https://mastodon.sdf.org/users/snowdusk/updates/7782"/> + <link rel="self" type="application/atom+xml" href="https://mastodon.sdf.org/users/snowdusk/updates/7782.atom"/> + </entry> +</feed> diff --git a/test/fixtures/httpoison_mock/sakamoto.atom b/test/fixtures/httpoison_mock/sakamoto.atom new file mode 100644 index 000000000..648946795 --- /dev/null +++ b/test/fixtures/httpoison_mock/sakamoto.atom @@ -0,0 +1 @@ +<?xml version="1.0"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0"><activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb><id>https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056</id><title>New note by eal</title><content type="html"><a href='https://shitposter.club/user/5381'>@shpuld</a> <a href='https://pleroma.hjkos.com/users/hj'>@hj</a> IM NOT GAY DAD</content><published>2017-08-04T12:51:26.130592Z</published><updated>2017-08-04T12:51:26.130592Z</updated><ostatus:conversation>https://pleroma.hjkos.com/contexts/53093c74-2100-4bf4-aac6-66d1973d03ef</ostatus:conversation><link ref="https://pleroma.hjkos.com/contexts/53093c74-2100-4bf4-aac6-66d1973d03ef" rel="ostatus:conversation"/><link type="application/atom+xml" href="https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056" rel="self"/><link type="text/html" href="https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056" rel="alternate"/><thr:in-reply-to ref="tag:shitposter.club,2017-08-04:noticeId=4027863:objectType=comment" href="https://shitposter.club/notice/4027863"/><author><id>https://social.sakamoto.gq/users/eal</id><activity:object>http://activitystrea.ms/schema/1.0/person</activity:object><uri>https://social.sakamoto.gq/users/eal</uri><poco:preferredUsername>eal</poco:preferredUsername><poco:displayName>坂本</poco:displayName><poco:note>(・ヮ・)</poco:note><name>eal</name><link rel="avatar" href="https://social.sakamoto.gq/media/7646c027-3614-4ee1-93f9-eea8f244a0d7/1A2EFE3153B9C9C3826DB511D043A26597C9F7178C8A4899FBBF808972D1659F.png"/></author><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://shitposter.club/user/5381"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://pleroma.hjkos.com/users/hj"/></entry>
\ No newline at end of file diff --git a/test/fixtures/httpoison_mock/sakamoto_eal_feed.atom b/test/fixtures/httpoison_mock/sakamoto_eal_feed.atom new file mode 100644 index 000000000..9340d9038 --- /dev/null +++ b/test/fixtures/httpoison_mock/sakamoto_eal_feed.atom @@ -0,0 +1 @@ +<?xml version="1.0"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0"><id>https://social.sakamoto.gq/users/eal/feed.atom</id><title>eal's timeline</title><updated>2017-08-04T14:19:12.683854</updated><link rel="hub" href="https://social.sakamoto.gq/push/hub/eal"/><link rel="salmon" href="https://social.sakamoto.gq/users/eal/salmon"/><link rel="self" href="https://social.sakamoto.gq/users/eal/feed.atom" type="application/atom+xml"/><author><id>https://social.sakamoto.gq/users/eal</id><activity:object>http://activitystrea.ms/schema/1.0/person</activity:object><uri>https://social.sakamoto.gq/users/eal</uri><poco:preferredUsername>eal</poco:preferredUsername><poco:displayName>坂本</poco:displayName><poco:note>(・ヮ・)</poco:note><name>eal</name><link rel="avatar" href="https://social.sakamoto.gq/media/7646c027-3614-4ee1-93f9-eea8f244a0d7/1A2EFE3153B9C9C3826DB511D043A26597C9F7178C8A4899FBBF808972D1659F.png"/></author><entry><activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb><id>https://social.sakamoto.gq/objects/b79a1721-23f3-45a5-9610-adb08c2afae5</id><title>New note by eal</title><content type="html">Honestly, I like all smileys that are not emoji.</content><published>2017-08-04T14:19:12.675999Z</published><updated>2017-08-04T14:19:12.675999Z</updated><ostatus:conversation>https://social.sakamoto.gq/contexts/e05ede92-8db9-4963-8b8e-e71a5797d68f</ostatus:conversation><link ref="https://social.sakamoto.gq/contexts/e05ede92-8db9-4963-8b8e-e71a5797d68f" rel="ostatus:conversation"/><link type="application/atom+xml" href="https://social.sakamoto.gq/objects/b79a1721-23f3-45a5-9610-adb08c2afae5" rel="self"/><link type="text/html" href="https://social.sakamoto.gq/objects/b79a1721-23f3-45a5-9610-adb08c2afae5" rel="alternate"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb><id>https://social.sakamoto.gq/objects/45475bf3-2dfc-4d9e-8eae-1f4f86f48982</id><title>New note by eal</title><content type="html">Then again, I like all smileys/emoticons that are not emoji.<br></content><published>2017-08-04T14:19:10.113373Z</published><updated>2017-08-04T14:19:10.113373Z</updated><ostatus:conversation>https://social.sakamoto.gq/contexts/852d1605-4dcb-4ba7-9ba4-dfc37ed62fbc</ostatus:conversation><link ref="https://social.sakamoto.gq/contexts/852d1605-4dcb-4ba7-9ba4-dfc37ed62fbc" rel="ostatus:conversation"/><link type="application/atom+xml" href="https://social.sakamoto.gq/objects/45475bf3-2dfc-4d9e-8eae-1f4f86f48982" rel="self"/><link type="text/html" href="https://social.sakamoto.gq/objects/45475bf3-2dfc-4d9e-8eae-1f4f86f48982" rel="alternate"/><thr:in-reply-to ref="https://social.sakamoto.gq/objects/8f8fd6d6-cc63-40c6-a5d0-1c0e4f919368" href="https://social.sakamoto.gq/objects/8f8fd6d6-cc63-40c6-a5d0-1c0e4f919368"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://social.sakamoto.gq/users/eal"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb><id>https://social.sakamoto.gq/objects/8f8fd6d6-cc63-40c6-a5d0-1c0e4f919368</id><title>New note by eal</title><content type="html">I love the russian-style smiley.</content><published>2017-08-04T14:18:30.478552Z</published><updated>2017-08-04T14:18:30.478552Z</updated><ostatus:conversation>https://social.sakamoto.gq/contexts/852d1605-4dcb-4ba7-9ba4-dfc37ed62fbc</ostatus:conversation><link ref="https://social.sakamoto.gq/contexts/852d1605-4dcb-4ba7-9ba4-dfc37ed62fbc" rel="ostatus:conversation"/><link type="application/atom+xml" href="https://social.sakamoto.gq/objects/8f8fd6d6-cc63-40c6-a5d0-1c0e4f919368" rel="self"/><link type="text/html" href="https://social.sakamoto.gq/objects/8f8fd6d6-cc63-40c6-a5d0-1c0e4f919368" rel="alternate"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/follow</activity:verb><id>https://social.sakamoto.gq/activities/6e69df95-f2ad-4b8e-af4a-e93ff93d64e1</id><title>eal started following https://cybre.space/users/0x3F</title><content type="html">eal started following https://cybre.space/users/0x3F</content><published>2017-08-04T14:17:24.942193Z</published><updated>2017-08-04T14:17:24.942193Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type><id>https://cybre.space/users/0x3F</id><uri>https://cybre.space/users/0x3F</uri></activity:object><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/6e69df95-f2ad-4b8e-af4a-e93ff93d64e1"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://cybre.space/users/0x3F"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/follow</activity:verb><id>https://social.sakamoto.gq/activities/54c5e260-0185-4267-a2a6-f5dd9c76c2c9</id><title>eal started following https://niu.moe/users/rye</title><content type="html">eal started following https://niu.moe/users/rye</content><published>2017-08-04T14:16:35.604739Z</published><updated>2017-08-04T14:16:35.604739Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type><id>https://niu.moe/users/rye</id><uri>https://niu.moe/users/rye</uri></activity:object><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/54c5e260-0185-4267-a2a6-f5dd9c76c2c9"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://niu.moe/users/rye"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/follow</activity:verb><id>https://social.sakamoto.gq/activities/092ca863-19a8-416c-85d7-d3f23b3c0203</id><title>eal started following https://mastodon.xyz/users/rafudesu</title><content type="html">eal started following https://mastodon.xyz/users/rafudesu</content><published>2017-08-04T14:16:10.993429Z</published><updated>2017-08-04T14:16:10.993429Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type><id>https://mastodon.xyz/users/rafudesu</id><uri>https://mastodon.xyz/users/rafudesu</uri></activity:object><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/092ca863-19a8-416c-85d7-d3f23b3c0203"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://mastodon.xyz/users/rafudesu"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/follow</activity:verb><id>https://social.sakamoto.gq/activities/be5cf702-b127-423b-a6be-5f78f01a4289</id><title>eal started following https://gs.kawa-kun.com/user/2</title><content type="html">eal started following https://gs.kawa-kun.com/user/2</content><published>2017-08-04T14:15:41.804611Z</published><updated>2017-08-04T14:15:41.804611Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type><id>https://gs.kawa-kun.com/user/2</id><uri>https://gs.kawa-kun.com/user/2</uri></activity:object><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/be5cf702-b127-423b-a6be-5f78f01a4289"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://gs.kawa-kun.com/user/2"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/follow</activity:verb><id>https://social.sakamoto.gq/activities/4951e2a1-9bae-4e87-8e98-e6d2f8a52338</id><title>eal started following https://gs.kawa-kun.com/user/4885</title><content type="html">eal started following https://gs.kawa-kun.com/user/4885</content><published>2017-08-04T14:15:00.135352Z</published><updated>2017-08-04T14:15:00.135352Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type><id>https://gs.kawa-kun.com/user/4885</id><uri>https://gs.kawa-kun.com/user/4885</uri></activity:object><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/4951e2a1-9bae-4e87-8e98-e6d2f8a52338"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://gs.kawa-kun.com/user/4885"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/follow</activity:verb><id>https://social.sakamoto.gq/activities/cadf8745-b9ee-4f6c-af32-bfddb70e4607</id><title>eal started following https://mastodon.social/users/Murassa</title><content type="html">eal started following https://mastodon.social/users/Murassa</content><published>2017-08-04T14:14:36.339560Z</published><updated>2017-08-04T14:14:36.339560Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type><id>https://mastodon.social/users/Murassa</id><uri>https://mastodon.social/users/Murassa</uri></activity:object><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/cadf8745-b9ee-4f6c-af32-bfddb70e4607"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://mastodon.social/users/Murassa"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/follow</activity:verb><id>https://social.sakamoto.gq/activities/a52c9aab-f0e6-4ccb-8dd3-9f417e72a41c</id><title>eal started following https://mastodon.social/users/rysiek</title><content type="html">eal started following https://mastodon.social/users/rysiek</content><published>2017-08-04T14:13:04.061572Z</published><updated>2017-08-04T14:13:04.061572Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type><id>https://mastodon.social/users/rysiek</id><uri>https://mastodon.social/users/rysiek</uri></activity:object><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/a52c9aab-f0e6-4ccb-8dd3-9f417e72a41c"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://mastodon.social/users/rysiek"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/follow</activity:verb><id>https://social.sakamoto.gq/activities/738bc887-4cca-4b36-8c86-2b54d4c54732</id><title>eal started following https://mastodon.hasameli.com/users/munin</title><content type="html">eal started following https://mastodon.hasameli.com/users/munin</content><published>2017-08-04T14:12:10.514155Z</published><updated>2017-08-04T14:12:10.514155Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type><id>https://mastodon.hasameli.com/users/munin</id><uri>https://mastodon.hasameli.com/users/munin</uri></activity:object><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/738bc887-4cca-4b36-8c86-2b54d4c54732"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://mastodon.hasameli.com/users/munin"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/follow</activity:verb><id>https://social.sakamoto.gq/activities/dc66ad5a-b776-4180-a8aa-e4c1bf7cb703</id><title>eal started following https://cybre.space/users/nightpool</title><content type="html">eal started following https://cybre.space/users/nightpool</content><published>2017-08-04T14:11:16.046148Z</published><updated>2017-08-04T14:11:16.046148Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type><id>https://cybre.space/users/nightpool</id><uri>https://cybre.space/users/nightpool</uri></activity:object><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/dc66ad5a-b776-4180-a8aa-e4c1bf7cb703"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://cybre.space/users/nightpool"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb><id>https://social.sakamoto.gq/objects/9c5c00d7-3ce4-4c11-b965-dc5c2bda86c5</id><title>New note by eal</title><content type="html"><a href='https://mastodon.zombocloud.com/users/staticsafe'>@staticsafe</a> privet )))</content><published>2017-08-04T14:10:08.812247Z</published><updated>2017-08-04T14:10:08.812247Z</updated><ostatus:conversation>https://social.sakamoto.gq/contexts/12a33823-0327-4c1c-a591-850ea79331b5</ostatus:conversation><link ref="https://social.sakamoto.gq/contexts/12a33823-0327-4c1c-a591-850ea79331b5" rel="ostatus:conversation"/><link type="application/atom+xml" href="https://social.sakamoto.gq/objects/9c5c00d7-3ce4-4c11-b965-dc5c2bda86c5" rel="self"/><link type="text/html" href="https://social.sakamoto.gq/objects/9c5c00d7-3ce4-4c11-b965-dc5c2bda86c5" rel="alternate"/><thr:in-reply-to ref="tag:mastodon.zombocloud.com,2017-08-04:objectId=995766:objectType=Status" href="https://mastodon.zombocloud.com/users/staticsafe/updates/4900"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://mastodon.zombocloud.com/users/staticsafe"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/follow</activity:verb><id>https://social.sakamoto.gq/activities/49798053-1f40-4a71-ad33-106e90630863</id><title>eal started following https://social.homunyan.com/users/animeirl</title><content type="html">eal started following https://social.homunyan.com/users/animeirl</content><published>2017-08-04T14:09:44.904792Z</published><updated>2017-08-04T14:09:44.904792Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type><id>https://social.homunyan.com/users/animeirl</id><uri>https://social.homunyan.com/users/animeirl</uri></activity:object><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/49798053-1f40-4a71-ad33-106e90630863"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://social.homunyan.com/users/animeirl"/></entry><entry><activity:verb>http://activitystrea.ms/schema/1.0/favorite</activity:verb><id>https://social.sakamoto.gq/activities/2d83a1c5-70a6-45d3-9b84-59d6a70fbb17</id><title>New favorite by eal</title><content type="html">eal favorited something</content><published>2017-08-04T14:07:27.210044Z</published><updated>2017-08-04T14:07:27.210044Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type><id>https://pleroma.soykaf.com/objects/b831e52f-4ed4-438e-95b4-888897f64f09</id></activity:object><ostatus:conversation>https://pleroma.hjkos.com/contexts/3ed48205-1e72-4e19-a618-89a0d2ca811e</ostatus:conversation><link ref="https://pleroma.hjkos.com/contexts/3ed48205-1e72-4e19-a618-89a0d2ca811e" rel="ostatus:conversation"/><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/2d83a1c5-70a6-45d3-9b84-59d6a70fbb17"/><thr:in-reply-to ref="https://pleroma.soykaf.com/objects/b831e52f-4ed4-438e-95b4-888897f64f09"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://pleroma.soykaf.com/users/lain"/></entry><entry><activity:verb>http://activitystrea.ms/schema/1.0/favorite</activity:verb><id>https://social.sakamoto.gq/activities/06d28bed-544a-496b-8414-1c6d439273b5</id><title>New favorite by eal</title><content type="html">eal favorited something</content><published>2017-08-04T14:05:37.280200Z</published><updated>2017-08-04T14:05:37.280200Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type><id>tag:toot-lab.reclaim.technology,2017-08-04:objectId=1166030:objectType=Status</id></activity:object><ostatus:conversation>tag:p2px.me,2017-08-04:objectType=thread:nonce=f8bfc4d13db6ce91</ostatus:conversation><link ref="tag:p2px.me,2017-08-04:objectType=thread:nonce=f8bfc4d13db6ce91" rel="ostatus:conversation"/><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/06d28bed-544a-496b-8414-1c6d439273b5"/><thr:in-reply-to ref="tag:toot-lab.reclaim.technology,2017-08-04:objectId=1166030:objectType=Status"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://toot-lab.reclaim.technology/users/djsundog"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/follow</activity:verb><id>https://social.sakamoto.gq/activities/72bf19d4-9ad4-4b2f-9cd0-f0d70f4e931b</id><title>eal started following https://mstdn.jp/users/nullkal</title><content type="html">eal started following https://mstdn.jp/users/nullkal</content><published>2017-08-04T14:05:04.148904Z</published><updated>2017-08-04T14:05:04.148904Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type><id>https://mstdn.jp/users/nullkal</id><uri>https://mstdn.jp/users/nullkal</uri></activity:object><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/72bf19d4-9ad4-4b2f-9cd0-f0d70f4e931b"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://mstdn.jp/users/nullkal"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb><id>https://social.sakamoto.gq/objects/b0e89515-7621-4e09-b23d-83e192324107</id><title>New note by eal</title><content type="html"><a href='https://p2px.me/user/1'>@stitchxd</a> test also</content><published>2017-08-04T14:04:38.699051Z</published><updated>2017-08-04T14:04:38.699051Z</updated><ostatus:conversation>tag:p2px.me,2017-08-04:objectType=thread:nonce=f8bfc4d13db6ce91</ostatus:conversation><link ref="tag:p2px.me,2017-08-04:objectType=thread:nonce=f8bfc4d13db6ce91" rel="ostatus:conversation"/><link type="application/atom+xml" href="https://social.sakamoto.gq/objects/b0e89515-7621-4e09-b23d-83e192324107" rel="self"/><link type="text/html" href="https://social.sakamoto.gq/objects/b0e89515-7621-4e09-b23d-83e192324107" rel="alternate"/><thr:in-reply-to ref="tag:p2px.me,2017-08-04:noticeId=222109:objectType=note" href="https://p2px.me/notice/222109"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://p2px.me/user/1"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/></entry><entry><activity:verb>http://activitystrea.ms/schema/1.0/favorite</activity:verb><id>https://social.sakamoto.gq/activities/d8d2006b-6b23-45d6-ba27-39d27587777d</id><title>New favorite by eal</title><content type="html">eal favorited something</content><published>2017-08-04T14:04:32.106626Z</published><updated>2017-08-04T14:04:32.106626Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type><id>tag:p2px.me,2017-08-04:noticeId=222109:objectType=note</id></activity:object><ostatus:conversation>tag:p2px.me,2017-08-04:objectType=thread:nonce=f8bfc4d13db6ce91</ostatus:conversation><link ref="tag:p2px.me,2017-08-04:objectType=thread:nonce=f8bfc4d13db6ce91" rel="ostatus:conversation"/><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/d8d2006b-6b23-45d6-ba27-39d27587777d"/><thr:in-reply-to ref="tag:p2px.me,2017-08-04:noticeId=222109:objectType=note"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://p2px.me/user/1"/></entry><entry><activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type><activity:verb>http://activitystrea.ms/schema/1.0/follow</activity:verb><id>https://social.sakamoto.gq/activities/cb9db95d-ec27-41fa-bebd-5375fc13acb9</id><title>eal started following https://mastodon.social/users/Gargron</title><content type="html">eal started following https://mastodon.social/users/Gargron</content><published>2017-08-04T14:04:04.325531Z</published><updated>2017-08-04T14:04:04.325531Z</updated><activity:object><activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type><id>https://mastodon.social/users/Gargron</id><uri>https://mastodon.social/users/Gargron</uri></activity:object><link rel="self" type="application/atom+xml" href="https://social.sakamoto.gq/activities/cb9db95d-ec27-41fa-bebd-5375fc13acb9"/><link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://mastodon.social/users/Gargron"/></entry></feed>
\ No newline at end of file diff --git a/test/support/factory.ex b/test/support/factory.ex index bb3bdb02c..eca73725d 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -7,9 +7,9 @@ defmodule Pleroma.Factory do email: sequence(:email, &"user#{&1}@example.com"), nickname: sequence(:nickname, &"nick#{&1}"), password_hash: Comeonin.Pbkdf2.hashpwsalt("test"), - bio: sequence(:bio, &"Tester Number #{&1}"), + bio: sequence(:bio, &"Tester Number #{&1}") } - %{ user | ap_id: Pleroma.User.ap_id(user) } + %{ user | ap_id: Pleroma.User.ap_id(user), follower_address: Pleroma.User.ap_followers(user) } end def note_factory do diff --git a/test/support/httpoison_mock.ex b/test/support/httpoison_mock.ex index 420d42a0d..08b566fcd 100644 --- a/test/support/httpoison_mock.ex +++ b/test/support/httpoison_mock.ex @@ -87,6 +87,13 @@ defmodule HTTPoisonMock do }} end + def get("https://social.sakamoto.gq/users/eal/feed.atom", _body, _headers) do + {:ok, %Response{ + status_code: 200, + body: File.read!("test/fixtures/httpoison_mock/sakamoto_eal_feed.atom") + }} + end + def get("http://gs.example.org/index.php/api/statuses/user_timeline/1.atom", _body, _headers) do {:ok, %Response{ status_code: 200, @@ -142,6 +149,13 @@ defmodule HTTPoisonMock do }} end + def get("https://social.sakamoto.gq/.well-known/webfinger", [Accept: "application/xrd+xml"], [params: [resource: "https://social.sakamoto.gq/users/eal"]]) do + {:ok, %Response{ + status_code: 200, + body: File.read!("test/fixtures/httpoison_mock/eal_sakamoto.xml") + }} + end + def get("https://mamot.fr/users/Skruyb.atom", _, _) do {:ok, %Response{ status_code: 200, @@ -149,6 +163,14 @@ defmodule HTTPoisonMock do }} end + def get("https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056", [Accept: "application/atom+xml"], _) do + {:ok, %Response{ + status_code: 200, + body: File.read!("test/fixtures/httpoison_mock/sakamoto.atom") + }} + + end + def get(url, body, headers) do {:error, "Not implemented the mock response for get #{inspect(url)}, #{inspect(body)}, #{inspect(headers)}"} end diff --git a/test/upload_test.exs b/test/upload_test.exs index e8c954341..71041e83c 100644 --- a/test/upload_test.exs +++ b/test/upload_test.exs @@ -4,9 +4,10 @@ defmodule Pleroma.UploadTest do describe "Storing a file" do test "copies the file to the configured folder" do - file = %Plug.Upload{content_type: "image/jpg", path: Path.absname("test/fixtures/image.jpg"), filename: "an_image.jpg"} + file = %Plug.Upload{content_type: "image/jpg", path: Path.absname("test/fixtures/image.jpg"), filename: "an [image.jpg"} data = Upload.store(file) - assert data["name"] == "an_image.jpg" + assert data["name"] == "an [image.jpg" + assert List.first(data["url"])["href"] == "http://localhost:4001/media/#{data["uuid"]}/an%20%5Bimage.jpg" end end end diff --git a/test/user_test.exs b/test/user_test.exs index c79564385..097d7d98e 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -37,6 +37,9 @@ defmodule Pleroma.UserTest do user = Repo.get(User, user.id) + followed = User.get_by_ap_id(followed.ap_id) + assert followed.info["follower_count"] == 1 + assert user.following == [User.ap_followers(followed)] end @@ -103,6 +106,7 @@ defmodule Pleroma.UserTest do assert is_binary(changeset.changes[:password_hash]) assert changeset.changes[:ap_id] == User.ap_id(%User{nickname: @full_user_data.nickname}) assert changeset.changes[:following] == [User.ap_followers(%User{nickname: @full_user_data.nickname})] + assert changeset.changes.follower_address == "#{changeset.changes.ap_id}/followers" end end @@ -162,6 +166,12 @@ defmodule Pleroma.UserTest do assert cs.valid? end + test "it sets the follower_adress" do + cs = User.remote_user_creation(@valid_remote) + # remote users get a fake local follower address + assert cs.changes.follower_address == User.ap_followers(%User{ nickname: @valid_remote[:nickname] }) + end + test "it enforces the fqn format for nicknames" do cs = User.remote_user_creation(%{@valid_remote | nickname: "bla"}) assert cs.changes.local == false @@ -190,5 +200,64 @@ defmodule Pleroma.UserTest do end) end end + + describe "followers and friends" do + test "gets all followers for a given user" do + user = insert(:user) + follower_one = insert(:user) + follower_two = insert(:user) + not_follower = insert(:user) + + {:ok, follower_one} = User.follow(follower_one, user) + {:ok, follower_two} = User.follow(follower_two, user) + + {:ok, res} = User.get_followers(user) + + assert res == [follower_one, follower_two] + end + + test "gets all friends (followed users) for a given user" do + user = insert(:user) + followed_one = insert(:user) + followed_two = insert(:user) + not_followed = insert(:user) + + {:ok, user} = User.follow(user, followed_one) + {:ok, user} = User.follow(user, followed_two) + + {:ok, res} = User.get_friends(user) + + followed_one = User.get_by_ap_id(followed_one.ap_id) + followed_two = User.get_by_ap_id(followed_two.ap_id) + assert res == [followed_one, followed_two] + end + end + + describe "updating note and follower count" do + test "it sets the info->note_count property" do + note = insert(:note) + + user = User.get_by_ap_id(note.data["actor"]) + + assert user.info["note_count"] == nil + + {:ok, user} = User.update_note_count(user) + + assert user.info["note_count"] == 1 + end + + test "it sets the info->follower_count property" do + user = insert(:user) + follower = insert(:user) + + User.follow(follower, user) + + assert user.info["follower_count"] == nil + + {:ok, user} = User.update_follower_count(user) + + assert user.info["follower_count"] == 1 + end + end end diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index b9fa4ccfb..0129e3758 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -4,9 +4,23 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do alias Pleroma.Web.OStatus.ActivityRepresenter alias Pleroma.{User, Activity, Object} alias Pleroma.Web.ActivityPub.ActivityPub + alias Pleroma.Web.OStatus import Pleroma.Factory + test "an external note activity" do + incoming = File.read!("test/fixtures/mastodon-note-cw.xml") + {:ok, [activity]} = OStatus.handle_incoming(incoming) + + user = User.get_cached_by_ap_id(activity.data["actor"]) + + tuple = ActivityRepresenter.to_simple_form(activity, user) + + res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary + + assert String.contains?(res, ~s{<link type="text/html" href="https://mastodon.social/users/lambadalambda/updates/2314748" rel="alternate"/>}) + end + test "a note activity" do note_activity = insert(:note_activity) @@ -23,6 +37,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do <ostatus:conversation>#{note_activity.data["context"]}</ostatus:conversation> <link ref="#{note_activity.data["context"]}" rel="ostatus:conversation" /> <link type="application/atom+xml" href="#{note_activity.data["object"]["id"]}" rel="self" /> + <link type="text/html" href="#{note_activity.data["object"]["id"]}" rel="alternate" /> <category term="2hu"/> <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/> """ @@ -43,6 +58,9 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do data = %{answer.data | "object" => object} answer = %{answer | data: data} + note_object = Object.get_by_ap_id(note.data["object"]["id"]) + Repo.update!(Object.change(note_object, %{ data: Map.put(note_object.data, "external_url", "someurl") })) + user = User.get_cached_by_ap_id(answer.data["actor"]) expected = """ @@ -56,8 +74,9 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do <ostatus:conversation>#{answer.data["context"]}</ostatus:conversation> <link ref="#{answer.data["context"]}" rel="ostatus:conversation" /> <link type="application/atom+xml" href="#{answer.data["object"]["id"]}" rel="self" /> + <link type="text/html" href="#{answer.data["object"]["id"]}" rel="alternate" /> <category term="2hu"/> - <thr:in-reply-to ref="#{note.data["object"]["id"]}" /> + <thr:in-reply-to ref="#{note.data["object"]["id"]}" href="someurl" /> <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/> """ diff --git a/test/web/ostatus/incoming_documents/delete_handling_test.exs b/test/web/ostatus/incoming_documents/delete_handling_test.exs new file mode 100644 index 000000000..989c87afa --- /dev/null +++ b/test/web/ostatus/incoming_documents/delete_handling_test.exs @@ -0,0 +1,28 @@ +defmodule Pleroma.Web.OStatus.DeleteHandlingTest do + use Pleroma.DataCase + + import Pleroma.Factory + alias Pleroma.{Repo, Activity, Object} + alias Pleroma.Web.OStatus + + describe "deletions" do + test "it removes the mentioned activity" do + note = insert(:note_activity) + second_note = insert(:note_activity) + user = insert(:user) + object = Object.get_by_ap_id(note.data["object"]["id"]) + + {:ok, like, object} = Pleroma.Web.ActivityPub.ActivityPub.like(user, object) + + incoming = File.read!("test/fixtures/delete.xml") + |> String.replace("tag:mastodon.sdf.org,2017-06-10:objectId=310513:objectType=Status", note.data["object"]["id"]) + {:ok, []} = OStatus.handle_incoming(incoming) + + refute Repo.get(Activity, note.id) + refute Repo.get(Activity, like.id) + refute Object.get_by_ap_id(note.data["object"]["id"]) + assert Repo.get(Activity, second_note.id) + assert Object.get_by_ap_id(second_note.data["object"]["id"]) + end + end +end diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 34bfaa005..44d687d8e 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -15,6 +15,8 @@ defmodule Pleroma.Web.OStatusTest do incoming = File.read!("test/fixtures/incoming_note_activity.xml") {:ok, [activity]} = OStatus.handle_incoming(incoming) + user = User.get_by_ap_id(activity.data["actor"]) + assert user.info["note_count"] == 1 assert activity.data["type"] == "Create" assert activity.data["object"]["type"] == "Note" assert activity.data["object"]["id"] == "tag:gs.example.org:4040,2017-04-23:noticeId=29:objectType=note" @@ -324,11 +326,18 @@ defmodule Pleroma.Web.OStatusTest do describe "fetching a status by it's HTML url" do test "it builds a missing status from an html url" do url = "https://shitposter.club/notice/2827873" - {:ok, [activity] } = OStatus.fetch_activity_from_html_url(url) + {:ok, [activity] } = OStatus.fetch_activity_from_url(url) assert activity.data["actor"] == "https://shitposter.club/user/1" assert activity.data["object"]["id"] == "tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment" end + + test "it works for atom notes, too" do + url = "https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056" + {:ok, [activity] } = OStatus.fetch_activity_from_url(url) + assert activity.data["actor"] == "https://social.sakamoto.gq/users/eal" + assert activity.data["object"]["id"] == url + end end test "insert or update a user from given data" do diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 0281ea55b..8c689d7d3 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -419,6 +419,42 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do end end + describe "GET /api/statuses/followers" do + test "it returns a user's followers", %{conn: conn} do + user = insert(:user) + follower_one = insert(:user) + follower_two = insert(:user) + not_follower = insert(:user) + + {:ok, follower_one} = User.follow(follower_one, user) + {:ok, follower_two} = User.follow(follower_two, user) + + conn = conn + |> assign(:user, user) + |> get("/api/statuses/followers") + + assert json_response(conn, 200) == UserView.render("index.json", %{users: [follower_one, follower_two], for: user}) + end + end + + describe "GET /api/statuses/friends" do + test "it returns a user's friends", %{conn: conn} do + user = insert(:user) + followed_one = insert(:user) + followed_two = insert(:user) + not_followed = insert(:user) + + {:ok, user} = User.follow(user, followed_one) + {:ok, user} = User.follow(user, followed_two) + + conn = conn + |> assign(:user, user) + |> get("/api/statuses/friends") + + assert json_response(conn, 200) == UserView.render("index.json", %{users: [followed_one, followed_two], for: user}) + end + end + defp valid_user(_context) do user = insert(:user) [user: user] diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index 080e5f86a..bbb261eff 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -9,7 +9,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do import Pleroma.Factory test "create a status" do - user = UserBuilder.build(%{ap_id: "142344"}) + user = insert(:user) _mentioned_user = UserBuilder.insert(%{nickname: "shp", ap_id: "shp"}) object_data = %{ @@ -52,10 +52,14 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do assert is_list(activity.data["object"]["attachment"]) assert activity.data["object"] == Object.get_by_ap_id(activity.data["object"]["id"]).data + + user = User.get_by_ap_id(user.ap_id) + + assert user.info["note_count"] == 1 end test "create a status that is a reply" do - user = UserBuilder.build(%{ap_id: "some_cool_id"}) + user = insert(:user) input = %{ "status" => "Hello again." } @@ -73,7 +77,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do assert get_in(reply.data, ["object", "context"]) == get_in(activity.data, ["object", "context"]) assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"]) assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id - assert Enum.member?(get_in(reply.data, ["to"]), "some_cool_id") + assert Enum.member?(get_in(reply.data, ["to"]), user.ap_id) end test "fetch public statuses, excluding remote ones." do @@ -187,6 +191,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do {:ok, user, followed, _activity } = TwitterAPI.follow(user, %{"screen_name" => followed.nickname}) assert user.following == [User.ap_followers(followed)] + followed = User.get_by_ap_id(followed.ap_id) + assert followed.info["follower_count"] == 1 + { :error, msg } = TwitterAPI.follow(user, %{"screen_name" => followed.nickname}) assert msg == "Could not follow user: #{followed.nickname} is already on your list." end diff --git a/test/web/twitter_api/twitter_api_utils_test.exs b/test/web/twitter_api/twitter_api_utils_test.exs index 62aa7843b..49818afed 100644 --- a/test/web/twitter_api/twitter_api_utils_test.exs +++ b/test/web/twitter_api/twitter_api_utils_test.exs @@ -9,6 +9,6 @@ defmodule Pleroma.Web.TwitterAPI.UtilsTest do res = Utils.add_attachments("", [attachment]) - assert res == "<br>\n<a href=\"http://heise.de/i%22m%20a%20boy.png\" class='attachment'>i\"m a boy.png</a>" + assert res == "<br>\n<a href=\"http://heise.de/i\"m a boy.png\" class='attachment'>i\"m a boy.png</a>" end end diff --git a/test/web/twitter_api/views/user_view_test.exs b/test/web/twitter_api/views/user_view_test.exs index de2cd3d30..b81d3d64d 100644 --- a/test/web/twitter_api/views/user_view_test.exs +++ b/test/web/twitter_api/views/user_view_test.exs @@ -22,6 +22,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do test "A user" do note_activity = insert(:note_activity) user = User.get_cached_by_ap_id(note_activity.data["actor"]) + {:ok, user} = User.update_note_count(user) follower = insert(:user) second_follower = insert(:user) @@ -57,6 +58,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do test "A user for a given other follower", %{user: user} do {:ok, follower} = UserBuilder.insert(%{following: [User.ap_followers(user)]}) + {:ok, user} = User.update_follower_count(user) image = "https://placehold.it/48x48" represented = %{ "id" => user.id, |