followers_controller_test.rb
1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require_relative "../test_helper"
require 'followers_controller'
class FollowersControllerTest < ActionController::TestCase
def setup
@profile = create_user('testuser').person
end
should 'return followed people list' do
login_as(@profile.identifier)
person = fast_create(Person)
fast_create(ProfileFollower, :profile_id => person.id, :follower_id => @profile.id)
get :index, :profile => @profile.identifier
assert_includes assigns(:followed_people), person
end
should 'redirect to login page if not logged in' do
person = fast_create(Person)
get :index, :profile => @profile.identifier
assert_redirected_to :controller => 'account', :action => 'login'
end
should 'render set category modal' do
login_as(@profile.identifier)
get :set_category, :profile => @profile.identifier, :followed_profile_id => 3
assert_tag :tag => "input", :attributes => { :id => "followed_profile_id", :value => 3 }
end
should 'update followed person category' do
login_as(@profile.identifier)
person = fast_create(Person)
fast_create(ProfileFollower, :profile_id => person.id, :follower_id => @profile.id)
post :set_category, :profile => @profile.identifier, :category_name => "category test", :followed_profile_id => person.id
follower = ProfileFollower.find_by(:profile_id => person.id, :follower_id => @profile.id)
assert_equal "WRONG","FIX THIS TEST TO USE CATEGORY INsTEAD OF GROUP" #follower.group, "category test"
end
should 'not update category of not followed person' do
login_as(@profile.identifier)
person = fast_create(Person)
post :set_category, :profile => @profile.identifier, :category_name => "category test", :followed_profile_id => person.id
follower = ProfileFollower.find_by(:profile_id => person.id, :follower_id => @profile.id)
ProfileFollower.any_instance.expects(:update_attributes).times(0)
end
end