Sha256: e26551d07a9040e4db1ee6f2f77c6d8c37baea3e36beee8a88d4bc3d85042d16

Contents?: true

Size: 1.88 KB

Versions: 1

Compression:

Stored size: 1.88 KB

Contents

# frozen_string_literal: true

require "rails_helper"

RSpec.describe "Backend - Designs (HTML)", type: :feature do
  describe "listing" do
    before do
      stub_authorization!

      ("A".."Z").each do |letter|
        create(:design, name: "Design #{letter} Name")
      end
    end

    describe "sorted ascending from A-Z (default)" do
      it "displays the first resource" do
        visit "/backend/designs"

        within("tbody") do
          expect(page.find("tr:eq(1)")).to have_content("Design A Name")
        end
      end

      it "displays the second resource" do
        visit "/backend/designs"

        within("tbody") do
          expect(page.find("tr:eq(2)")).to have_content("Design B Name")
        end
      end

      it "displays the third resource" do
        visit "/backend/designs"

        within("tbody") do
          expect(page.find("tr:eq(3)")).to have_content("Design C Name")
        end
      end
    end

    describe "paginated" do
      it "finds the second page of Designs" do
        visit "/backend/designs?page=2"

        expect(page).to have_content("Design Y Name")
      end

      it "does not find the first page of Designs with `per` count" do
        visit "/backend/designs?page=2&per=3"

        expect(page).not_to have_content("Design A Name")
      end

      it "finds the second page of Designs with `per` count" do
        visit "/backend/designs?page=2&per=3"

        expect(page).to have_content("Design D Name")
      end

      it "finds nothing outside the count" do
        visit "/backend/designs?page=2&per=26"

        expect(page).to have_content("No designs found.")
      end
    end

    describe "excludes" do
      it "does not list deleted Designs" do
        create(:design, :deleted, name: "Deleted Design Name")

        visit "/backend/designs"

        expect(page).not_to have_content("Deleted Design Name")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archangel-0.4.0 spec/features/backend/designs/listing_spec.rb