Commit ea211396e9b34b6e7557423bd7c5bb8439dc085b
1 parent
ea63d985
Exists in
federation-webfinger
Adds more tests for ExternalPerson
Showing
3 changed files
with
21 additions
and
20 deletions
Show diff stats
app/models/person.rb
... | ... | @@ -173,7 +173,7 @@ class Person < Profile |
173 | 173 | end |
174 | 174 | |
175 | 175 | def add_friend(friend, group = nil) |
176 | - unless self.is_a_friend?(friend) | |
176 | + unless self.is_a_friend?(friend) || friend.is_a?(ExternalPerson) | |
177 | 177 | friendship = self.friendships.build |
178 | 178 | friendship.friend = friend |
179 | 179 | friendship.group = group | ... | ... |
test/unit/external_person_test.rb
... | ... | @@ -69,39 +69,50 @@ class ExternalPersonTest < ActiveSupport::TestCase |
69 | 69 | end |
70 | 70 | |
71 | 71 | should 'generate a custom profile icon based on its avatar' do |
72 | - skip | |
72 | + assert_match(/http:\/\/#{@external_person.source}\/.*/, @external_person.profile_custom_icon) | |
73 | 73 | end |
74 | 74 | |
75 | 75 | should 'have an url to its profile on its original environment' do |
76 | - skip | |
76 | + assert_match(/http:\/\/#{@external_person.source}\/profile\/.*/, @external_person.url) | |
77 | 77 | end |
78 | 78 | |
79 | 79 | should 'have a public profile url' do |
80 | - skip | |
80 | + assert_match(/http:\/\/#{@external_person.source}\/profile\/.*/, @external_person.public_profile_url) | |
81 | 81 | end |
82 | 82 | |
83 | 83 | should 'have an admin url to its profile on its original environment' do |
84 | - skip | |
84 | + assert_match(/http:\/\/#{@external_person.source}\/myprofile\/.*/, @external_person.admin_url) | |
85 | 85 | end |
86 | 86 | |
87 | 87 | should 'never be a friend of another person' do |
88 | - skip | |
88 | + friend = fast_create(Person) | |
89 | + friend.add_friend @external_person | |
90 | + refute @external_person.is_a_friend?(friend) | |
91 | + refute friend.is_a_friend?(@external_person) | |
89 | 92 | end |
90 | 93 | |
91 | 94 | should 'never send a friend request to another person' do |
92 | - skip | |
95 | + friend = fast_create(Person) | |
96 | + friend.add_friend @external_person | |
97 | + refute friend.already_request_friendship?(@external_person) | |
98 | + @external_person.add_friend(friend) | |
99 | + refute @external_person.already_request_friendship?(friend) | |
93 | 100 | end |
94 | 101 | |
95 | 102 | should 'not follow another profile' do |
96 | - skip | |
103 | + friend = fast_create(Person) | |
104 | + friend.add_friend @external_person | |
105 | + refute @external_person.follows?(friend) | |
106 | + refute friend.follows?(@external_person) | |
97 | 107 | end |
98 | 108 | |
99 | 109 | should 'have an image' do |
100 | - skip | |
110 | + assert_not_nil @external_person.image | |
101 | 111 | end |
102 | 112 | |
103 | 113 | should 'profile image has public filename and mimetype' do |
104 | - skip | |
114 | + assert_not_nil @external_person.image.public_filename | |
115 | + assert_not_nil @external_person.image.content_type | |
105 | 116 | end |
106 | 117 | |
107 | 118 | should 'respond to all instance methods in Profile' do | ... | ... |
test/unit/external_user_test.rb
... | ... | @@ -1,10 +0,0 @@ |
1 | -# encoding: UTF-8 | |
2 | -require_relative "../test_helper" | |
3 | - | |
4 | -class ExternalUserTest < ActiveSupport::TestCase | |
5 | - # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead. | |
6 | - # Then, you can remove it from this and the functional test. | |
7 | - include AuthenticatedTestHelper | |
8 | - fixtures :users, :environments | |
9 | - | |
10 | -end |