मैं इस विधि का परीक्षण करने की कोशिश कर रहा हूं जो एक ही पृष्ठ पर रीडायरेक्ट करता है लेकिन www के साथ। उपसर्ग अगर यह वहां नहीं है। यह रीडायरेक्ट करता है, लेकिन आरएसपीसी परीक्षण "< होने की अपेक्षित प्रतिक्रिया देता है: रीडायरेक्ट>, लेकिन < 200> था।" ऐसा क्यों है?रीडायरेक्ट रिटर्न के लिए आरएसपीसी परीक्षण 200
application_controller.rb
def check_uri
if request.subdomain.present? and request.subdomain.first != "www"
redirect_to request.protocol + "www." + request.host_with_port + request.fullpath if !/^www/.match(request.host)
end
end
application_controller_spec.rb #
describe :check_uri do
it "should redirect to www" do
{ :get => "http://sub.lvh.me:3000/accounts/sign_up" }.
should redirect_to "http://www.sub.lvh.me:3000/accounts/sign_up"
end
end
जब मैं डिबग मैं: (
rdb:1) p response
#<ActionController::TestResponse:0x0000010277d988 @writer=#<Proc:[email protected]/Users/mm/.rvm/gems/[email protected]/gems/actionpack-3.0.7/lib/action_dispatch/http/response.rb:43 (lambda)>, @block=nil, @length=0, @header={}, @status=200, @body=[], @cookie=[], @sending_file=false, @blank=false, @cache_control={}, @etag=nil>
आप प्रतिक्रिया डिबग किया? प्रतिक्रिया के लिए सामग्री क्या है? – e3matheus
क्या आपके पास application_controller में 'first_filter' के रूप में check_uri है? – dexter
हां, check_uri को पहले_फिल्टर के माध्यम से बुलाया जाता है। मैंने मूल पोस्ट में डीबग प्रतिक्रिया जोड़ा। – 99miles