Sha256: 656bdd4de03c4076696f59eacb70e5bc4fe5930a2aeaaa4db803630b66216e76

Contents?: true

Size: 924 Bytes

Versions: 3

Compression:

Stored size: 924 Bytes

Contents

require 'spec_helper'

describe GenericFileHelper do

  describe "#render_collection_list" do

    context "using a file that is part of a collection" do

      let(:collection) do
        mock_model(Collection, title: "Foo Collection")
      end

      let(:gf) do 
        mock_model(GenericFile, { collections: [collection, collection] })
      end

      let(:link) do
        "<a href=\"/collections/#{collection.id}\">#{collection.title}</a>"
      end

      it "should display a comma-delimited list of collections" do
        expect(helper.render_collection_list(gf)).to eq("Is part of: " + [link,link].join(", "))
      end

    end

    context "using a file that is not part of a collection" do
      
      let(:gf) do 
        mock_model(GenericFile, { collections: [] })
      end

      it "should render nothing" do
        expect(helper.render_collection_list(gf)).to be_nil
      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sufia-4.0.1 spec/helpers/generic_file_helper_spec.rb
sufia-4.0.0 spec/helpers/generic_file_helper_spec.rb
sufia-4.0.0.rc2 spec/helpers/generic_file_helper_spec.rb