Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Adkisson committed Aug 9, 2010
1 parent 7c5217a commit e4cd0ba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
14 changes: 7 additions & 7 deletions lib/modesty/metric/data.rb
Expand Up @@ -100,22 +100,22 @@ def track!(count=1, options={})
with = options[:with] || {}

with[:user] ||= Modesty.identity if Modesty.identity

self.experiments.each do |exp|
# only track the for the experiment group if
# the user has previously hit the experiment
identity_slug = exp.identity_for(self)
identity = if identity_slug
i = with[identity_slug]
raise IdentityError, """
identity = with[identity_slug]

if !identity && exp.metric_contexts.has_key?(self.slug)
raise IdentityError, <<-msg.squish
#{exp.inspect} requires #{self.inspect} to be tracked
with #{identity_slug.to_s.singularize.to_sym.inspect}.
It was tracked :with => #{with.inspect}
""".squish unless i
i
else
Modesty.identity
msg
end

if identity
alt = exp.data.get_cached_alternative(identity)
if alt
Expand Down
5 changes: 1 addition & 4 deletions spec/metric_spec.rb
@@ -1,11 +1,8 @@
require 'modesty'

describe Modesty::Metric, "Creating Metrics" do
before :all do
Modesty.set_store :redis, :mock => true
end

before :each do
Modesty.set_store :redis, :mock => true
Modesty.metrics.clear
end

Expand Down
14 changes: 7 additions & 7 deletions spec/significance_spec.rb
Expand Up @@ -106,7 +106,7 @@
end
end

(1..500).each do |i|
(1..500).each do |i|
Modesty.identify!(i)
Modesty.group :baz
Modesty.track! :foo, 1+rand(i)
Expand All @@ -133,15 +133,15 @@

it "uses the blocks for conversion" do
three_days = @e.stats[:special_conv].data(3.days.ago..Date.today)
three_days.should == [
[
@e.metrics(:control)[:foo].unique(:users, 3.days.ago..Date.today).sum,
@e.metrics(:control)[:foo].count(3.days.ago, :today).sum
],
three_days.sort.should == [
[
@e.metrics(:experiment)[:foo].unique(:users, 3.days.ago, :today).sum,
@e.metrics(:experiment)[:foo].count(3.days.ago, Date.today).sum
],
]
[
@e.metrics(:control)[:foo].unique(:users, 3.days.ago..Date.today).sum,
@e.metrics(:control)[:foo].count(3.days.ago, :today).sum
],
].sort
end
end

0 comments on commit e4cd0ba

Please sign in to comment.