diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/models/concerns/limitable_spec.rb | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/models/concerns/limitable_spec.rb')
-rw-r--r-- | spec/models/concerns/limitable_spec.rb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/spec/models/concerns/limitable_spec.rb b/spec/models/concerns/limitable_spec.rb index 753e2a8ee5e..6b25ed39efb 100644 --- a/spec/models/concerns/limitable_spec.rb +++ b/spec/models/concerns/limitable_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' +require 'active_model' RSpec.describe Limitable do let(:minimal_test_class) do @@ -35,6 +36,28 @@ RSpec.describe Limitable do instance.valid?(:create) end + + context 'with custom relation' do + before do + MinimalTestClass.limit_relation = :custom_relation + end + + it 'triggers custom limit_relation' do + instance = MinimalTestClass.new + + def instance.project + @project ||= Object.new + end + + limits = Object.new + custom_relation = Object.new + expect(instance).to receive(:custom_relation).and_return(custom_relation) + expect(instance.project).to receive(:actual_limits).and_return(limits) + expect(limits).to receive(:exceeded?).with(instance.class.name.demodulize.tableize, custom_relation).and_return(false) + + instance.valid?(:create) + end + end end context 'with global limit' do |