rootstrap/rails_api_base

View on GitHub
spec/policies/application_policy_spec.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

describe ApplicationPolicy do
  subject { described_class }

  permissions :update?, :index?, :show?, :create?, :new?, :edit?, :destroy? do
    context 'when is an user' do
      let(:user) { build(:user) }

      it 'denies access' do
        expect(subject).not_to permit(user, user)
      end
    end
  end

  describe 'scope' do
    subject { ApplicationPolicy::Scope.new(user, mock_model).resolve }

    let(:user) { create(:user) }
    let(:mock_model) { double('MockModel', all: true) }

    it 'shows all models' do
      expect(subject).to be(true)
    end
  end
end