Sha256: e1d5ea25a7c2493600db57af2691557793ee0e974faf59e3a1b9ebb6af320abd
Contents?: true
Size: 1.39 KB
Versions: 5
Compression:
Stored size: 1.39 KB
Contents
# frozen_string_literal: true require "spec_helper" module Decidim module Admin describe OrganizationDashboardConstraint do let(:organization) { create(:organization) } let(:request) do double( env: { "decidim.current_organization" => organization, "warden" => warden } ) end let(:warden) do double( authenticate!: authenticated, user: user ) end subject { described_class.new(request).matches? } context "when authenticated" do let(:authenticated) { true } context "a regular user" do let(:user) { create(:user, :confirmed, organization: organization) } it { is_expected.to be_falsey } end context "an organization admin" do let(:user) { create(:user, :confirmed, :admin, organization: organization) } it { is_expected.to be_truthy } end context "an admin from another organization" do let(:other_organization) { create(:organization) } let(:user) { create(:user, :confirmed, :admin, organization: other_organization) } it { is_expected.to be_falsey } end end describe "when unauthenticated" do let(:authenticated) { false } let(:user) { nil } it { is_expected.to be_falsey } end end end end
Version data entries
5 entries across 5 versions & 1 rubygems