Rails/Rspec - testing a redirect in the controller -
so writing test controller in existing controller didnt have 1 before. want test redirect happens when not allowed edit vs allowed edit it. the controller action being edit def edit if !@scorecard.reviewed? || admin? @company = @scorecard.company @custom_css_include = "confirmation_page" else redirect_to :back end end so if scorecard has been reviewed admin can edit score. routes controller.. # scorecards resources :scorecards member 'report' end resources :inaccuracy_reports, :only => [:new, :create] end and test require 'spec_helper' describe scorecardscontroller describe "get edit" before(:each) @agency = factory(:agency) @va = factory(:va_user, :agency => @agency) @admin = factory(:admin) @company = factory(:company) @scorecard = factory(:scorecard, :level => 1, :company => @company, :agency => @agency, :reviewed => true) ...