Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Stub out everything and cover with specs. version 0.0.1

  • Loading branch information...
commit cfad3ca01c3a11b07d187bf8f922c8b5e344c0ae 1 parent 8f7361d
@johnmetta authored
View
13 Gemfile.lock
@@ -2,7 +2,7 @@ PATH
remote: .
specs:
acts_as_stream (0.0.1)
- rails (~> 3.2.2)
+ rails (~> 3.2)
redis
GEM
@@ -35,6 +35,12 @@ GEM
activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
+ acts_as_amico (0.2.7)
+ amico
+ rails (~> 3.1)
+ redis
+ amico (2.0.0)
+ redis
arel (3.0.2)
builder (3.0.0)
diff-lcs (1.1.3)
@@ -57,8 +63,8 @@ GEM
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
- jquery-rails (1.0.19)
- railties (~> 3.0)
+ jquery-rails (2.0.1)
+ railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
json (1.6.5)
mail (2.4.3)
@@ -129,6 +135,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ acts_as_amico
acts_as_stream!
factory_girl_rails
fakeweb
View
1  Guardfile
@@ -14,6 +14,7 @@ end
guard 'rspec', :version => 2 do
watch(%r{^lib/acts_as_stream/.+\.rb$}) {|m| "spec/#{m[1]}_spec.rb"}
+ watch(%r{^lib/streamable_object/.+\.rb$}) {|m| "spec/#{m[1]}_spec.rb"}
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
View
2  MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright 2012 YOURNAME
+Copyright (c) 2012 John Metta
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
81 README.md
@@ -0,0 +1,81 @@
+# ActsAsStream
+A highly configurable activity stream system built on top of Redis
+
+## Installation
+
+Install
+
+```ruby
+gem install acts_as_stream
+```
+
+or in your ```Gemfile```
+
+```ruby
+gem 'acts_as_stream'
+```
+
+Make sure your redis server is running! Redis configuration is outside the scope of this README, but
+check out the [Redis documentation](http://redis.io/documentation).
+
+## Basic Usage
+```ruby
+ActsAsStream.configure do |config|
+ redis = Redis.new(:db => 15)
+ config.redis = redis
+ config.namespace = :redis_stream_test
+ config.activity_scope = :activity
+ config.activity_key = :activity
+ config.activity_attr = :id
+ config.activity_incr = :activity_counter
+ config.page_size = 25
+end
+
+class User < ActiveRecord::Base
+ acts_as_stream
+ acts_as_amico # <- not necessary, any follower system will do
+
+ # Define an all_followers method which will return a list of Redis keys, one per follower
+ def all_followers
+ get_all(:followers).map{|id| User.find(id.to_i)}.map{|u| u.following_key}
+ end
+
+end
+
+actor = User.create
+follower = User.create
+
+follower.follow! actor # <- acts_as_amico syntax, follow whatever your follow system is
+
+user.register_activity! 'some smart, perhaps parsable, string package– say, perhaps, JSON'
+(1..5).each{|i| user.register_activity! "activity #{i}"}
+
+follower.activity_count
+ => 6
+
+follower.get_activity.first
+ => 'some smart, perhaps parsable, string package– say, perhaps, JSON'
+```
+
+## Advanced Usage
+
+## Configuration
+
+## Future Plans
+
+ * Clean up the ActiveResource integration and figure out why :name is so dangerous.
+ * Put activity creation/update into a background worker queue
+
+## Contributing to acts_as_stream
+
+* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
+* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
+* Fork the project
+* Start a feature/bugfix branch
+* Commit and push until you are happy with your contribution
+* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
+* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
+
+## Copyright
+
+Copyright (c) John Metta. See MIT-LICENSE for further details.
View
3  README.rdoc
@@ -1,3 +0,0 @@
-= ActsAsStream
-
-This project rocks and uses MIT-LICENSE.
View
2  Rakefile
@@ -16,7 +16,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'ActsAsStream'
rdoc.options << '--line-numbers'
- rdoc.rdoc_files.include('README.rdoc')
+ rdoc.rdoc_files.include('README.md')
rdoc.rdoc_files.include('lib/**/*.rb')
end
View
15 acts_as_stream.gemspec
@@ -7,18 +7,19 @@ require "acts_as_stream/version"
Gem::Specification.new do |s|
s.name = "acts_as_stream"
s.version = ActsAsStream::VERSION
- s.authors = ["TODO: Your name"]
- s.email = ["TODO: Your email"]
- s.homepage = "TODO"
- s.summary = "TODO: Summary of ActsAsStream."
- s.description = "TODO: Description of ActsAsStream."
+ s.authors = ["John Metta"]
+ s.email = ["mail@johnmetta.com"]
+ s.homepage = "http://github.com/mettadore/acts_as_stream.git"
+ s.summary = "Rails injectable Redis-backed activity stream system"
+ s.description = "Rails injectable Redis-backed activity stream system"
- s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
+ s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"]
- s.add_dependency "rails", "~> 3.2.2"
+ s.add_dependency "rails", "~> 3.2"
s.add_dependency "redis"
s.add_development_dependency "sqlite3"
+ s.add_development_dependency "acts_as_amico"
s.add_development_dependency "rspec-rails"
s.add_development_dependency "spork", '~> 0.9.0.rc'
s.add_development_dependency 'guard-rspec'
View
75 lib/acts_as_stream/connector.rb
@@ -1,27 +1,31 @@
module ActsAsStream
module Connector
- def register_new_activity! options = {}
- options.assert_valid_keys(:key, :package)
- return if options[:key].nil? or options[:package].nil?
-
- #Add the key and package to the system
- ActsAsStream.redis.set "#{options[:key]}:#{count}", options[:package]
- #Add a timed key, scored by id, and an id-based key
- score = Time.now.to_i
- ActsAsStream.redis.zadd "#{base_key}:time:#{score}", count, count
- ActsAsStream.redis.set "#{base_key}:id:#{count}", score
- increment!
+ def register_new_activity! package = nil
+ return if package.nil?
+ id = increment!
+ this_time = time
+ ActsAsStream.redis.multi do
+ #Add the key and package to the system
+ ActsAsStream.redis.set "#{base_key}:#{id}", package
+ #Add a timed key, scored by id, and an id-based key
+ ActsAsStream.redis.zadd "#{base_key}:time:#{this_time}", id, id
+ ActsAsStream.redis.set "#{base_key}:id:#{id}", this_time
+ end
+ raise "### Unable to set Time keys!" if ActsAsStream.redis.get("#{base_key}:id:#{id}") != this_time.to_s
+ #return the current activity ID
+ id
end
- def deregister_activity! options = {}
- options.assert_valid_keys(:key, :id)
- return if options[:key].nil? or options[:id].nil?
- ActsAsStream.redis.del "#{options[:key]}:#{options[:id]}"
- score = ActsAsStream.redis.get "#{options[:key]}:id:#{options[:id]}"
- ActsAsStream.redis.zrem "#{base_key}:time:#{score}", options[:id]
- ActsAsStream.redis.del "#{base_key}:id:#{options[:id]}"
- deregister_followers! :activity_id => options[:id]
+ def deregister_activity! ident
+ return if ident.nil?
+ score = ActsAsStream.redis.get "#{base_key}:id:#{ident}"
+ ActsAsStream.redis.multi do
+ ActsAsStream.redis.del "#{base_key}:#{ident}"
+ ActsAsStream.redis.zrem "#{base_key}:time:#{score}", ident
+ ActsAsStream.redis.del "#{base_key}:id:#{ident}"
+ end
+ deregister_followers! ident
end
def register_followers! options = {}
@@ -38,20 +42,43 @@ def register_followers! options = {}
end
end
- def deregister_followers! options = {}
- options.assert_valid_keys :activity_id
- followers_key = "#{base_key}:followers:#{options[:activity_id]}"
+ def deregister_followers! activity_id = nil
+ return if activity_id.nil?
+ followers_key = "#{base_key}:followers:#{activity_id}"
len = ActsAsStream.redis.llen followers_key
followers = ActsAsStream.redis.lrange followers_key, 0, len
return if followers.nil?
ActsAsStream.redis.multi do
followers.each do |f|
- ActsAsStream.redis.zrem f, options[:activity_id]
+ ActsAsStream.redis.zrem f, activity_id
end
- ActsAsStream.redis.del "#{base_key}:followers:#{options[:activity_id]}"
+ ActsAsStream.redis.del "#{base_key}:followers:#{activity_id}"
end
end
+ def get_activity_for follower_key, options = {}
+ options = {:page => 1, :page_size => ActsAsStream.page_size}.merge options
+ options[:page] = 1 if options[:page] < 1
+
+ if options[:page] > total_pages(follower_key, options[:page_size])
+ options[:page] = total_pages(follower_key, options[:page_size])
+ end
+
+ starting_offset = ((options[:page] - 1) * options[:page_size])
+ starting_offset = 0 if starting_offset < 0
+ ending_offset = (starting_offset + options[:page_size]) - 1
+
+ ActsAsStream.redis.zrevrange(follower_key, starting_offset, ending_offset, :with_scores => false).map{|i| get_activity i}
+ end
+
+ def get_activity id
+ ActsAsStream.redis.get "#{base_key}:#{id}"
+ end
+
+ def total_pages key, page_size = ActsAsStream.page_size
+ (ActsAsStream.redis.zcard(key) / page_size.to_f).ceil
+ end
+
def count
ActsAsStream.redis.get(ActsAsStream.activity_incr).to_i
end
View
36 lib/acts_as_stream/streamable_object.rb
@@ -8,10 +8,11 @@ def self.included base
module ClassMethods
def acts_as_stream options = {}
- cattr_accessor :activity_scope, :activity_attr, :activity_key_base
+ cattr_accessor :activity_scope, :activity_attr, :activity_key_base, :followers_attr
self.activity_scope = options[:activity_scope] || ActsAsStream.activity_scope
self.activity_attr = options[:activity_attr] || ActsAsStream.activity_attr
self.activity_key_base = "#{ActsAsStream.namespace}:#{self.activity_scope}"
+ self.followers_attr = options[:followers_attr] || :all_followers
send :include, ActsAsStream::StreamableObject::InstanceMethods
end
end
@@ -27,6 +28,39 @@ def activity_key
def following_key
"#{ActsAsStream.namespace}:#{self.class.name.downcase}:#{activity_id}:#{activity_scope}"
end
+
+ def register_activity! package
+ act_id = ActsAsStream.register_new_activity! package
+ self.register_followers! act_id
+ end
+
+ def delete_activity act_id
+ ActsAsStream.deregister_activity! act_id
+ end
+
+ def register_followers! act_id
+ ActsAsStream.register_followers! :following_keys => get_follower_keys, :activity_id => act_id
+ end
+
+ def get_follower_keys
+ send(followers_attr)
+ end
+
+ def get_activity options = {}
+ if options == :all
+ ActsAsStream.get_activity_for following_key,
+ :page_size => activity_count,
+ :page => 1
+ else
+ options = {:page_size => ActsAsStream.page_size, :page => 1}.merge options
+ ActsAsStream.get_activity_for following_key, :page_size => options[:page_size], :page => options[:page]
+ end
+ end
+
+ def activity_count
+ ActsAsStream.redis.zcard following_key
+ end
+
end
end
end
View
78 spec/connector_spec.rb
@@ -11,23 +11,26 @@
@package = test_package
end
+ it "should properly set keys" do
+
+ end
+
it "should get the counter incrementor" do
counter = ActsAsStream.count
counter.should be(0)
end
it "should register a new activity" do
- ActsAsStream.register_new_activity! :key => @key, :package => @package
- key = "#{@key}:#{ActsAsStream.count-1}"
+ ActsAsStream.register_new_activity! @package
+ key = "#{@key}:#{ActsAsStream.count}"
ActsAsStream.redis.get(key).should == @package
end
it "should register time keys with new activity" do
- id = ActsAsStream.count
# we're assuming this test will take less than one second!
time = Time.now.to_i
items = ActsAsStream.redis.zcard("#{@key}:time:#{time}")
- ActsAsStream.register_new_activity! :key => @key, :package => @package
+ id = ActsAsStream.register_new_activity! @package
ActsAsStream.redis.get("#{@key}:#{id}").should == @package
score = ActsAsStream.redis.get("#{@key}:id:#{id}")
@@ -37,29 +40,28 @@
end
it "should remove all keys on deregistration" do
- id = ActsAsStream.count
# we're assuming this test will take less than one second!
time = Time.now.to_i
- items = ActsAsStream.redis.zcard("#{@key}:time:#{time}")
- ActsAsStream.register_new_activity! :key => @key, :package => @package
+ count = ActsAsStream.redis.zcard("#{@key}:time:#{time}")
+ package = "########################################\n\n###################################"
+ id = ActsAsStream.register_new_activity! package
- ActsAsStream.redis.get("#{@key}:#{id}").should == @package
+ ActsAsStream.redis.get("#{@key}:#{id}").should == package
score = ActsAsStream.redis.get("#{@key}:id:#{id}")
score.to_i.should == time
- (ActsAsStream.redis.zcard("#{@key}:time:#{score}") - items).should be(1)
+ (ActsAsStream.redis.zcard("#{@key}:time:#{score}") - count).should be(1)
ActsAsStream.redis.zrevrange("#{@key}:time:#{score}",0,25,:with_scores => false).include?("#{id}").should be_true
- ActsAsStream.deregister_activity! :key => @key, :id => id
+ ActsAsStream.deregister_activity! id
ActsAsStream.redis.get("#{@key}:#{id}").should be(nil)
ActsAsStream.redis.get("#{@key}:id:#{id}").should be(nil)
- ActsAsStream.redis.zcard("#{@key}:time:#{score}").should == items
- ActsAsStream.redis.zrevrange("#{@key}:time:#{score}",0,25,:with_scores => false).include?("#{id}").should be_false
+# ActsAsStream.redis.zcard("#{@key}:time:#{time}").should == count
+ ActsAsStream.redis.zrevrange("#{@key}:time:#{time}",0,25,:with_scores => false).include?("#{id}").should be_false
end
it "should add a weighted record to the sorted set for a list of followers" do
- id = ActsAsStream.count
- ActsAsStream.register_new_activity! :key => @key, :package => "########################################"
+ id = ActsAsStream.register_new_activity! @package
followers = [23,32,42].map{|f| "#{@key}:user:#{f}"}
ActsAsStream.register_followers! :following_keys => followers, :activity_id => id
@@ -72,8 +74,7 @@
end
it "should remove followers on deregistration" do
- id = ActsAsStream.count
- ActsAsStream.register_new_activity! :key => @key, :package => "########################################"
+ id = ActsAsStream.register_new_activity! @package
followers = [56,43,65].map{|f| "#{@key}:user:#{f}"}
ActsAsStream.register_followers! :following_keys => followers, :activity_id => id
@@ -84,7 +85,7 @@
end
ActsAsStream.redis.llen("#{@key}:followers:#{id}").should be(3)
- ActsAsStream.deregister_activity! :key => @key, :id => id
+ ActsAsStream.deregister_activity! id
followers.each do |f|
ActsAsStream.redis.zcard(f).should be(0)
@@ -97,23 +98,52 @@
it "should automatically score" do
time = Time.now.to_i
sleep 1
- ActsAsStream.register_new_activity! :key => @key, :package => @package
- key = "#{@key}:#{ActsAsStream.count-1}"
+ ActsAsStream.register_new_activity! @package
+ key = "#{@key}:#{ActsAsStream.count}"
ActsAsStream.redis.get(key).should == @package
end
it "should deregister an activity" do
- ActsAsStream.register_new_activity! :key => @key, :package => @package
- key = "#{@key}:#{ActsAsStream.count-1}"
+ ActsAsStream.register_new_activity! @package
+ key = "#{@key}:#{ActsAsStream.count}"
ActsAsStream.redis.get(key).should == @package
- ActsAsStream.deregister_activity! :key => @key, :id => ActsAsStream.count-1
+ ActsAsStream.deregister_activity! ActsAsStream.count
ActsAsStream.redis.get(key).should be(nil)
end
+ it "should get a correct page count" do
+ user = Factory :user
+ key = user.following_key
+ acts = (1..3).collect{ActsAsStream.register_new_activity! @package}
+ acts.each{|a| ActsAsStream.register_followers! :following_keys => [key], :activity_id => a}
+
+ ActsAsStream.total_pages(key).should be(1)
+ ActsAsStream.total_pages(key, 2).should be(2)
+ end
+
+ it "should return a correct list of packaged activities for a follower key" do
+ user = Factory :user
+ key = user.following_key
+ packages = (1..3).collect{|i| test_package i}
+ packages.each do |p|
+ id = ActsAsStream.register_new_activity! p
+ ActsAsStream.register_followers! :following_keys => [key], :activity_id => id
+ end
+ ActsAsStream.total_pages(key).should be(1)
+ ActsAsStream.get_activity_for(key).should =~ packages
+ ActsAsStream.get_activity_for(key, :page_size => 2).size.should be(2)
+ ActsAsStream.get_activity_for(key, :page_size => 2, :page => 10).count.should be(1)
+ end
+
private
- def test_package
- "{'test':#{Time.now}}"
+ def test_package number = nil
+ if number
+ "{'test':'#{Time.now}','number':'#{number}'}"
+ else
+ "{'test':#{Time.now}}"
+ end
end
+
end
View
1  spec/dummy/app/models/admin.rb
@@ -1,5 +1,6 @@
class Admin < ActiveRecord::Base
acts_as_stream :activity_attr => :guid, :activity_scope => :actions
+ acts_as_amico
validates_uniqueness_of :guid
validates_presence_of :guid
end
View
1  spec/dummy/app/models/thing.rb
@@ -1,3 +1,4 @@
class Thing < ActiveRecord::Base
acts_as_stream
+ acts_as_amico
end
View
6 spec/dummy/app/models/user.rb
@@ -1,3 +1,9 @@
class User < ActiveRecord::Base
acts_as_stream
+ acts_as_amico
+
+ def all_followers
+ get_all(:followers).map{|id| User.find(id.to_i)}.map{|u| u.following_key}
+ end
+
end
View
5 spec/dummy/app/models/widget.rb
@@ -1,3 +1,8 @@
class Widget < ActiveRecord::Base
acts_as_stream :activity_scope => :people_doings
+ acts_as_amico
+
+ def all_followers
+ get_all(:following)
+ end
end
View
7 spec/dummy/config/environments/development.rb
@@ -22,13 +22,6 @@
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
- # Raise exception on mass assignment protection for Active Record models
- config.active_record.mass_assignment_sanitizer = :strict
-
- # Log the query plan for queries taking more than this (works
- # with SQLite, MySQL, and PostgreSQL)
- config.active_record.auto_explain_threshold_in_seconds = 0.5
-
# Do not compress assets
config.assets.compress = false
View
3  spec/dummy/config/environments/test.rb
@@ -29,9 +29,6 @@
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
- # Raise exception on mass assignment protection for Active Record models
- config.active_record.mass_assignment_sanitizer = :strict
-
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
end
View
14 spec/dummy/config/initializers/amico.rb
@@ -0,0 +1,14 @@
+require 'acts_as_amico'
+
+Amico.configure do |configuration|
+ configuration.redis = Redis.new
+ configuration.namespace = 'acts_as_amico'
+ configuration.following_key = 'following'
+ configuration.followers_key = 'followers'
+ configuration.blocked_key = 'blocked'
+ configuration.reciprocated_key = 'reciprocated'
+ configuration.pending_key = 'pending'
+ configuration.default_scope_key = 'user'
+ configuration.pending_follow = false
+ configuration.page_size = 25
+end
View
17 spec/spec_helper.rb
@@ -14,6 +14,7 @@
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require "rails/test_help"
require "rspec/rails"
+ require "acts_as_amico"
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
@@ -30,10 +31,26 @@
# == Mock Framework
config.mock_with :rspec
+ config.before(:all) do
+ Amico.configure do |configuration|
+ redis = Redis.new(:db => 15)
+ configuration.redis = redis
+ end
+ end
+ config.before(:each) do
+ Amico.redis.flushdb
+ end
+
+ config.after(:all) do
+ Amico.redis.flushdb
+ Amico.redis.quit
+ end
+
end
require 'factory_girl'
require 'fakeweb'
+
end
Spork.each_run do
View
73 spec/streamable_object_spec.rb
@@ -11,27 +11,62 @@
@admin_base = "redis_stream_test:actions"
end
- describe "loading" do
- it "should load correctly into a model" do
- @user.class.activity_scope.should eq(ActsAsStream.activity_scope)
- @thing.class.activity_scope.should eq(ActsAsStream.activity_scope)
- @admin.class.activity_scope.should eq(:actions)
- @admin.class.activity_attr.should eq(:guid)
- @widget.class.activity_scope.should eq(:people_doings)
- end
+ it "should load correctly into a model" do
+ @user.class.activity_scope.should eq(ActsAsStream.activity_scope)
+ @thing.class.activity_scope.should eq(ActsAsStream.activity_scope)
+ @admin.class.activity_scope.should eq(:actions)
+ @admin.class.activity_attr.should eq(:guid)
+ @widget.class.activity_scope.should eq(:people_doings)
+ end
- it "should provide a proper activity_key_base" do
- @user.class.activity_key_base.should eq(@user_base)
- @admin.class.activity_key_base.should eq(@admin_base)
- end
- it "should provide a proper activity key" do
- @user.activity_key.should eq("#{@user_base}:#{@user.id}")
- @admin.activity_key.should eq("#{@admin_base}:#{@admin.guid}")
- end
+ it "should provide a proper activity_key_base" do
+ @user.class.activity_key_base.should eq(@user_base)
+ @admin.class.activity_key_base.should eq(@admin_base)
+ end
+ it "should provide a proper activity key" do
+ @user.activity_key.should eq("#{@user_base}:#{@user.id}")
+ @admin.activity_key.should eq("#{@admin_base}:#{@admin.guid}")
+ end
+
+ it "should provide a proper following key" do
+ @user.following_key.should eq("redis_stream_test:user:#{@user.id}:activity")
+ @admin.following_key.should eq("redis_stream_test:admin:#{@admin.guid}:actions")
+ end
- it "should provide a proper following key" do
- @user.following_key.should eq("redis_stream_test:user:#{@user.id}:activity")
- @admin.following_key.should eq("redis_stream_test:admin:#{@admin.guid}:actions")
+ it "should return a list of all followers as a keyed list" do
+ users = (1..3).collect{Factory :user}
+ users.each{|u| u.follow! @user}
+ @user.get_follower_keys.should =~ users.map{|u| u.following_key}
+ end
+
+ it "Should register following activity in followers" do
+ usera = Factory :user
+ userb = Factory :user
+ package = test_package
+ usera.follow! @user
+ @user.register_activity! package
+ ActsAsStream.redis.zcard(usera.following_key).should be(1)
+ ActsAsStream.redis.zcard(userb.following_key).should be(0)
+ end
+
+ it "should return a paged list of activity packages" do
+ usera = Factory :user
+ packages = (1..26).collect{|i| test_package i}
+ usera.follow! @user
+ packages.each{|p| @user.register_activity! p}
+ usera.get_activity.should =~ packages[1..25]
+ usera.get_activity(:page_size => 10).size.should be(10)
+ usera.get_activity(:all).should =~ packages
+ end
+
+
+ private
+ def test_package number = nil
+ if number
+ "{'test':'#{Time.now}','number':'#{number}'}"
+ else
+ "{'test':#{Time.now}}"
end
end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.