friends_controller_test.rb
1.92 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
require File.dirname(__FILE__) + '/../test_helper'
require 'friends_controller'
class FriendsController; def rescue_action(e) raise e end; end
class FriendsControllerTest < Test::Unit::TestCase
noosfero_test :profile => 'testuser'
def setup
@controller = FriendsController.new
@request = ActionController::TestRequest.new
@request.stubs(:ssl?).returns(true)
@response = ActionController::TestResponse.new
self.profile = create_user('testuser').person
self.friend = create_user('thefriend').person
login_as ('testuser')
end
attr_accessor :profile, :friend
def test_local_files_reference
assert_local_files_reference
end
def test_valid_xhtml
assert_valid_xhtml
end
should 'list friends' do
get :index
assert_response :success
assert_template 'index'
assert_kind_of Array, assigns(:friends)
end
should 'confirm addition of new friend' do
get :add, :id => friend.id
assert_response :success
assert_template 'add'
ok("must load the friend being added to display") { friend == assigns(:friend) }
end
should 'actually add friend' do
assert_difference AddFriend, :count do
post :add, :id => friend.id, :confirmation => '1'
assert_response :redirect
end
end
should 'confirm removal of friend' do
profile.add_friend(friend)
get :remove, :id => friend.id
assert_response :success
assert_template 'remove'
ok("must load the friend being removed") { friend == assigns(:friend) }
end
should 'actually remove friend' do
profile.add_friend(friend)
assert_difference Friendship, :count, -1 do
post :remove, :id => friend.id, :confirmation => '1'
assert_redirected_to :action => 'index'
end
end
should 'display find people button' do
get :index, :profile => 'testuser'
assert_tag :tag => 'a', :content => 'Find people', :attributes => { :href => '/assets/people' }
end
end