Skip to content

Commit

Permalink
Coveralls coverage (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
rashidsp authored and mikeproeng37 committed Apr 5, 2018
1 parent c10c123 commit a80d4ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
12 changes: 4 additions & 8 deletions lib/optimizely/project_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,8 @@ def get_forced_variation(experiment_key, user_id)
experiment = get_experiment_from_key(experiment_key)
experiment_id = experiment['id'] if experiment
# check for nil and empty string experiment ID
if experiment_id.nil? || experiment_id.empty?
# this case is logged in get_experiment_from_key
return nil
end
# this case is logged in get_experiment_from_key
return nil if experiment_id.nil? || experiment_id.empty?

unless experiment_to_variation_map.key? experiment_id
@logger.log(Logger::DEBUG, "No experiment '#{experiment_key}' mapped to user '#{user_id}' "\
Expand All @@ -307,10 +305,8 @@ def get_forced_variation(experiment_key, user_id)
variation_key = variation['key'] if variation

# check if the variation exists in the datafile
if variation_key.empty?
# this case is logged in get_variation_from_id
return nil
end
# this case is logged in get_variation_from_id
return nil if variation_key.empty?

@logger.log(Logger::DEBUG, "Variation '#{variation_key}' is mapped to experiment '#{experiment_key}' "\
"and user '#{user_id}' in the forced variation map")
Expand Down
28 changes: 4 additions & 24 deletions spec/notification_center_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@

before(:context) do
class CallBack
def call(args)
args
end
def call; end
end

@callback = CallBack.new
Expand Down Expand Up @@ -108,9 +106,7 @@ def call(args)
it 'should add and return notification ID when multiple
valid callbacks are added for a single notification type' do
class CallBackSecond
def call(_args)
'Test multi listner.'
end
def call; end
end

@callback_second = CallBackSecond.new
Expand Down Expand Up @@ -166,12 +162,6 @@ def call(_args)
let(:notification_center) { Optimizely::NotificationCenter.new(spy_logger, raise_error_handler) }
before(:example) do
@inner_notification_center = notification_center
class CallBackSecond
def call(_args)
'Test remove notification.'
end
end

@callback_second = CallBackSecond.new
@callback_reference_second = @callback_second.method(:call)
# add a callback for multiple notification types
Expand Down Expand Up @@ -321,19 +311,11 @@ def call(_args)
let(:notification_center) { Optimizely::NotificationCenter.new(spy_logger, raise_error_handler) }
before(:example) do
@inner_notification_center = notification_center
class CallBackSecond
def call(_args)
'Test remove notification.'
end
end

@callback_second = CallBackSecond.new
@callback_reference_second = @callback_second.method(:call)

class CallBackThird
def call(_args)
'Test remove notification.'
end
def call; end
end

@callback_third = CallBackThird.new
Expand Down Expand Up @@ -406,9 +388,7 @@ def deliver_two(_args)
@logger.log Logger::INFO, 'delivered two.'
end

def deliver_three(_args)
@logger.log Logger::INFO, 'delivered three.'
end
def deliver_three; end
end
let(:raise_error_handler) { Optimizely::RaiseErrorHandler.new }
let(:invitation) { Invitation.new(spy_logger) }
Expand Down

0 comments on commit a80d4ac

Please sign in to comment.