aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/user_spec.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2014-01-29 16:10:52 +0000
committerLouise Crow <louise.crow@gmail.com>2014-01-29 16:10:52 +0000
commit184ffeccb7f4579b481db9b7744aa9baed70562f (patch)
tree67c023b029a699a1e727ef6becdc0832e82ea1c5 /spec/models/user_spec.rb
parente44c8b875fd4ad46b954ef9c31bdb6f0366dcb9e (diff)
parent79b2f672aeae394a2c195d89b70bda27bb3201a4 (diff)
Merge branch 'feature/batch-requests' into rails-3-develop
Conflicts: config/general.yml-example spec/factories.rb
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r--spec/models/user_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index cbbf4b5ce..b6f48dad3 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -337,3 +337,34 @@ describe User, "when emails have bounced" do
user.email_bounce_message.should == "The reason we think the email bounced (e.g. a bounce message)"
end
end
+
+describe User, "when calculating if a user has exceeded the request limit" do
+
+ before do
+ @info_request = FactoryGirl.create(:info_request)
+ @user = @info_request.user
+ end
+
+ it 'should return false if no request limit is set' do
+ AlaveteliConfiguration.stub!(:max_requests_per_user_per_day).and_return nil
+ @user.exceeded_limit?.should be_false
+ end
+
+ it 'should return false if the user has not submitted more than the limit' do
+ AlaveteliConfiguration.stub!(:max_requests_per_user_per_day).and_return(2)
+ @user.exceeded_limit?.should be_false
+ end
+
+ it 'should return true if the user has submitted more than the limit' do
+ AlaveteliConfiguration.stub!(:max_requests_per_user_per_day).and_return(0)
+ @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