Skip to content

Instantly share code, notes, and snippets.

@thomasmaas
Created March 25, 2014 11:22
Show Gist options
  • Save thomasmaas/9759801 to your computer and use it in GitHub Desktop.
Save thomasmaas/9759801 to your computer and use it in GitHub Desktop.
class Data
class << self
def all
(1..10).to_a
end
def created
[4, 5, 6, 8, 9]
end
def users
[1, 2, 4, 5, 6]
end
def accounts
[3, 7, 8, 9, 10]
end
def updated
[2, 3, 6, 7, 8, 9, 10]
end
end
end
class Activity
def self.find
Data.all
end
end
if __FILE__ == $0
require 'test/unit'
class ActivityTest < Test::Unit::TestCase
def test_one
assert_equal [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], Activity.find
end
def test_two
assert_equal [4, 5, 6], Activity.find(:indexes => {:type => :users, :action => :created})
end
def test_three
assert_equal [2, 3, 6, 7, 8, 9, 10],
Activity.find(:indexes => {:type => [:accounts, :users], :action => :updated})
end
def test_four
assert_equal [2, 3, 4, 5, 6, 7, 8, 9, 10],
Activity.find(:indexes => {:type => [:accounts, :users], :action => [:updated, :created]})
end
def test_five
assert_equal [3, 7, 8, 9, 10],
Activity.find(:indexes => {:type => :accounts, :action => [:updated, :created]})
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment