Module: SplitTester::Controller::InstanceMethods
- Defined in:
- lib/split_tester/controller.rb
Instance Method Summary collapse
- #current_split_test_key ⇒ Object
-
#get_split_test_key ⇒ Object
Get the existing split_test_key from the session or the cookie.
- #is_split_test? ⇒ Boolean
-
#setup_split_testing ⇒ Object
If a split_test_key other than BASELINE exists, add the proper view path to the load paths used by ActionView.
Instance Method Details
#current_split_test_key ⇒ Object
38 39 40 |
# File 'lib/split_tester/controller.rb', line 38 def current_split_test_key @split_test_key ||= get_split_test_key end |
#get_split_test_key ⇒ Object
Get the existing split_test_key from the session or the cookie. If there isn’t one, or if the one isn’t a running test anymore assign the user a new key and store it. Don’t assign a key if it is a crawler. (This doesn’t feel right)
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/split_tester/controller.rb', line 25 def get_split_test_key return params[:force_test_key] if params[:force_test_key] && SplitTester::Base.active_test?(params[:force_test_key]) # just for testing return session[:split_test_key] if session[:split_test_key] && SplitTester::Base.active_test?(session[:split_test_key]) return session[:split_test_key] = [:split_test_key] if [:split_test_key] && SplitTester::Base.active_test?([:split_test_key]) if (request.user_agent =~ /\b(Baidu|Gigabot|Googlebot|libwww-perl|lwp-trivial|msnbot|SiteUptime|Slurp|WordPress|ZIBB|ZyBorg)\b/i) session[:split_test_key] = nil else session[:split_test_key] = SplitTester::Base.random_test_key [:split_test_key] = session[:split_test_key] end return session[:split_test_key] end |
#is_split_test? ⇒ Boolean
42 43 44 |
# File 'lib/split_tester/controller.rb', line 42 def is_split_test? current_split_test_key && current_split_test_key != 'BASELINE' end |
#setup_split_testing ⇒ Object
If a split_test_key other than BASELINE exists, add the proper view path to the load paths used by ActionView
15 16 17 18 19 |
# File 'lib/split_tester/controller.rb', line 15 def setup_split_testing return unless is_split_test? split_test_path = SplitTester::Base.view_path(current_split_test_key) prepend_view_path(split_test_path) if split_test_path end |