Sha256: ea9cad289583f7ccf59dd1da73a6978141a6c56f868cf57e5e69cb2f33fb6c23

Contents?: true

Size: 1.55 KB

Versions: 24

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

require "spec_helper"

shared_examples_for "has attachments" do
  context "when it has attachments", processing_uploads_for: Decidim::AttachmentUploader do
    let!(:document) { create(:attachment, :with_pdf, attached_to: attached_to) }

    let!(:image) { create(:attachment, attached_to: attached_to) }

    before do
      visit current_path
    end

    it "shows them" do
      within "div.wrapper .documents" do
        expect(page).to have_content(/#{translated(document.title, locale: :en)}/i)
      end

      within "div.wrapper .images" do
        expect(page).to have_css("img.thumbnail")
      end
    end
  end

  context "that are ordered by weight", processing_uploads_for: Decidim::AttachmentUploader do
    let!(:last_document) { create(:attachment, :with_pdf, attached_to: attached_to, weight: 2) }
    let!(:first_document) { create(:attachment, :with_pdf, attached_to: attached_to, weight: 1) }
    let!(:last_image) { create(:attachment, attached_to: attached_to, weight: 2) }
    let!(:fist_image) { create(:attachment, attached_to: attached_to, weight: 1) }

    before do
      visit current_path
    end

    it "shows them ordered" do
      within "div.wrapper .documents" do
        expect(translated(first_document.title, locale: :en)).to appear_before(translated(last_document.title, locale: :en))
      end

      within "div.wrapper .images" do
        expect(strip_tags(translated(fist_image.description, locale: :en))).to appear_before(strip_tags(translated(last_image.description, locale: :en)))
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
decidim-core-0.17.2 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.17.1 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.16.1 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.17.0 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.16.0 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.15.2 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.15.1 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.15.0 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.14.4 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.14.3 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.14.2 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.14.1 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.13.1 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.12.2 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.13.0 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.12.1 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.13.0.pre1 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.12.0 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.11.2 lib/decidim/core/test/shared_examples/has_attachments.rb
decidim-core-0.12.0.pre lib/decidim/core/test/shared_examples/has_attachments.rb