2014-08-09 06:28:57 -04:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
describe Admin::ExportCsvController do
|
|
|
|
|
|
|
|
it "is a subclass of AdminController" do
|
2014-09-25 11:44:48 -04:00
|
|
|
(Admin::ExportCsvController < Admin::AdminController).should == true
|
2014-08-09 06:28:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
let(:export_filename) { "export_b6a2bc87.csv" }
|
|
|
|
|
|
|
|
context "while logged in as an admin" do
|
|
|
|
|
|
|
|
before { @admin = log_in(:admin) }
|
|
|
|
|
|
|
|
describe ".download" do
|
|
|
|
|
|
|
|
it "uses send_file to transmit the export file" do
|
|
|
|
controller.stubs(:render)
|
|
|
|
export = ExportCsv.new()
|
|
|
|
ExportCsv.expects(:get_download_path).with(export_filename).returns(export)
|
|
|
|
subject.expects(:send_file).with(export)
|
2014-11-19 12:09:23 -05:00
|
|
|
get :show, id: export_filename
|
2014-08-09 06:28:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "returns 404 when the export file does not exist" do
|
|
|
|
ExportCsv.expects(:get_download_path).returns(nil)
|
2014-11-19 12:09:23 -05:00
|
|
|
get :show, id: export_filename
|
2014-08-09 06:28:57 -04:00
|
|
|
response.should be_not_found
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|