Sha256: 75506d00a7eaf617173af631cc2a85e0c9a7187c2114c95b11e39f27fa524b91

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

require "rails_helper"

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

      ("A".."Z").each { |letter| create(:user, name: "User #{letter} Name") }
    end

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

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

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

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

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

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

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

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

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

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

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

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

    describe "excludes" do
      it "does not list deleted User" do
        create(:user, :deleted, name: "Deleted User Name")

        visit "/backend/users"

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

Version data entries

1 entries across 1 versions & 1 rubygems

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