Sha256: a7d1550299b1112507d2efd1b9e930d362f7830a30ffbefa446f49207d9aca91

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

require 'rails_helper'

describe ActiveAdmin::ViewHelpers::DownloadFormatLinksHelper do
  describe "class methods" do
    before :all do
      begin
        # The mime type to be used in respond_to |format| style web-services in rails
        Mime::Type.register "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", :xlsx
      rescue NameError
        puts "Mime module not defined. Skipping registration of xlsx"
      end
    end

    subject do
      Class.new do
        include ActiveAdmin::ViewHelpers::DownloadFormatLinksHelper
      end
    end

    it "extends the class to add a formats class method that returns the default formats." do
      expect(subject.formats).to eq [:csv, :xml, :json]
    end

    it "does not let you alter the formats array directly" do
      subject.formats << :xlsx
      expect(subject.formats).to eq [:csv, :xml, :json]
    end

    it "allows us to add new formats" do
      subject.add_format :xlsx
      expect(subject.formats).to eq [:csv, :xml, :json, :xlsx]
    end

    it "raises an exception if you provide an unregisterd mime type extension" do
      expect{ subject.add_format :hoge }.to raise_error 'Please register the hoge mime type with `Mime::Type.register`'
    end

  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
activeadmin-orac-1.0.0.pre4 spec/unit/view_helpers/download_format_links_helper_spec.rb
activeadmin-orac-1.0.0 spec/unit/view_helpers/download_format_links_helper_spec.rb
activeadmin-orac-1.0.0.pre.orac spec/unit/view_helpers/download_format_links_helper_spec.rb
activeadmin-1.0.0.pre4 spec/unit/view_helpers/download_format_links_helper_spec.rb
activeadmin-1.0.0.pre3 spec/unit/view_helpers/download_format_links_helper_spec.rb