2014-05-16 18:03:13 -04:00
|
|
|
require 'test_helper'
|
2013-03-17 19:20:48 -06:00
|
|
|
|
|
|
|
|
class ContextActionsDataTest < ActionController::TestCase
|
|
|
|
|
tests StatsController
|
|
|
|
|
|
|
|
|
|
def test_total_with_more_than_10_items
|
|
|
|
|
login_as(:admin_user)
|
|
|
|
|
contexts = [
|
|
|
|
|
{'id' => 1, 'name' => 'one', 'total' => 11},
|
|
|
|
|
{'id' => 2, 'name' => 'two', 'total' => 4},
|
2013-03-17 20:02:16 -06:00
|
|
|
{'id' => 3, 'name' => 'three', 'total' => 8}
|
2013-03-17 19:20:48 -06:00
|
|
|
]
|
|
|
|
|
Stats::TopContextsQuery.any_instance.stubs(:result).returns contexts
|
|
|
|
|
|
|
|
|
|
get :context_total_actions_data
|
|
|
|
|
|
2013-03-17 20:02:16 -06:00
|
|
|
assert_equal [47, 17, 34], assigns[:data].values
|
2013-03-17 19:20:48 -06:00
|
|
|
end
|
|
|
|
|
|
2013-03-17 20:02:16 -06:00
|
|
|
def test_running_actions
|
2013-03-17 19:20:48 -06:00
|
|
|
login_as(:admin_user)
|
|
|
|
|
contexts = [
|
|
|
|
|
{'id' => 1, 'name' => 'one', 'total' => 11},
|
|
|
|
|
{'id' => 2, 'name' => 'two', 'total' => 4},
|
2013-03-17 20:02:16 -06:00
|
|
|
{'id' => 3, 'name' => 'three', 'total' => 8}
|
2013-03-17 19:20:48 -06:00
|
|
|
]
|
|
|
|
|
Stats::TopContextsQuery.any_instance.stubs(:result).returns contexts
|
|
|
|
|
|
|
|
|
|
get :context_running_actions_data
|
|
|
|
|
|
2013-03-17 20:02:16 -06:00
|
|
|
assert_equal [47, 17, 34], assigns[:data].values
|
2013-03-17 19:20:48 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|