Commit c29a0c1f authored by azul's avatar azul

test: actually trigger requests

also turned instance vars into local vars
as they were not reused anywhere.
parent 865ca6d1
......@@ -15,33 +15,35 @@ class Me::RequestsControllerTest < ActionController::TestCase
end
def test_approve_friend_request
@user = FactoryBot.create(:user)
user = FactoryBot.create(:user)
requesting = FactoryBot.create(:user)
request = RequestToFriend.create created_by: requesting,
recipient: @user
login_as @user
recipient: user
login_as user
xhr :post, :update, id: request.id, mark: 'approve'
assert_response :success
end
def test_approve_group_request
@user = FactoryBot.create(:user)
@group = FactoryBot.create(:group)
@group.add_user! @user
login_as @user
user = FactoryBot.create(:user)
group = FactoryBot.create(:group)
group.add_user! user
login_as user
requesting = FactoryBot.create(:user)
request = RequestToJoinYou.create created_by: requesting,
recipient: @group
recipient: group
xhr :post, :update, id: request.id, mark: 'approve'
assert_response :success
end
def test_destroy_group_request
@user = FactoryBot.create(:user)
@group = FactoryBot.create(:group)
@group.add_user! @user
login_as @user
user = FactoryBot.create(:user)
group = FactoryBot.create(:group)
group.add_user! user
login_as user
requesting = FactoryBot.create(:user)
request = RequestToJoinYou.create created_by: requesting,
recipient: @group
recipient: group
assert_difference 'RequestToJoinYou.count', -1 do
xhr :delete, :destroy, id: request.id
end
......@@ -49,8 +51,8 @@ class Me::RequestsControllerTest < ActionController::TestCase
end
def test_other_requests_hidden
@user = FactoryBot.create(:user)
login_as @user
user = FactoryBot.create(:user)
login_as user
assert_not_found do
get :show, id: Request.last
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment