From bf511988c786d8bc7b7e800b595f103bae91b4e5 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Wed, 23 Oct 2013 14:53:46 +0100 Subject: Add some specs for existing exceeded_limit? behaviour --- spec/models/user_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'spec/models/user_spec.rb') diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index cbbf4b5ce..bb1b054aa 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -337,3 +337,27 @@ 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 + +end -- cgit v1.2.3 From b97cf2f206ae9aea778db2a10132fa68aeaa764b Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Wed, 23 Oct 2013 14:58:02 +0100 Subject: 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. --- spec/models/user_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'spec/models/user_spec.rb') 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 -- cgit v1.2.3