2018-10-08 10:24:40 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::GonHelper do
|
2018-10-08 10:24:40 -04:00
|
|
|
let(:helper) do
|
|
|
|
Class.new do
|
|
|
|
include Gitlab::GonHelper
|
|
|
|
end.new
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#push_frontend_feature_flag' do
|
|
|
|
it 'pushes a feature flag to the frontend' do
|
|
|
|
gon = instance_double('gon')
|
2020-05-29 14:08:26 -04:00
|
|
|
thing = stub_feature_flag_gate('thing')
|
|
|
|
|
|
|
|
stub_feature_flags(my_feature_flag: thing)
|
2018-10-08 10:24:40 -04:00
|
|
|
|
|
|
|
allow(helper)
|
|
|
|
.to receive(:gon)
|
|
|
|
.and_return(gon)
|
|
|
|
|
|
|
|
expect(gon)
|
|
|
|
.to receive(:push)
|
|
|
|
.with({ features: { 'myFeatureFlag' => true } }, true)
|
|
|
|
|
2020-05-29 14:08:26 -04:00
|
|
|
helper.push_frontend_feature_flag(:my_feature_flag, thing)
|
2018-10-08 10:24:40 -04:00
|
|
|
end
|
|
|
|
end
|
2019-01-13 10:11:26 -05:00
|
|
|
|
|
|
|
describe '#default_avatar_url' do
|
|
|
|
it 'returns an absolute URL' do
|
|
|
|
url = helper.default_avatar_url
|
|
|
|
|
|
|
|
expect(url).to match(/^http/)
|
|
|
|
expect(url).to match(/no_avatar.*png$/)
|
|
|
|
end
|
|
|
|
end
|
2018-10-08 10:24:40 -04:00
|
|
|
end
|