Permalink
Browse files

bugfix

  • Loading branch information...
1 parent 7c5217a commit e4cd0ba83b1fdd25aa0ce8b59346f175c2108d8a Jay Adkisson committed Aug 9, 2010
Showing with 15 additions and 18 deletions.
  1. +7 −7 lib/modesty/metric/data.rb
  2. +1 −4 spec/metric_spec.rb
  3. +7 −7 spec/significance_spec.rb
View
@@ -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
View
@@ -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
View
@@ -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)
@@ -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.