dimanche 25 septembre 2016

Rails 4: How to test Controller Action

How do I actually test this Controller Action, I wrote in my PurchasesController:

protect_from_forgery except: [:hook]
def hook
    params.permit! # Permit all Paypal input params
    status = params[:payment_status]
    if status == "Completed"
        @purchase = Purchase.find(params[:invoice])
        @purchase.update_attributes(status: status, transaction_id: params[:txn_id], purchased_at: Time.now)
        @purchase.save!
        @user = @tool.user
        @user.earned_money += @tool.price
        @user.save!
    end
    render nothing: true
end

preferably with my Rails Console?

Routes:

post "/purchases/:id" => "purchases#show"
post "/hook" => "purchases#hook"

Aucun commentaire:

Enregistrer un commentaire