manage_friendships_test.rb
1.01 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
require_relative "../test_helper"
class ManageFriendshipsTest < ActionController::IntegrationTest
def setup
FriendsController.any_instance.stubs(:get_layout).returns('application')
ProfileController.any_instance.stubs(:get_layout).returns('application')
Friendship.delete_all
Person.delete_all
@person = create_user("albert", :password => 'test',
:password_confirmation => 'test').person
@person.user.activate
@friend = fast_create(Person, :identifier => "isaac")
login(@person.identifier, 'test')
end
should 'remove friendships' do
@person.add_friend(@friend)
@friend.add_friend(@person)
get "/myprofile/#{@person.identifier}/friends/remove/#{@friend.id}"
assert_response :success
post "/myprofile/#{@person.identifier}/friends/remove/#{@friend.id}",
:confirmation => '1'
assert_response :redirect
follow_redirect!
assert assigns(:friends).empty?
refute @person.is_a_friend?(@friend)
refute @friend.is_a_friend?(@person)
end
end