Skip to content

fix(ForcedDecision): remove config-ready check from forced-decision apis #290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions lib/optimizely/optimizely_user_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def decide_all(options = nil)

def set_forced_decision(context, decision)
flag_key = context[:flag_key]
return false if @optimizely_client&.get_optimizely_config.nil?
return false if flag_key.nil?

@forced_decision_mutex.synchronize { @forced_decisions[context] = decision }
Expand All @@ -126,8 +125,6 @@ def find_forced_decision(context)
# @return - A variation key or nil if forced decisions are not set for the parameters.

def get_forced_decision(context)
return nil if @optimizely_client&.get_optimizely_config.nil?

find_forced_decision(context)
end

Expand All @@ -138,8 +135,6 @@ def get_forced_decision(context)
# @return - true if the forced decision has been removed successfully.

def remove_forced_decision(context)
return false if @optimizely_client&.get_optimizely_config.nil?

deleted = false
@forced_decision_mutex.synchronize do
if @forced_decisions.key?(context)
Expand All @@ -155,8 +150,6 @@ def remove_forced_decision(context)
# @return - true if forced decisions have been removed successfully.

def remove_all_forced_decision
return false if @optimizely_client&.get_optimizely_config.nil?

@forced_decision_mutex.synchronize { @forced_decisions.clear }
true
end
Expand Down
18 changes: 0 additions & 18 deletions spec/optimizely_user_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,6 @@
end

describe '#forced_decisions' do
it 'should return invalid status for invalid datafile in forced decision calls' do
user_id = 'test_user'
original_attributes = {}
invalid_project_instance = Optimizely::Project.new('Invalid datafile', nil, spy_logger, error_handler)
user_context_obj = Optimizely::OptimizelyUserContext.new(invalid_project_instance, user_id, original_attributes)
context = Optimizely::OptimizelyUserContext::OptimizelyDecisionContext.new('feature_1', nil)
decision = Optimizely::OptimizelyUserContext::OptimizelyForcedDecision.new('3324490562')

status = user_context_obj.set_forced_decision(context, decision)
expect(status).to be false
status = user_context_obj.get_forced_decision(context)
expect(status).to be_nil
status = user_context_obj.remove_forced_decision(context)
expect(status).to be false
status = user_context_obj.remove_all_forced_decision
expect(status).to be false
end

it 'should return status for datafile in forced decision calls' do
user_id = 'test_user'
original_attributes = {}
Expand Down