IMil
0
Q:

redirect_back fallback_location root_path rspec

module RedirectBack
  def from(url)
    request.env['HTTP_REFERER'] = url
  end
end
0
RSpec.describe InterestsController, type: :controller do
  describe 'POST #create' do
    context 'with valid attributes' do
      it 'redirects to referer' do
        from about_path
        post :create, params: { interest: attributes_for(:interest) }
        expect(response).to redirect_to about_url
      end
    end
  end
end
0
RSpec.configure do |config|
  config.include RedirectBack
end
0

New to Communities?

Join the community