summaryrefslogtreecommitdiff
path: root/spec/models/concerns
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-12 21:08:48 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-12 21:08:48 +0000
commit006e89697dd5165f355afc20fc6bb0cdfa7b381a (patch)
tree9095aeb37b2c80f3b0cc5a8dfd27baf93f05b61b /spec/models/concerns
parent43e3dc2f95a25c600e08f65d4f1c406a1a63ed3d (diff)
downloadgitlab-ce-006e89697dd5165f355afc20fc6bb0cdfa7b381a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/concerns')
-rw-r--r--spec/models/concerns/bulk_insert_safe_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/models/concerns/bulk_insert_safe_spec.rb b/spec/models/concerns/bulk_insert_safe_spec.rb
new file mode 100644
index 00000000000..91884680738
--- /dev/null
+++ b/spec/models/concerns/bulk_insert_safe_spec.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe BulkInsertSafe do
+ class BulkInsertItem < ApplicationRecord
+ include BulkInsertSafe
+ end
+
+ module InheritedUnsafeMethods
+ extend ActiveSupport::Concern
+
+ included do
+ after_save -> { "unsafe" }
+ end
+ end
+
+ module InheritedSafeMethods
+ extend ActiveSupport::Concern
+
+ included do
+ after_initialize -> { "safe" }
+ end
+ end
+
+ it_behaves_like 'a BulkInsertSafe model', BulkInsertItem
+
+ context 'when inheriting class methods' do
+ it 'raises an error when method is not bulk-insert safe' do
+ expect { BulkInsertItem.include(InheritedUnsafeMethods) }.to(
+ raise_error(subject::MethodNotAllowedError))
+ end
+
+ it 'does not raise an error when method is bulk-insert safe' do
+ expect { BulkInsertItem.include(InheritedSafeMethods) }.not_to raise_error
+ end
+ end
+end