-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathempty_activerecord_spec.rb
More file actions
33 lines (28 loc) · 1011 Bytes
/
empty_activerecord_spec.rb
File metadata and controls
33 lines (28 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true
RSpec.describe CallbackHell, "with an empty ActiveRecord" do
def normalization_supported?
ActiveRecord::Base.respond_to?(:normalizes)
end
let(:options) { {} }
subject(:ar) { CallbackHell::Collector.new(ApplicationRecord, **options).collect }
it "does not have any own or rails callbacks or validations" do
expect(ar).not_to have_callback(origin: :rails)
expect(ar).not_to have_callback(origin: :own)
expect(ar).not_to have_validation(origin: :own)
end
context "with full mode" do
let(:options) { {mode: :full} }
it "does have callbacks on an empty ActiveRecord class" do
expect(ar).to have_callback(
method_name: :cant_modify_encrypted_attributes_when_frozen,
origin: :rails, inherited: false
)
if normalization_supported?
expect(ar).to have_callback(
method_name: :normalize_changed_in_place_attributes,
origin: :rails, inherited: false
)
end
end
end
end