Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 18:40:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 18:40:28 +0300
commitb595cb0c1dec83de5bdee18284abe86614bed33b (patch)
tree8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/models/operations
parent2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff)
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/models/operations')
-rw-r--r--spec/models/operations/feature_flags_client_spec.rb70
1 files changed, 69 insertions, 1 deletions
diff --git a/spec/models/operations/feature_flags_client_spec.rb b/spec/models/operations/feature_flags_client_spec.rb
index 05988d676f3..2ed3222c65c 100644
--- a/spec/models/operations/feature_flags_client_spec.rb
+++ b/spec/models/operations/feature_flags_client_spec.rb
@@ -3,7 +3,15 @@
require 'spec_helper'
RSpec.describe Operations::FeatureFlagsClient do
- subject { create(:operations_feature_flags_client) }
+ let_it_be(:project) { create(:project) }
+
+ let!(:client) { create(:operations_feature_flags_client, project: project) }
+
+ subject { client }
+
+ before do
+ client.unleash_app_name = 'production'
+ end
describe 'associations' do
it { is_expected.to belong_to(:project) }
@@ -18,4 +26,64 @@ RSpec.describe Operations::FeatureFlagsClient do
expect(subject.token).not_to be_empty
end
end
+
+ describe '.update_last_feature_flag_updated_at!' do
+ subject { described_class.update_last_feature_flag_updated_at!(project) }
+
+ it 'updates the last_feature_flag_updated_at of the project client' do
+ freeze_time do
+ expect { subject }.to change { client.reload.last_feature_flag_updated_at }.from(nil).to(Time.current)
+ end
+ end
+ end
+
+ describe '#unleash_api_version' do
+ subject { client.unleash_api_version }
+
+ it { is_expected.to eq(described_class::DEFAULT_UNLEASH_API_VERSION) }
+ end
+
+ describe '#unleash_api_features' do
+ subject { client.unleash_api_features }
+
+ it 'fetches' do
+ expect(Operations::FeatureFlag).to receive(:for_unleash_client).with(project, 'production').once
+
+ subject
+ end
+
+ context 'when unleash app name is not set' do
+ before do
+ client.unleash_app_name = nil
+ end
+
+ it 'does not fetch' do
+ expect(Operations::FeatureFlag).not_to receive(:for_unleash_client)
+
+ subject
+ end
+ end
+ end
+
+ describe '#unleash_api_cache_key' do
+ subject { client.unleash_api_cache_key }
+
+ it 'constructs the cache key' do
+ is_expected.to eq("api_version:#{client.unleash_api_version}"\
+ ":app_name:#{client.unleash_app_name}"\
+ ":updated_at:#{client.last_feature_flag_updated_at.to_i}")
+ end
+
+ context 'when unleash app name is not set' do
+ before do
+ client.unleash_app_name = nil
+ end
+
+ it 'constructs the cache key without unleash app name' do
+ is_expected.to eq("api_version:#{client.unleash_api_version}"\
+ ":app_name:"\
+ ":updated_at:#{client.last_feature_flag_updated_at.to_i}")
+ end
+ end
+ end
end