Sha256: dff1d8857861b116a3bb9b98e74293a32a358756e3875c87c9f99699cc1d2b4f

Contents?: true

Size: 1.36 KB

Versions: 11

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe "Admin dashboard access control", type: :feature do
  let(:organization) { create(:organization) }

  before do
    switch_to_host(organization.host)
  end

  context "when authenticated" do
    before do
      login_as user, scope: :user
    end

    context "a regular user" do
      let(:user) { create(:user, organization: organization) }

      it "can't access the admin dashboard" do
        visit decidim_admin.root_path
        expect(page.status_code).to eq(404)
      end
    end

    context "an organization admin" do
      let(:user) { create(:user, :admin, organization: organization) }

      it "can access the admin dashboard" do
        visit decidim_admin.root_path
        expect(page.status_code).to eq(200)
        expect(page).to have_content("Dashboard")
      end
    end

    context "an admin from another organization" do
      let(:other_organization) { create(:organization) }
      let(:user) { create(:user, :admin, organization: other_organization) }

      it "can't access the admin dashboard" do
        visit decidim_admin.root_path
        expect(page.status_code).to eq(404)
      end
    end
  end

  describe "when unauthenticated" do
    it "can't access the admin dashboard" do
      visit decidim_admin.root_path
      expect(page.body).to include("You need to sign in")
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
decidim-0.0.4 decidim-admin/spec/features/admin_access_control.rb
decidim-0.0.3 decidim-admin/spec/features/admin_access_control.rb
decidim-0.0.2 decidim-admin/spec/features/admin_access_control.rb
decidim-0.0.1 decidim-admin/spec/features/admin_access_control.rb
decidim-0.0.1.alpha9 decidim-admin/spec/features/admin_access_control.rb
decidim-0.0.1.alpha8 decidim-admin/spec/features/admin_access_control.rb
decidim-0.0.1.alpha7 decidim-admin/spec/features/admin_access_control.rb
decidim-0.0.1.alpha6 decidim-admin/spec/features/admin_access_control.rb
decidim-0.0.1.alpha5 decidim-admin/spec/features/admin_access_control.rb
decidim-0.0.1.alpha4 decidim-admin/spec/features/admin_access_control.rb
decidim-0.0.1.alpha3 decidim-admin/spec/features/admin_access_control.rb