Sha256: 3c1ea7347a418dab9a996f11e422cbb9ea0e45d8fb938f592988567190d88bf1
Contents?: true
Size: 1.96 KB
Versions: 3
Compression:
Stored size: 1.96 KB
Contents
describe 'collections/_form_for_select_collection.html.erb' do let(:collections) { [ build(:collection, id: '1234', create_date: Time.zone.parse('Thu, 13 Aug 2015 14:20:22 +0100')), build(:collection, id: '1235', create_date: Time.zone.parse('Thu, 13 Aug 2015 14:18:22 +0100')), build(:collection, id: '1236', create_date: Time.zone.parse('Thu, 13 Aug 2015 14:16:22 +0100')), build(:collection, id: '1237', create_date: Time.zone.parse('Thu, 13 Aug 2015 14:29:22 +0100')) ] } let(:solr_collections) { collections.map do |c| SolrDocument.new(c.to_solr).tap do |sd| sd['system_create_dtsi'] = c.create_date.to_s end end } let(:doc) { Nokogiri::HTML(rendered) } before { allow(view).to receive(:user_collections).and_return(solr_collections) } it "sorts the collections" do render collection_ids = doc.xpath("//input[@class='collection-selector']/@id").map(&:to_s) expect(collection_ids).to eql(["id_1237", "id_1234", "id_1235", "id_1236"]) end it "selects the right collection when instructed to do so" do assign(:add_files_to_collection, collections[2].id) render expect(rendered).not_to have_selector "#id_#{collections[0].id}[checked='checked']" expect(rendered).not_to have_selector "#id_#{collections[1].id}[checked='checked']" expect(rendered).not_to have_selector "#id_#{collections[3].id}[checked='checked']" expect(rendered).to have_selector "#id_#{collections[2].id}[checked='checked']" end it "selects the first collection when nothing else specified" do # first when sorted by create date, so not index 0 render expect(rendered).not_to have_selector "#id_#{collections[0].id}[checked='checked']" expect(rendered).not_to have_selector "#id_#{collections[1].id}[checked='checked']" expect(rendered).not_to have_selector "#id_#{collections[2].id}[checked='checked']" expect(rendered).to have_selector "#id_#{collections[3].id}[checked='checked']" end end
Version data entries
3 entries across 3 versions & 1 rubygems