Commit c3dd769c authored by Kerri Miller's avatar Kerri Miller

Merge branch '267759-suggest-pipeline-is-not-loading-dismiss-callout-paths' into 'master'

Enable force experiment use for grape api endpoints

See merge request gitlab-org/gitlab!45292
parents 884bdb93 e8870e72
......@@ -82,6 +82,7 @@ module IssuablesHelper
when Issue
IssueSerializer
when MergeRequest
opts[:experiment_enabled] = :suggest_pipeline if experiment_enabled?(:suggest_pipeline) && opts[:serializer] == 'widget'
MergeRequestSerializer
end
......
......@@ -67,15 +67,15 @@ class MergeRequestWidgetEntity < Grape::Entity
)
end
expose :user_callouts_path, if: -> (*) { Gitlab::Experimentation.enabled?(:suggest_pipeline) } do |_merge_request|
expose :user_callouts_path, if: -> (_, opts) { opts[:experiment_enabled] == :suggest_pipeline } do |_merge_request|
user_callouts_path
end
expose :suggest_pipeline_feature_id, if: -> (*) { Gitlab::Experimentation.enabled?(:suggest_pipeline) } do |_merge_request|
expose :suggest_pipeline_feature_id, if: -> (_, opts) { opts[:experiment_enabled] == :suggest_pipeline } do |_merge_request|
SUGGEST_PIPELINE
end
expose :is_dismissed_suggest_pipeline, if: -> (*) { Gitlab::Experimentation.enabled?(:suggest_pipeline) } do |_merge_request|
expose :is_dismissed_suggest_pipeline, if: -> (_, opts) { opts[:experiment_enabled] == :suggest_pipeline } do |_merge_request|
current_user && current_user.dismissed_callout?(feature_name: SUGGEST_PIPELINE)
end
......
......@@ -369,4 +369,35 @@ RSpec.describe IssuablesHelper do
expect(helper.sidebar_milestone_tooltip_label(milestone)).to eq('&lt;img onerror=alert(1)&gt;<br/>Milestone')
end
end
describe '#serialize_issuable' do
context 'when it is a merge request' do
let(:merge_request) { build(:merge_request) }
let(:user) { build(:user) }
before do
allow(helper).to receive(:current_user) { user }
end
it 'has suggest_pipeline experiment enabled' do
allow(helper).to receive(:experiment_enabled?).with(:suggest_pipeline) { true }
expect_next_instance_of(MergeRequestSerializer) do |serializer|
expect(serializer).to receive(:represent).with(merge_request, { serializer: 'widget', experiment_enabled: :suggest_pipeline })
end
helper.serialize_issuable(merge_request, serializer: 'widget')
end
it 'suggest_pipeline experiment disabled' do
allow(helper).to receive(:experiment_enabled?).with(:suggest_pipeline) { false }
expect_next_instance_of(MergeRequestSerializer) do |serializer|
expect(serializer).to receive(:represent).with(merge_request, { serializer: 'widget' })
end
helper.serialize_issuable(merge_request, serializer: 'widget')
end
end
end
end
......@@ -299,9 +299,7 @@ RSpec.describe MergeRequestWidgetEntity do
describe 'user callouts' do
context 'when suggest pipeline feature is enabled' do
before do
stub_experiment(suggest_pipeline: true)
end
subject { described_class.new(resource, request: request, experiment_enabled: :suggest_pipeline).as_json }
it 'provides a valid path value for user callout path' do
expect(subject[:user_callouts_path]).to eq '/-/user_callouts'
......@@ -335,10 +333,6 @@ RSpec.describe MergeRequestWidgetEntity do
end
context 'when suggest pipeline feature is not enabled' do
before do
stub_experiment(suggest_pipeline: false)
end
it 'provides no valid value for user callout path' do
expect(subject[:user_callouts_path]).to be_nil
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment