Sha256: 491e6ce6ff33c8028a13c11b66c5706848f846ff1bad86efe68e343490d2f023

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Decidim::Admin::ManageableParticipatoryProcessesForUser do
  let!(:organization_process) { create :participatory_process, organization: user.organization }
  let!(:external_process) { create :participatory_process }

  subject { described_class.new(user) }

  context "when the user is an admin" do
    let(:user) { create :user, :admin }

    it "returns only the organization processes" do
      expect(subject.query).to eq [organization_process]
    end
  end

  context "when the user is a collaborator" do
    let(:user) { create :user, :collaborator }

    it "returns only the organization processes" do
      expect(subject.query).to eq [organization_process]
    end
  end

  context "when the user is not an admin" do
    let(:user) { create :user }
    let!(:organization_process2) { create :participatory_process, organization: user.organization }

    before do
      create :participatory_process_user_role, user: user, participatory_process: organization_process
    end

    it "returns the processes the user can admin" do
      expect(subject.query).to eq [organization_process]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-0.4.0 decidim-admin/spec/queries/manageable_participatory_processes_for_user_spec.rb
decidim-0.3.2 decidim-admin/spec/queries/manageable_participatory_processes_for_user_spec.rb
decidim-0.3.1 decidim-admin/spec/queries/manageable_participatory_processes_for_user_spec.rb
decidim-0.3.0 decidim-admin/spec/queries/manageable_participatory_processes_for_user_spec.rb
decidim-0.2.0 decidim-admin/spec/queries/manageable_participatory_processes_for_user_spec.rb