SORU
18 Mayıs 2011, ÇARŞAMBA


Rspec test redirect_to :geri

Nasıl test redirect_to :rspec geri musunuz?

Anladım

ActionController::RedirectBackError:
       No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successfully. If this is a test, make sure to specify request.env["HTTP_REFERER"].

Nasıl benim test HTTP_REFERER ayarı falan var mı?

CEVAP
18 Temmuz 2011, PAZARTESİ


RSpec kullanarak, before bloğundaki işlem yapmaya başlamadan önce ayarlayabilirsiniz. Bu özet doğrudan test ayarlamaya çalıştım ama ne zaman, nereye koyduğumu olursa olsun işe gelmedi, ama önce blok işe yarıyor.

describe BackController < ApplicationController do
  before(:each) do
    request.env["HTTP_REFERER"] = "where_i_came_from"
  end

  describe "GET /goback" do
    it "redirects back to the referring page" do
      get 'goback'
      response.should redirect_to "where_i_came_from"
    end
  end
end

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Alexey - servant of Christ

    Alexey - ser

    15 EYLÜL 2007
  • kindlechatmail

    kindlechatma

    25 AĞUSTOS 2010
  • Tom Megalis

    Tom Megalis

    18 NİSAN 2006