Commit 66d867d4 by Kevin Chugh

fix timing used on tests

parent e839ef1f
...@@ -28,6 +28,7 @@ describe "app" do ...@@ -28,6 +28,7 @@ describe "app" do
end_time = Time.now end_time = Time.now
post "/api/v1/notifications", from: CGI::escape(start_time.to_s), to: CGI::escape(end_time.to_s), user_ids: subscription.subscriber_id post "/api/v1/notifications", from: CGI::escape(start_time.to_s), to: CGI::escape(end_time.to_s), user_ids: subscription.subscriber_id
last_response.should be_ok last_response.should be_ok
last_response.body.to_s.include?(dummy).should == true last_response.body.to_s.include?(dummy).should == true
end end
...@@ -50,12 +51,14 @@ describe "app" do ...@@ -50,12 +51,14 @@ describe "app" do
comment.comment_thread = thread comment.comment_thread = thread
comment.save! comment.save!
start_time = Date.today - 400.days start_time = Date.today - 100.days
end_time = Time.now
sleep 1 sleep 1
end_time = Time.now + 5.seconds
post "/api/v1/notifications", from: CGI::escape(start_time.to_s), to: CGI::escape(end_time.to_s), user_ids: user.id post "/api/v1/notifications", from: CGI::escape(start_time.to_s), to: CGI::escape(end_time.to_s), user_ids: user.id
last_response.should be_ok last_response.should be_ok
payload = JSON.parse last_response.body payload = JSON.parse last_response.body
courses = payload[user.id.to_s] courses = payload[user.id.to_s]
...@@ -74,14 +77,17 @@ describe "app" do ...@@ -74,14 +77,17 @@ describe "app" do
end end
it "returns only unflagged threads" do it "returns only unflagged threads" do
start_time = Date.today - 400.days start_time = Date.today - 100.days
end_time = Time.now
user = User.create(:email => "test@example.com",:external_id => 1,:username => "example") user = User.create(:email => "test@example.com",:external_id => 1,:username => "example")
sleep 1 sleep 1
end_time = Time.now + 5.seconds
post "/api/v1/notifications", from: CGI::escape(start_time.to_s), to: CGI::escape(end_time.to_s), user_ids: user.id post "/api/v1/notifications", from: CGI::escape(start_time.to_s), to: CGI::escape(end_time.to_s), user_ids: user.id
last_response.should be_ok last_response.should be_ok
payload = JSON.parse last_response.body payload = JSON.parse last_response.body
courses = payload[user.id.to_s] courses = payload[user.id.to_s]
...@@ -97,6 +103,8 @@ describe "app" do ...@@ -97,6 +103,8 @@ describe "app" do
sleep 1 sleep 1
end_time = Time.now + 5.seconds
post "/api/v1/notifications", from: CGI::escape(start_time.to_s), to: CGI::escape(end_time.to_s), user_ids: user.id post "/api/v1/notifications", from: CGI::escape(start_time.to_s), to: CGI::escape(end_time.to_s), user_ids: user.id
last_response.should be_ok last_response.should be_ok
payload = JSON.parse last_response.body payload = JSON.parse last_response.body
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment