-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
715ccd4
commit a8234a2
Showing
6 changed files
with
51 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'test_helper' | ||
|
||
class QuestionsHelperTest < ActionView::TestCase | ||
test 'should return null if period is nil' do | ||
assert_nil questions_stats(nil) | ||
end | ||
|
||
test 'should return all questions if all' do | ||
request = questions_stats("All") | ||
asked = Node.questions.length | ||
answered = Answer.all.map(&:node).uniq.count | ||
assert_not_nil request | ||
assert_includes request, asked.to_s | ||
assert_includes request, answered.to_s | ||
end | ||
|
||
test "should return exact count according to period given" do | ||
options.reject { |option| option == "All" }.each do |period| | ||
request = questions_stats(period) | ||
asked = Node.questions.where('created >= ?', 1.send(period.downcase).ago.to_i).length | ||
answered = Answer.where("created_at >= ?", 1.send(period.downcase).ago).map(&:node).uniq.count | ||
assert_includes request, asked.to_s | ||
assert_includes request, answered.to_s | ||
end | ||
end | ||
|
||
test 'it caches results' do | ||
end | ||
end |