aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-10-23 14:58:02 +0100
committerLouise Crow <louise.crow@gmail.com>2013-12-04 09:32:41 +0000
commitb97cf2f206ae9aea778db2a10132fa68aeaa764b (patch)
tree30f5fbcf800c98cf6c2bd402c096209c470f39ab
parentbf511988c786d8bc7b7e800b595f103bae91b4e5 (diff)
Batch users don't have a daily limit.
It doesn't make logical sense that they would. However I am preserving the ability to make batch requests as a separate thing from not having a daily limit - I think batch sending requires a (perhaps marginally) bigger level of trust.
-rw-r--r--app/controllers/request_controller.rb3
-rw-r--r--app/models/user.rb3
-rw-r--r--spec/models/user_spec.rb7
3 files changed, 11 insertions, 2 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index d56b5d245..718a8aada 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -188,8 +188,7 @@ class RequestController < ApplicationController
redirect_to select_authorities_path and return
end
- # TODO: I don't think batch requesters should be subject to rate limits,
- # but I do think we should probably check for double submission of batch
+ # TODO: I do think we should probably check for double submission of batch
# requests as we do in 'new' for ordinary requests with find_by_existing_request
# TODO: Decide if we make batch requesters describe their undescribed requests
diff --git a/app/models/user.rb b/app/models/user.rb
index 2c4f87944..2052b942b 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -269,6 +269,9 @@ class User < ActiveRecord::Base
# Some users have no limit
return false if self.no_limit
+ # Batch request users don't have a limit
+ return false if self.can_make_batch_requests?
+
# Has the user issued as many as MAX_REQUESTS_PER_USER_PER_DAY requests in the past 24 hours?
return false if AlaveteliConfiguration::max_requests_per_user_per_day.blank?
recent_requests = InfoRequest.count(:conditions => ["user_id = ? and created_at > now() - '1 day'::interval", self.id])
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index bb1b054aa..b6f48dad3 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -360,4 +360,11 @@ describe User, "when calculating if a user has exceeded the request limit" do
@user.exceeded_limit?.should be_true
end
+ it 'should return false if the user is allowed to make batch requests' do
+ @user.can_make_batch_requests = true
+ AlaveteliConfiguration.stub!(:max_requests_per_user_per_day).and_return(0)
+ @user.exceeded_limit?.should be_false
+ end
+
+
end