Sha256: f70504f98e5a6628f7117b3d891994c40e0355549ff240bd3aa26d09688bc2bc

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

require "spec_helper"

module Decidim
  module Admin
    describe OrganizationPolicy do
      let(:organization) { create(:organization) }

      subject { described_class.new(user, organization) }

      context "within the same organization" do
        context "being a regular user" do
          let(:user) { create(:user, organization: organization) }

          it { is_expected.to forbid_action(:update) }
        end

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

          it { is_expected.to permit_action(:update) }
        end
      end

      context "in another organization" do
        let(:other_organization) { create(:organization) }

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

          it { is_expected.to forbid_action(:update) }
        end

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

          it { is_expected.to forbid_action(:update) }
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-0.0.1.alpha7 decidim-admin/spec/policies/organization_policy_spec.rb
decidim-0.0.1.alpha6 decidim-admin/spec/policies/organization_policy_spec.rb
decidim-0.0.1.alpha5 decidim-admin/spec/policies/organization_policy_spec.rb
decidim-0.0.1.alpha4 decidim-admin/spec/policies/organization_policy_spec.rb
decidim-0.0.1.alpha3 decidim-admin/spec/policies/organization_policy_spec.rb