Permalink
Browse files

fixed a ruby 1.8.7 issue in sessions

  • Loading branch information...
1 parent 5639a1a commit 50321565cfe65ac35c08c78d7d8762c2aeeab5ef @asmuth committed May 4, 2012
Showing with 20 additions and 20 deletions.
  1. +3 −3 lib/fnordmetric/session.rb
  2. +17 −17 spec/session_spec.rb
@@ -97,8 +97,8 @@ def add_event(event)
end
def add_event_data(event)
- event.each do |key,value|
- add_data(key, value) unless key[0]=="_"
+ event.each do |key, value|
+ add_data(key, value) unless key.to_s.starts_with?("_")
end
end
@@ -109,7 +109,7 @@ def add_data(key, value)
def fetch_data!
@data = Hash.new
@redis.hgetall(redis_key(:data)).each do |key, value|
- if key[0]=="_"
+ if key.to_s.starts_with?("_")
fetch_meta_key(key, value)
else
@data[key.intern] = value
View
@@ -25,7 +25,7 @@
end
it "should add a new session on intialize" do
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => @event,
:session_data_ttl => 10,
@@ -35,7 +35,7 @@
end
it "should add a new session on intialize and hash the session token" do
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => @event,
:session_data_ttl => 10,
@@ -45,7 +45,7 @@
end
it "should add a new session on intialize and set the timestamp as score" do
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => @event,
:session_data_ttl => 10,
@@ -57,7 +57,7 @@
it "should update the timestamp on a existing session" do
@redis.zadd(@sessions, @now-10, @md5_key)
@redis.zscore(@sessions, @md5_key).to_i.should == @now-10
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => @event,
:session_data_ttl => 10,
@@ -67,7 +67,7 @@
end
it "should add the event_id to the session-event set on a new session" do
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => @event,
:session_data_ttl => 10,
@@ -82,7 +82,7 @@
:_type => "_set_name",
:name => "Horst Mayer"
)
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => event_data,
:session_data_ttl => 10,
@@ -97,7 +97,7 @@
:_type => "_set_picture",
:url => "http://myhost/mypic.jpg"
)
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => event_data,
:session_data_ttl => 10,
@@ -113,7 +113,7 @@
:fnord => "blubb",
:foobar => "123"
)
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => event_data,
:session_data_ttl => 10,
@@ -130,7 +130,7 @@
:fnord => "blubb",
:foobar => "123"
)
- Session.create(
+ FnordMetric::Session.create(
:namespace_prefix => @namespace,
:event => event_data,
:session_data_ttl => 10,
@@ -159,32 +159,32 @@
it "should find all sessions" do
create_session("sess533", @now, {})
create_session("sess343", @now, {})
- Session.all(@opts).length.should == 2
+ FnordMetric::Session.all(@opts).length.should == 2
end
it "should find all sessions and return session objects" do
create_session("sess523", @now, {})
- Session.all(@opts).first.should be_a(FnordMetric::Session)
+ FnordMetric::Session.all(@opts).first.should be_a(FnordMetric::Session)
end
it "should find a session and return a session object" do
create_session("sess223", @now, {})
- sess = Session.find(Digest::MD5.hexdigest("sess223"), @opts)
+ sess = FnordMetric::Session.find(Digest::MD5.hexdigest("sess223"), @opts)
sess.should be_a(FnordMetric::Session)
sess.session_key.should == Digest::MD5.hexdigest("sess223")
end
it "should find a sessions and return a session object with data" do
create_session("sess123", @now, { :fnord => "blubb" })
- sess = Session.find(Digest::MD5.hexdigest("sess123"), @opts)
+ sess = FnordMetric::Session.find(Digest::MD5.hexdigest("sess123"), @opts)
sess.fetch_data!
sess.data(:fnord).should == "blubb"
end
it "should not include special attributes in data" do
event_data = { :_name => "Horst Mayer", :_picture => "http://myhost/mypic.jpg" }
create_session("sess173", @now, event_data)
- sess = Session.find(Digest::MD5.hexdigest("sess173"), @opts)
+ sess = FnordMetric::Session.find(Digest::MD5.hexdigest("sess173"), @opts)
sess.fetch_data!
sess.data(:_name).should == nil
sess.data(:_picture).should == nil
@@ -193,15 +193,15 @@
it "should find a session and return a session object with picture" do
event_data = { :_name => "Horst Mayer", :_picture => "http://myhost/mypic.jpg" }
create_session("sess163", @now, event_data)
- sess = Session.find(Digest::MD5.hexdigest("sess163"), @opts)
+ sess = FnordMetric::Session.find(Digest::MD5.hexdigest("sess163"), @opts)
sess.fetch_data!
sess.picture.should == "http://myhost/mypic.jpg"
end
it "should find a session and return a session object with name" do
event_data = { :_name => "Horst Mayer", :_picture => "http://myhost/mypic.jpg" }
create_session("sess143", @now, event_data)
- sess = Session.find(Digest::MD5.hexdigest("sess143"), @opts)
+ sess = FnordMetric::Session.find(Digest::MD5.hexdigest("sess143"), @opts)
sess.fetch_data!
sess.name.should == "Horst Mayer"
end
@@ -210,7 +210,7 @@
sesshash = create_session("sess923", @now, {})
@redis_wrap.zadd("#{@namespace}-session-#{sesshash}-events", @now, "shmoo")
@redis_wrap.zadd("#{@namespace}-session-#{sesshash}-events", @now, "fnord")
- sess = Session.find(sesshash, @opts)
+ sess = FnordMetric::Session.find(sesshash, @opts)
sess.fetch_event_ids!
sess.event_ids.should include("shmoo")
sess.event_ids.should include("fnord")

0 comments on commit 5032156

Please sign in to comment.