Commit f078e729167d5b5196de6a3db5387fb19eb9426b
1 parent
96dd6daf
Exists in
federation-webfinger
Creates initial tests for ExternalProfile
Showing
3 changed files
with
136 additions
and
0 deletions
Show diff stats
app/models/external_person.rb
... | ... | @@ -6,6 +6,8 @@ class ExternalPerson < ActiveRecord::Base |
6 | 6 | |
7 | 7 | validates_uniqueness_of :identifier, scope: :source |
8 | 8 | |
9 | + validates_presence_of :source, :email, :created_at | |
10 | + | |
9 | 11 | attr_accessible :source, :email, :created_at |
10 | 12 | |
11 | 13 | def self.get_or_create(webfinger) |
... | ... | @@ -74,6 +76,24 @@ class ExternalPerson < ActiveRecord::Base |
74 | 76 | Profile.none |
75 | 77 | end |
76 | 78 | |
79 | + def tasks | |
80 | + Task.none | |
81 | + end | |
82 | + | |
83 | + def suggested_profiles | |
84 | + ProfileSuggestion.none | |
85 | + end | |
86 | + def suggested_people | |
87 | + ProfileSuggestion.none | |
88 | + end | |
89 | + def suggested_communities | |
90 | + ProfileSuggestion.none | |
91 | + end | |
92 | + | |
93 | + def add_friend(friend, group = nil) | |
94 | + false | |
95 | + end | |
96 | + | |
77 | 97 | def follows?(profile) |
78 | 98 | false |
79 | 99 | end |
... | ... | @@ -96,6 +116,8 @@ class ExternalPerson < ActiveRecord::Base |
96 | 116 | end |
97 | 117 | |
98 | 118 | def content_type |
119 | + # This is not really going to be used anywhere that matters | |
120 | + # so we are hardcodding it here. | |
99 | 121 | 'image/png' |
100 | 122 | end |
101 | 123 | end | ... | ... |
... | ... | @@ -0,0 +1,104 @@ |
1 | +# encoding: UTF-8 | |
2 | +require_relative "../test_helper" | |
3 | + | |
4 | +class PersonTest < ActiveSupport::TestCase | |
5 | + fixtures :environments | |
6 | + | |
7 | + def setup | |
8 | + @external_person = ExternalPerson.create!(identifier: 'johnlock', | |
9 | + name: 'John Lock', | |
10 | + source: 'anerenvironment.org', | |
11 | + email: 'john@lock.org', | |
12 | + created_at: Date.yesterday | |
13 | + ) | |
14 | + end | |
15 | + | |
16 | + should 'have no permissions' do | |
17 | + assert_equivalent [], @external_person.role_assignments | |
18 | + refute @external_person.has_permission?(:manage_friends) | |
19 | + end | |
20 | + | |
21 | + should 'have no suggested profiles' do | |
22 | + assert_equivalent [], @external_person.suggested_communities | |
23 | + assert_equivalent [], @external_person.suggested_people | |
24 | + assert_equivalent [], @external_person.suggested_profiles | |
25 | + end | |
26 | + | |
27 | + should 'have no friendships' do | |
28 | + refute @external_person.add_friend(fast_create(Person)) | |
29 | + assert_equivalent [], @external_person.friendships | |
30 | + end | |
31 | + | |
32 | + should 'not be a member of any communities' do | |
33 | + community = fast_create(Community) | |
34 | + refute community.add_member(@external_person) | |
35 | + assert_equivalent [], @external_person.memberships | |
36 | + end | |
37 | + | |
38 | + should 'not have any favorite enterprises' do | |
39 | + assert_equivalent [], @external_person.favorite_enterprises | |
40 | + end | |
41 | + | |
42 | + should 'be a person' do | |
43 | + assert @external_person.person? | |
44 | + end | |
45 | + | |
46 | + should 'not be a community, organization or enterprise' do | |
47 | + refute @external_person.community? | |
48 | + refute @external_person.enterprise? | |
49 | + refute @external_person.organization? | |
50 | + end | |
51 | + | |
52 | + should 'never be an admin for environments' do | |
53 | + refute @external_person.is_admin? | |
54 | + env = Environment.default | |
55 | + env.add_admin @external_person | |
56 | + refute @external_person.is_admin?(env) | |
57 | + assert_equivalent [], env.admins | |
58 | + end | |
59 | + | |
60 | + should 'redirect after login based on environment settings' do | |
61 | + assert_respond_to ExternalPerson.new, :preferred_login_redirection | |
62 | + environment = fast_create(Environment, :redirection_after_login => 'site_homepage') | |
63 | + profile = fast_create(ExternalPerson, :environment_id => environment.id) | |
64 | + assert_equal 'site_homepage', profile.preferred_login_redirection | |
65 | + end | |
66 | + | |
67 | + should 'have an avatar from its original environment' do | |
68 | + assert_match /http:\/\/#{@external_person.source}\/.*/, @external_person.avatar | |
69 | + end | |
70 | + | |
71 | + should 'generate a custom profile icon based on its avatar' do | |
72 | + end | |
73 | + | |
74 | + should 'have an url to its profile on its original environment' do | |
75 | + end | |
76 | + | |
77 | + should 'have a public profile url' do | |
78 | + end | |
79 | + | |
80 | + should 'have an admin url to its profile on its original environment' do | |
81 | + end | |
82 | + | |
83 | + should 'respond to lat and lng' do | |
84 | + assert_respond_to ExternalPerson.new, :lat | |
85 | + assert_respond_to ExternalPerson.new, :lng | |
86 | + assert_nil @external_person.lat | |
87 | + assert_nil @external_person.lng | |
88 | + end | |
89 | + | |
90 | + should 'never be a friend of another person' do | |
91 | + end | |
92 | + | |
93 | + should 'never send a friend request to another person' do | |
94 | + end | |
95 | + | |
96 | + should 'not follow another profile' do | |
97 | + end | |
98 | + | |
99 | + should 'have an image' do | |
100 | + end | |
101 | + | |
102 | + should 'profile image has public filename and mimetype' do | |
103 | + end | |
104 | +end | ... | ... |
... | ... | @@ -0,0 +1,10 @@ |
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 | ... | ... |