FIX: rate limit user posts export

This commit is contained in:
Arpit Jalan
2014-12-30 18:07:05 +05:30
parent f7955406cc
commit 78537aad39
6 changed files with 28 additions and 8 deletions

View File

@ -14,6 +14,13 @@ describe ExportCsvController do
response.should be_success
end
it "should not enqueue export job if rate limit is reached" do
Jobs::ExportCsvFile.any_instance.expects(:execute).never
UserExport.create(export_type: "user", user_id: @user.id)
xhr :post, :export_entity, entity: "user_archive", entity_type: "user"
response.should_not be_success
end
it "returns 404 when normal user tries to export admin entity" do
xhr :post, :export_entity, entity: "staff_action", entity_type: "admin"
response.should_not be_success
@ -55,6 +62,13 @@ describe ExportCsvController do
xhr :post, :export_entity, entity: "staff_action", entity_type: "admin"
response.should be_success
end
it "should not rate limit export for staff" do
Jobs.expects(:enqueue).with(:export_csv_file, has_entries(entity: "staff_action", user_id: @admin.id))
UserExport.create(export_type: "admin", user_id: @admin.id)
xhr :post, :export_entity, entity: "staff_action", entity_type: "admin"
response.should be_success
end
end
describe ".download" do