Skip to content

Instantly share code, notes, and snippets.

@hallelujah
Created January 26, 2017 15:59
Show Gist options
  • Save hallelujah/b8645ce2caa3b5ef074374ca82e78d22 to your computer and use it in GitHub Desktop.
Save hallelujah/b8645ce2caa3b5ef074374ca82e78d22 to your computer and use it in GitHub Desktop.
acitivity.rb
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
if __FILE__ == $0
require 'minitest/autorun'
class ActivityTest < Minitest::Test
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