mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 08:24:18 +08:00
controllers with rspec3 syntax
This commit is contained in:
@ -11,19 +11,19 @@ describe ExportCsvController do
|
||||
it "enqueues export job" do
|
||||
Jobs.expects(:enqueue).with(:export_csv_file, has_entries(entity: "user_archive", user_id: @user.id))
|
||||
xhr :post, :export_entity, entity: "user_archive", entity_type: "user"
|
||||
response.should be_success
|
||||
expect(response).to 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
|
||||
expect(response).not_to 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
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
end
|
||||
|
||||
@ -36,18 +36,18 @@ describe ExportCsvController do
|
||||
UserExport.expects(:get_download_path).with(file_name).returns(export)
|
||||
subject.expects(:send_file).with(export)
|
||||
get :show, id: file_name
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it "returns 404 when the user tries to export another user's csv file" do
|
||||
get :show, id: export_filename
|
||||
response.should be_not_found
|
||||
expect(response).to be_not_found
|
||||
end
|
||||
|
||||
it "returns 404 when the export file does not exist" do
|
||||
UserExport.expects(:get_download_path).returns(nil)
|
||||
get :show, id: export_filename
|
||||
response.should be_not_found
|
||||
expect(response).to be_not_found
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -60,14 +60,14 @@ describe ExportCsvController do
|
||||
it "enqueues export job" do
|
||||
Jobs.expects(:enqueue).with(:export_csv_file, has_entries(entity: "staff_action", user_id: @admin.id))
|
||||
xhr :post, :export_entity, entity: "staff_action", entity_type: "admin"
|
||||
response.should be_success
|
||||
expect(response).to 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
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
@ -80,13 +80,13 @@ describe ExportCsvController do
|
||||
UserExport.expects(:get_download_path).with(file_name).returns(export)
|
||||
subject.expects(:send_file).with(export)
|
||||
get :show, id: file_name
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it "returns 404 when the export file does not exist" do
|
||||
UserExport.expects(:get_download_path).returns(nil)
|
||||
get :show, id: export_filename
|
||||
response.should be_not_found
|
||||
expect(response).to be_not_found
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user