glebtv_mongoid_userstamp 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mongoid/userstamp.rb +2 -2
- data/lib/mongoid/userstamp/version.rb +1 -1
- data/spec/mongoid/userstamp_spec.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baa875b76008936bf0ab968862c2402cc996be50da6597460679682f768ce87d
|
4
|
+
data.tar.gz: 91b99770c94fbed0bd6ebbfab098a6d0205107d9773c825be930dde9c79c6a47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c88703face9dbab1c7f7db92aea3dbea7e25aa0329674ca92353154120056c37884a2998a1da02f83704b6baa30cf0951f80e93b2a1c5642255b46d47c934594
|
7
|
+
data.tar.gz: b53b23b2a8f1c44d80e1cbb9aadc0f544048b4847d3fdc48af3033dc8d0caee795bfb45bf48c76737d2f3e9d76aa42a7c6fbc4b97c84ab68a8775d1963246839
|
data/lib/mongoid/userstamp.rb
CHANGED
@@ -3,8 +3,8 @@ module Mongoid
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
belongs_to Userstamp.config.creator_field, class_name: Userstamp.config.user_model_name, autosave: false,
|
7
|
-
belongs_to Userstamp.config.updater_field, class_name: Userstamp.config.user_model_name, autosave: false,
|
6
|
+
belongs_to Userstamp.config.creator_field, class_name: Userstamp.config.user_model_name, autosave: false, optional: true
|
7
|
+
belongs_to Userstamp.config.updater_field, class_name: Userstamp.config.user_model_name, autosave: false, optional: true
|
8
8
|
|
9
9
|
before_validation :set_updater
|
10
10
|
before_validation :set_creator
|
@@ -130,6 +130,18 @@ describe Mongoid::Userstamp do
|
|
130
130
|
end
|
131
131
|
subject { Novel.new(name: 'Ethyl the Aardvark goes Quantity Surveying') }
|
132
132
|
|
133
|
+
context 'when created without user' do
|
134
|
+
before do
|
135
|
+
User.current = nil
|
136
|
+
subject.save!
|
137
|
+
end
|
138
|
+
|
139
|
+
it { expect(subject.c_by_id).to eq(nil) }
|
140
|
+
it { expect(subject.c_by).to eq(nil) }
|
141
|
+
it { expect(subject.u_by_id).to eq(nil) }
|
142
|
+
it { expect(subject.u_by).to eq(nil) }
|
143
|
+
end
|
144
|
+
|
133
145
|
context 'when created by a user' do
|
134
146
|
before do
|
135
147
|
User.current = user_1
|