Skip to content
Snippets Groups Projects
Select Git revision
  • 81bec38c24787662a504d2384aaa187d5cd533b6
  • master default protected
  • replication_test
  • dev protected
  • release-1.10 protected
  • 556-usage-statistics
  • 553-semantic-recommendation-2
  • 553-semantic-recommendation
  • release-1.9 protected
  • 551-init-broker-service-permissions
  • 549-test-oai-pmh
  • 545-saving-multiple-times-breaks-pid-metadata
  • 499-standalone-compute-service-2
  • 539-load-tests
  • hotfix/helm-chart
  • luca_ba_new_interface
  • 534-bug-when-adding-access-to-user-that-is-not-registered-at-dashboard-service
  • release-1.8 protected
  • 533-integrate-semantic-recommendation
  • feature/openshift
  • 518-spark-doesn-t-map-the-headers-correct
  • v1.10.4 protected
  • v1.10.3 protected
  • v1.10.2 protected
  • v1.10.1 protected
  • v1.10.0-rc13 protected
  • v1.10.0-rc12 protected
  • v1.10.0-rc11 protected
  • v1.10.0-rc10 protected
  • v1.10.0-rc9 protected
  • v1.10.0-rc8 protected
  • v1.10.0-rc7 protected
  • v1.10.0-rc6 protected
  • v1.10.0-rc5 protected
  • v1.10.0-rc4 protected
  • v1.10.0-rc3 protected
  • v1.10.0-rc2 protected
  • v1.10.0rc1 protected
  • v1.10.0rc0 protected
  • v1.10.0 protected
  • v1.9.3 protected
41 results

data-db.md

Blame
  • text_policy_spec.rb 1.70 KiB
    require "rails_helper"
    
    RSpec.describe TextPolicy do
      subject { described_class.new(user, text) }
      let(:text) { FactoryBot.create(:text) }
    
      context "for an applicant" do
        let(:user) { FactoryBot.create(:user, :applicant) }
    
        it { is_expected.to forbid_action(:index) }
        it { is_expected.to forbid_action(:show) }
        it { is_expected.to forbid_new_and_create_actions }
        it { is_expected.to forbid_edit_and_update_actions }
        it { is_expected.to forbid_action(:destroy) }
      end
    
      context "for an apprentice" do
        let(:user) { FactoryBot.create(:user, :apprentice) }
    
        it { is_expected.to forbid_action(:index) }
        it { is_expected.to forbid_action(:show) }
        it { is_expected.to forbid_new_and_create_actions }
        it { is_expected.to forbid_edit_and_update_actions }
        it { is_expected.to forbid_action(:destroy) }
      end
    
      context "for an editor" do
        let(:user) { FactoryBot.create(:user, :editor) }
    
        it { is_expected.to forbid_action(:index) }
        it { is_expected.to forbid_action(:show) }
        it { is_expected.to forbid_new_and_create_actions }
        it { is_expected.to forbid_edit_and_update_actions }
        it { is_expected.to forbid_action(:destroy) }
      end
    
      context "for an admin" do
        let(:user) { FactoryBot.create(:user, :admin) }
    
        it { is_expected.to permit_action(:index) }
        it { is_expected.to permit_action(:show) }
        it { is_expected.to permit_new_and_create_actions }
        it { is_expected.to permit_edit_and_update_actions }
        it { is_expected.to permit_action(:destroy) }
      end
    
      describe "Scope" do
        let(:user) { FactoryBot.create(:user) }
    
        it "returns all texts" do
          expect(described_class::Scope.new(user, Text.all).resolve).to eq(Text.all)
        end
      end
    end