Sha256: 915a89596a2f8f6ff0bbd75f6c1fd835ae65edec5a9ecc310d9afc08a2649591

Contents?: true

Size: 1.11 KB

Versions: 20

Compression:

Stored size: 1.11 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

      class Foo
        include ActiveAdmin::ViewHelpers::DownloadFormatLinksHelper
      end
    end

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

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

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

    it "raises an exception if you provide an unregisterd mime type extension" do
      expect{ Foo.add_format :hoge }.to raise_error
    end

  end
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
activeadmin_addons-1.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/view_helpers/download_format_links_helper_spec.rb
activeadmin_addons-1.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/view_helpers/download_format_links_helper_spec.rb
yousty-activeadmin-1.0.17.pre spec/unit/view_helpers/download_format_links_helper_spec.rb
yousty-activeadmin-1.0.16.pre spec/unit/view_helpers/download_format_links_helper_spec.rb
activeadmin_addons-1.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/view_helpers/download_format_links_helper_spec.rb
activeadmin_addons-1.0.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/view_helpers/download_format_links_helper_spec.rb
activeadmin_addons-1.0.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/view_helpers/download_format_links_helper_spec.rb
yousty-activeadmin-1.0.15.pre spec/unit/view_helpers/download_format_links_helper_spec.rb
yousty-activeadmin-1.0.14.pre spec/unit/view_helpers/download_format_links_helper_spec.rb
yousty-activeadmin-1.0.13.pre spec/unit/view_helpers/download_format_links_helper_spec.rb
yousty-activeadmin-1.0.12.pre spec/unit/view_helpers/download_format_links_helper_spec.rb
yousty-activeadmin-1.0.11.pre spec/unit/view_helpers/download_format_links_helper_spec.rb
yousty-activeadmin-1.0.10.pre spec/unit/view_helpers/download_format_links_helper_spec.rb
yousty-activeadmin-1.0.9.pre spec/unit/view_helpers/download_format_links_helper_spec.rb
yousty-activeadmin-1.0.8.pre spec/unit/view_helpers/download_format_links_helper_spec.rb
activeadmin-1.0.0.pre2 spec/unit/view_helpers/download_format_links_helper_spec.rb
activeadmin-1.0.0.pre1 spec/unit/view_helpers/download_format_links_helper_spec.rb
yousty-activeadmin-1.0.7.pre spec/unit/view_helpers/download_format_links_helper_spec.rb
yousty-activeadmin-1.0.6.pre spec/unit/view_helpers/download_format_links_helper_spec.rb
yousty-activeadmin-1.0.5.pre spec/unit/view_helpers/download_format_links_helper_spec.rb