docbrown/spec/models/ab_experiment_spec.rb
Jeremy Friesen 6269aa4108
Proposing a new feed experiment (#15789)
* Proposing a new feed experiment

This commit involves tweaking a few subtle aspects of the challenger:

1) Remove the sort by published date on the relevance score.  The
   articles will now be listed in the order of perceived relevance.
2) Disable a few levers that did little.  There really aren't any
   `articles.featured = true` articles in the database.
3) Gently increase the weight of each comment in a linear manner.
4) Give a little more weight to posts that don't have followed tags.

In addition, it involves renaming the conversions to better convey their
implementation.  This renaming helps create more descriptive labels for
the test results at `/admin/abtests`.

This commit also adds logic to repurpose the AbExperiment feed_strategy
logic; I envision adjusting the weighted feed strategy levers with some
frequency.

Per discussions, I'm also disabling the "not logged in" feed testing.
We'll use the LargeForemExperimental for this.

* Flipping attribute name to positive

Mentally "not disabled" is harder to parse than "enabled".  This change
helps with setting an optimistic attribute.

* Bump for travis

* Bump for travis

* Removing file committed by mistake

* Extracting method
2022-01-03 14:38:14 -05:00

60 lines
2.3 KiB
Ruby

require "rails_helper"
RSpec.describe AbExperiment do
let(:controller) { ApplicationController.new }
let(:user) { double }
describe ".get" do
before do
allow(controller).to receive(:field_test).with(:feed_strategy_round_2, participant: user).and_return("special")
end
context "with :feed_strategy_round_2 experiment" do
it "repurposes the :feed_strategy experiment" do
expect(described_class.get(experiment: :feed_strategy_round_2,
user: user,
controller: controller,
default_value: "default")).to eq("special")
end
end
context "with :feed_strategy experiment" do
before do
allow(controller).to receive(:field_test).with(:feed_strategy, participant: user).and_return("special")
end
let(:experiment) { :feed_strategy }
it "returns an inquirable string" do
result = described_class.get(experiment: :feed_strategy,
user: user,
controller: controller,
default_value: "default")
expect(result).to eq("special")
expect(result).to be_special
end
it "allows for an config override" do
result = described_class.get(experiment: :feed_strategy,
user: user,
controller: controller,
default_value: "special",
config: { "AB_EXPERIMENT_FEED_STRATEGY" => "not_special" })
expect(result).to eq("not_special")
expect(result).to be_not_special
end
it "returns the default value when the FeatureFlipper is off" do
allow(FeatureFlag).to receive(:accessible?).with(:ab_experiment_feed_strategy).and_return(false)
result = described_class.get(experiment: :feed_strategy,
user: user,
controller: controller,
default_value: "special",
config: { "AB_EXPERIMENT_FEED_STRATEGY" => "not_special" })
expect(result).to eq("special")
expect(result).to be_special
end
end
end
end