docbrown/spec
Jeremy Friesen fe2e53cc50
Moving Experiments into AbExperiment namespace (#17532)
* Moving Experiments into AbExperiment namespace

This commit entails two major concepts:

1. Extracting logic out of a worker.
2. Cleaning the conditions in which we convert experiments.

In addition, I revisited some spec names to tidy them up for
clarification and structure.

**Extracting Logic...**

For workers, my preference is that they be a simple router to another
object.  A non-worker object, with it's initialize method, can both
better manage instance variables.  Further, workers are somewhat "flat"
in hierarchy,

In this case, having the AbExperiment be knowledgeable both in setting
the experiment and handling conversions makes (to me) organizational
sense.  For example, the AbExperiment is constructed as a wrapper to the
FieldTest gem.  But the RecordFieldTestEventWorker had knowledge of
FieldTest.

With this refactor, it does not have that knowledge.  This also provided
an opportunity to replace magic strings with constants.

**Cleaning the conditions...**

This relates directly to and closes forem/forem#17530.  I was looking at
the experiments after 2 days, and realized that there shouldn't be
results for
`user_views_pages_on_at_least_nine_different_days_within_two_weeks`;
after all the experiment started 2 days ago, how can we have results
that look at 2 weeks.

By adding the "max" function calls, we ensure a clear boundary of
"before the experiment began" versus "while the experiment is running".

Closes forem/forem#17530

* Update spec/models/ab_experiment_spec.rb

Co-authored-by: Mac Siri <krairit.siri@gmail.com>

* Apply suggestions from code review

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
2022-05-03 21:34:12 -04:00
..
controllers/concerns 15 minute fix: Add default argument to JsonApiSortParam (#13369) 2021-04-14 10:32:07 +07:00
decorators Routine Rubocop fixes (#16838) 2022-03-09 09:32:50 -05:00
factories Remove GDPR from the "users" namespace (#17536) 2022-05-03 19:42:20 +02:00
fixtures Allowing VariantQuery for Feed Generation (#17382) 2022-04-21 11:07:09 -04:00
forms Routine Rubocop fixes (#16838) 2022-03-09 09:32:50 -05:00
generator Add service generator (#11265) 2020-11-10 09:09:35 +07:00
helpers Sanitize URL before parsing (#17559) 2022-05-03 14:28:20 -04:00
initializers A suspended user returns 403 instead of 500 (#16408) 2022-02-04 09:42:23 -05:00
lib Use Sidekiq::Job module alias for Sidekiq::Worker (#17526) 2022-05-02 11:12:58 -05:00
liquid_tags Sharpen RegEx that matches Forem-specific links (#17500) 2022-04-29 11:34:32 -04:00
mailers "Reply to" and "From" Email addresses for SMTP Configurations (#16499) 2022-02-16 16:14:54 +02:00
models Moving Experiments into AbExperiment namespace (#17532) 2022-05-03 21:34:12 -04:00
policies Encapsulating the "why we hide/show" something (#17166) 2022-04-11 13:40:16 -04:00
queries Community Wellness badge (#17394) 2022-04-29 12:38:40 -06:00
refinements Update data exporter to handle admin send (#10274) 2020-10-26 18:00:56 -04:00
requests Remove GDPR from the "users" namespace (#17536) 2022-05-03 19:42:20 +02:00
routing Remove profile admin feature flag (#17194) 2022-04-11 09:27:35 -05:00
sanitizers Don't sanitize anchor elements with no href (#16667) 2022-02-22 11:27:38 -06:00
serializers Refactoring to add helper method (#16064) 2022-01-12 11:21:44 -05:00
services Replace Ahoy metric logging with ForemStatsClient on Community Wellness Badge service (#17542) 2022-05-03 09:31:38 -06:00
support Use Sidekiq::Job module alias for Sidekiq::Worker (#17526) 2022-05-02 11:12:58 -05:00
system Remove name from invitation flow (#17438) 2022-05-03 09:33:12 +01:00
tasks Make home link an admin-customisable navigation link (#16268) 2022-02-01 09:27:09 +00:00
uploaders Remove Remaining logo_svg Code (#16291) 2022-02-22 12:05:16 -07:00
validators Don't raise error when empty community emoji setting submitted (#15723) 2021-12-17 09:29:55 -06:00
view_objects Avoid using robohash for factory generated article cover images (#17024) 2022-03-28 14:01:29 -05:00
views Adding logic to hide Create Post on empty dashboard (#17149) 2022-04-11 13:52:35 -04:00
workers Moving Experiments into AbExperiment namespace (#17532) 2022-05-03 21:34:12 -04:00
i18n_spec.rb Show missing translation keys when test fails (#16637) 2022-02-17 16:21:29 -06:00
rails_helper.rb Moving Experiments into AbExperiment namespace (#17532) 2022-05-03 21:34:12 -04:00
spec_helper.rb Bump to Rails 7.0.2.2 MVP (#15908) 2022-03-30 15:00:33 -04:00