Commit f34d8e89dd0d3a5c8fe87f98c704ee594a90b3f7
1 parent
a5ffad1d
Exists in
master
and in
1 other branch
fix test with randomness so won't randomly fail
ensure that each question has at least one vote after the date we're checking
Showing
1 changed file
with
4 additions
and
1 deletions
Show diff stats
spec/integration/questions_spec.rb
| @@ -72,12 +72,15 @@ describe "Questions" do | @@ -72,12 +72,15 @@ describe "Questions" do | ||
| 72 | 72 | ||
| 73 | it "should calculate the number of votes submitted since some date" do | 73 | it "should calculate the number of votes submitted since some date" do |
| 74 | votes = {} | 74 | votes = {} |
| 75 | + date = rand(365).days.ago | ||
| 75 | @questions.each do |q| | 76 | @questions.each do |q| |
| 76 | votes[q.id] = Array.new(20) do | 77 | votes[q.id] = Array.new(20) do |
| 77 | Factory(:vote, :question => q, :created_at => rand(365).days.ago) | 78 | Factory(:vote, :question => q, :created_at => rand(365).days.ago) |
| 78 | end | 79 | end |
| 80 | + # always add at least on vote so we know each question | ||
| 81 | + # has a vote after the date | ||
| 82 | + votes[q.id].push Factory(:vote, :question => q, :created_at => date + 1.day) | ||
| 79 | end | 83 | end |
| 80 | - date = rand(365).days.ago | ||
| 81 | get_auth questions_path(:format => 'xml'), :votes_since => date.strftime("%Y-%m-%d") | 84 | get_auth questions_path(:format => 'xml'), :votes_since => date.strftime("%Y-%m-%d") |
| 82 | 85 | ||
| 83 | response.should be_success | 86 | response.should be_success |