Commit ea211396e9b34b6e7557423bd7c5bb8439dc085b

Authored by Larissa Reis
1 parent ea63d985

Adds more tests for ExternalPerson

app/models/person.rb
@@ -173,7 +173,7 @@ class Person < Profile @@ -173,7 +173,7 @@ class Person < Profile
173 end 173 end
174 174
175 def add_friend(friend, group = nil) 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 friendship = self.friendships.build 177 friendship = self.friendships.build
178 friendship.friend = friend 178 friendship.friend = friend
179 friendship.group = group 179 friendship.group = group
test/unit/external_person_test.rb
@@ -69,39 +69,50 @@ class ExternalPersonTest < ActiveSupport::TestCase @@ -69,39 +69,50 @@ class ExternalPersonTest < ActiveSupport::TestCase
69 end 69 end
70 70
71 should 'generate a custom profile icon based on its avatar' do 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 end 73 end
74 74
75 should 'have an url to its profile on its original environment' do 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 end 77 end
78 78
79 should 'have a public profile url' do 79 should 'have a public profile url' do
80 - skip 80 + assert_match(/http:\/\/#{@external_person.source}\/profile\/.*/, @external_person.public_profile_url)
81 end 81 end
82 82
83 should 'have an admin url to its profile on its original environment' do 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 end 85 end
86 86
87 should 'never be a friend of another person' do 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 end 92 end
90 93
91 should 'never send a friend request to another person' do 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 end 100 end
94 101
95 should 'not follow another profile' do 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 end 107 end
98 108
99 should 'have an image' do 109 should 'have an image' do
100 - skip 110 + assert_not_nil @external_person.image
101 end 111 end
102 112
103 should 'profile image has public filename and mimetype' do 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 end 116 end
106 117
107 should 'respond to all instance methods in Profile' do 118 should 'respond to all instance methods in Profile' do
test/unit/external_user_test.rb
@@ -1,10 +0,0 @@ @@ -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