Dla mojego życia nie rozumiem, dlaczego Authlogic nie rejestruje mnie w tym teście integracji. Nie miałem żadnych problemów z/Authlogic logując mnie w testach funkcjonalnych za pomocą tego kodu. Według authlogic rdocs (http://tinyurl.com/mb2fp2), symulowanie stanu zalogowania jest takie samo w testach integracji funkcjonalnej &, więc jestem całkiem zdezorientowany. każda pomoc jest doceniana!Testy integracyjne z 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
dzięki. z tej linii w dokumencie rdoc: UserSession.create (użytkownicy (: kogo)) Zakładam, że mogę przekazać @user obj. doceń pomoc! – kareem
hmm według tego: http://rdoc.info/rdoc/binarylogic/authlogic/blob/73c4cccb38189f0e52e1e362992dfb9db7d1206f/Authlogic/Session/UnauthorizedRecord.html byłbym w stanie zrobić UserSession.create (@user) i to działa ... wtf. – kareem