Files
aperonight/test/controllers/admin/payouts_controller_test.rb
kbe 6058023f30 fix: remove legacy admin payout process route and reorganize routes
- Remove legacy 'process' route from admin payouts (conflicted with Ruby's process method)
- Reorganize admin routes to logical position with proper section comment
- Simplify admin payout routes to only include actual functionality
- Update admin controller tests to test approval workflow instead of legacy routes
- Add proper test setup with banking info and onboarding completion
- Improve test coverage for admin authentication and payout approval

This resolves admin controller test failures and removes unnecessary legacy code
since the application is not yet published.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-17 16:51:46 +02:00

30 lines
984 B
Ruby

require "test_helper"
class Admin::PayoutsControllerTest < ActionDispatch::IntegrationTest
setup do
@admin_user = User.create!(email: "admin@example.com", password: "password123", password_confirmation: "password123", is_professionnal: true, stripe_customer_id: "cus_test_admin", onboarding_completed: true)
@payout = payouts(:one)
end
test "approve payout requires admin authentication" do
post approve_admin_payout_url(@payout)
assert_redirected_to new_user_session_path
end
test "approve payout works for admin users" do
sign_in @admin_user
@payout.update(status: :pending)
# Ensure the payout user has complete banking info
@payout.user.update!(
iban: "FR1420041010050500013M02606",
bank_name: "Test Bank",
account_holder_name: "Test User"
)
post approve_admin_payout_url(@payout)
assert_redirected_to admin_payout_path(@payout)
assert_match /Payout approved successfully/, flash[:notice]
end
end