Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- UserSession.create(:email => 'someone@example.com', :password => 'password')
- UserSession.create(@user)
- require 'test_helper'
- class LoansControllerTest < ActionController::TestCase
- [...]
- context "as a signed-in user, with an active loan" do
- setup do
- @user = Factory(:user)
- @user_session = UserSession.create(@user)
- @loan = Factory(:loan, :ownership => Factory(:ownership, :user => @user))
- end
- context "on GET to :index" do
- setup do
- get :index
- end
- should_respond_with_success
- end
- end
- end
- ENV["RAILS_ENV"] = "test"
- require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
- require 'test_help'
- class ActiveSupport::TestCase
- [...]
- # Add more helper methods to be used by all tests here...
- include Authlogic::TestCase
- def setup
- activate_authlogic
- end
- end
- setup do
- post 'user_session', :user_session => {:email => 'someone@example.com', :password => 'password'}
- end
- UserSession.create!(@user)
Add Comment
Please, Sign In to add comment