Skip to content

Commit

Permalink
prepare 6.1.1 release (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaunchDarklyCI authored May 27, 2021
1 parent d61e4be commit a87fecb
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 138 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
mkmf.log
*.gem
.DS_Store
Gemfile.lock
116 changes: 0 additions & 116 deletions Gemfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
workingDirectory: $(System.DefaultWorkingDirectory)
script: |
ruby -v
gem install bundler:2.2.7
gem install bundler
bundle install
mkdir rspec
bundle exec rspec --format progress --format RspecJunitFormatter -o ./rspec/rspec.xml spec
6 changes: 3 additions & 3 deletions lib/ldclient-rb/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,15 @@ def make_output_event(event)
if @inline_users || is_debug
out[:user] = process_user(event)
else
out[:userKey] = event[:user].nil? ? nil : event[:user][:key]
out[:userKey] = event[:user][:key]
end
out[:reason] = event[:reason] if !event[:reason].nil?
out
when "identify"
{
kind: "identify",
creationDate: event[:creationDate],
key: event[:user].nil? ? nil : event[:user][:key].to_s,
key: event[:user][:key].to_s,
user: process_user(event)
}
when "custom"
Expand All @@ -464,7 +464,7 @@ def make_output_event(event)
if @inline_users
out[:user] = process_user(event)
else
out[:userKey] = event[:user].nil? ? nil : event[:user][:key]
out[:userKey] = event[:user][:key]
end
out[:metricValue] = event[:metricValue] if event.has_key?(:metricValue)
out[:contextKind] = event[:contextKind] if event.has_key?(:contextKind)
Expand Down
13 changes: 6 additions & 7 deletions lib/ldclient-rb/ldclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,12 @@ def evaluate_internal(key, user, default, event_factory)
return Evaluator.error_result(EvaluationReason::ERROR_CLIENT_NOT_READY, default)
end

unless user
@config.logger.error { "[LDClient] Must specify user" }
detail = Evaluator.error_result(EvaluationReason::ERROR_USER_NOT_SPECIFIED, default)
return detail
end

if !initialized?
if @store.initialized?
@config.logger.warn { "[LDClient] Client has not finished initializing; using last known values from feature store" }
Expand All @@ -421,13 +427,6 @@ def evaluate_internal(key, user, default, event_factory)
return detail
end

unless user
@config.logger.error { "[LDClient] Must specify user" }
detail = Evaluator.error_result(EvaluationReason::ERROR_USER_NOT_SPECIFIED, default)
@event_processor.add_event(event_factory.new_default_event(feature, user, default, detail.reason))
return detail
end

begin
res = @evaluator.evaluate(feature, user, event_factory)
if !res.events.nil?
Expand Down
22 changes: 11 additions & 11 deletions spec/ldclient_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,11 @@ def event_processor
client.variation("key", user, "default")
end

it "queues a feature event for an existing feature when user is nil" do
it "does not send an event if user is nil" do
config.feature_store.init({ LaunchDarkly::FEATURES => {} })
config.feature_store.upsert(LaunchDarkly::FEATURES, feature_with_value)
expect(event_processor).to receive(:add_event).with(hash_including(
kind: "feature",
key: "key",
version: 100,
user: nil,
value: "default",
default: "default",
trackEvents: true,
debugEventsUntilDate: 1000
))
expect(event_processor).not_to receive(:add_event)
expect(logger).to receive(:error)
client.variation("key", nil, "default")
end

Expand Down Expand Up @@ -313,6 +305,14 @@ def event_processor
))
client.variation_detail("key", user, "default")
end

it "does not send an event if user is nil" do
config.feature_store.init({ LaunchDarkly::FEATURES => {} })
config.feature_store.upsert(LaunchDarkly::FEATURES, feature_with_value)
expect(event_processor).not_to receive(:add_event)
expect(logger).to receive(:error)
client.variation_detail("key", nil, "default")
end
end

describe '#all_flags' do
Expand Down

0 comments on commit a87fecb

Please sign in to comment.