Sha256: a9462f073d0a8c863b05bec3a8eae3c496b07d7a95d24c71574886db29e2ec8c
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
require 'spec_helper' describe ActiveAdmin::ResourceController do let(:mime) { Mime::Type.lookup_by_extension(:xlsx) } let(:request) do ActionController::TestRequest.new.tap do |test_request| test_request.accept = mime end end let(:response) { ActionController::TestResponse.new } let(:controller) do Admin::CategoriesController.new.tap do |controller| controller.request = request controller.response = response end end let(:filename) { "#{controller.resource_class.to_s.downcase.pluralize}-#{Time.now.strftime("%Y-%m-%d")}.xlsx" } it 'generates an xlsx filename' do controller.xlsx_filename.should == filename end context 'when making requests with the xlsx mime type' do it 'returns xlsx attachment when requested' do controller.send :index response.headers["Content-Disposition"].should == "attachment; filename=\"#{filename}\"" response.headers["Content-Transfer-Encoding"].should == 'binary' end it 'returns max_csv_records for per_page' do controller.send(:per_page).should == controller.send(:max_csv_records) end it 'kicks back to the default per_page when we are not specifying a xlsx mime type' do controller.request.accept = 'text/html' controller.send(:per_page).should == ActiveAdmin.application.default_per_page end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activeadmin-axlsx-2.0.1 | spec/axlsx/unit/resource_controller_spec.rb |
activeadmin-axlsx-2.0.0 | spec/axlsx/unit/resource_controller_spec.rb |