Per la vita di me non capisco perché Authlogic non mi stia registrando in questo test di integrazione. Non ho avuto problemi con Authlogic che mi ha registrato in test funzionali usando questo codice. Secondo il rdocs authlogic (http://tinyurl.com/mb2fp2), la simulazione di uno stato di accesso è la stessa nei test di integrazione funzionali &, quindi sono abbastanza confuso. Ogni aiuto è molto apprezzato!Test di integrazione con Authlogic?
class TipsController < ApplicationController
before_filter :require_user, :only => [:destroy, :undelete]
def destroy
@tip = Tip.find(params[:id])
if can_delete?(@tip)
@tip.destroy
set_flash("good", "Tip deleted. <a href=\"#{undelete_tip_url(@tip.id)}\">Undo?</a>")
respond_to do |format|
format.html { redirect_to city_path(@tip.city)}
end
else
set_flash("bad", "Seems like you can't delete this tip, sorry.")
respond_to do |format|
format.html { render :action => "show", :id => @tip}
end
end
end
end
class DeleteTipAndRender < ActionController::IntegrationTest
context "log user in" do
setup do
@user = create_user
@tip = create_tip
end
context "delete tip" do
setup do
activate_authlogic
UserSession.create(@user)
@us = UserSession.find
post "/tips/destroy", :id => @tip.id
end
should_redirect_to("city_path(@tip.city)"){city_path(@tip.city)}
end
end
end
grazie. da questa riga in rdoc: UserSession.create (utenti (: chiunque)) ho presupposto che potrei passare un obj @user. apprezzare l'aiuto! – kareem
hmm secondo questo: http://rdoc.info/rdoc/binarylogic/authlogic/blob/73c4cccb38189f0e52e1e362992dfb9db7d1206f/Authlogic/Session/UnauthorizedRecord.html dovrei essere in grado di fare UserSession.create (@user) e farlo funzionare ... wtf. – kareem