From ea1f6fb17bd01ae5d2213f183ada30341453ab7b Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 1 Oct 2013 18:57:02 +0000 Subject: [PATCH] * VRFS-746 - add config to read X-Real-IP instead of request.remote_ip --- web/app/controllers/application_controller.rb | 1 + web/app/controllers/sessions_controller.rb | 2 +- web/app/controllers/users_controller.rb | 3 +- web/app/helpers/application_helper.rb | 8 +++++ web/config/application.rb | 2 ++ web/spec/features/user_progression_spec.rb | 33 +++++++++++++++++++ 6 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 web/spec/features/user_progression_spec.rb diff --git a/web/app/controllers/application_controller.rb b/web/app/controllers/application_controller.rb index b73db5ca9..0018ee0be 100644 --- a/web/app/controllers/application_controller.rb +++ b/web/app/controllers/application_controller.rb @@ -1,5 +1,6 @@ class ApplicationController < ActionController::Base protect_from_forgery + include ApplicationHelper include SessionsHelper diff --git a/web/app/controllers/sessions_controller.rb b/web/app/controllers/sessions_controller.rb index ca75e1e0e..45e019b27 100644 --- a/web/app/controllers/sessions_controller.rb +++ b/web/app/controllers/sessions_controller.rb @@ -48,7 +48,7 @@ class SessionsController < ApplicationController # an email and whatnot. # # Also, should we grab their photo from facebook? - user = UserManager.new.signup(request.remote_ip, + user = UserManager.new.signup(remote_ip(), auth_hash[:info][:first_name], auth_hash[:info][:last_name], auth_hash[:info][:email], diff --git a/web/app/controllers/users_controller.rb b/web/app/controllers/users_controller.rb index 55904eaee..755a817aa 100644 --- a/web/app/controllers/users_controller.rb +++ b/web/app/controllers/users_controller.rb @@ -30,7 +30,8 @@ class UsersController < ApplicationController return end @signup_postback = load_postback(@invited_user) - load_location(request.remote_ip) + + load_location(remote_ip()) @user = User.new @user.musician = true # default the UI to musician as selected option diff --git a/web/app/helpers/application_helper.rb b/web/app/helpers/application_helper.rb index 827379344..b7045302b 100644 --- a/web/app/helpers/application_helper.rb +++ b/web/app/helpers/application_helper.rb @@ -18,4 +18,12 @@ module ApplicationHelper Rails.application.config.bugsnag_notify_release_stages.include? Rails.env end + def remote_ip + if Rails.application.config.proxy_use_x_real_ip + request.env['X-Real-IP'] + else + request.remote_ip + end + end + end diff --git a/web/config/application.rb b/web/config/application.rb index 812a535b1..89423a3a5 100644 --- a/web/config/application.rb +++ b/web/config/application.rb @@ -154,5 +154,7 @@ if defined?(Bundler) config.ga_ua = 'UA-44184562-2' # google analytics config.ga_suppress_admin = true + + config.proxy_use_x_real_ip = false end end diff --git a/web/spec/features/user_progression_spec.rb b/web/spec/features/user_progression_spec.rb new file mode 100644 index 000000000..00e60481a --- /dev/null +++ b/web/spec/features/user_progression_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +# these test will verify all of the user progression cases that rely on a javascript event (not bothering with instrumented models) + +describe "User Progression", :js => true, :type => :feature, :capybara_feature => true do + + subject { page } + + before(:all) do + Capybara.javascript_driver = :poltergeist + Capybara.current_driver = Capybara.javascript_driver + Capybara.default_wait_time = 10 + end + + + let(:user) { FactoryGirl.create(:user) } + + before(:each) do + sign_in_poltergeist user + end + + describe "downloaded client" do + + end + + describe "ran client" do + + end + + describe "social promoted" do + + end +end