cia 0.5.1 → 0.5.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.
- data/.travis.yml +1 -2
- data/Gemfile.lock +1 -1
- data/gemfiles/rails2.gemfile.lock +1 -1
- data/gemfiles/rails3.gemfile.lock +1 -1
- data/lib/cia.rb +1 -1
- data/lib/cia/version.rb +1 -1
- data/spec/cia/event_spec.rb +2 -2
- data/spec/cia_spec.rb +16 -7
- data/spec/spec_helper.rb +1 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/lib/cia.rb
CHANGED
@@ -38,7 +38,7 @@ module CIA
|
|
38
38
|
return if options and options[:unless] and source.send(options[:unless])
|
39
39
|
|
40
40
|
changes = (source.cia_previous_changes || source.cia_changes).slice(*source.class.audited_attributes)
|
41
|
-
message = source.audit_message if source.respond_to?(:audit_message)
|
41
|
+
message = source.audit_message.presence if source.respond_to?(:audit_message)
|
42
42
|
|
43
43
|
return if not message and changes.empty? and action.to_s == "update"
|
44
44
|
|
data/lib/cia/version.rb
CHANGED
data/spec/cia/event_spec.rb
CHANGED
@@ -43,12 +43,12 @@ describe CIA::Event do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "does not validates source when source_display_name is present" do
|
46
|
-
create_event(:source_id => -111, :source_type => 'FakeTypeHere', :source_display_name => 'abc')
|
46
|
+
create_event(:source => nil, :source_id => -111, :source_type => 'FakeTypeHere', :source_display_name => 'abc')
|
47
47
|
end
|
48
48
|
|
49
49
|
it "validates source when source_display_name is blank" do
|
50
50
|
expect{
|
51
|
-
create_event(:source_id => -111, :source_type => 'FakeTypeHere', :source_display_name => '')
|
51
|
+
create_event(:source => nil, :source_id => -111, :source_type => 'FakeTypeHere', :source_display_name => '')
|
52
52
|
}.to raise_error
|
53
53
|
end
|
54
54
|
end
|
data/spec/cia_spec.rb
CHANGED
@@ -211,6 +211,15 @@ describe CIA do
|
|
211
211
|
event.attribute_changes.map { |c| [c.attribute_name, c.old_value, c.new_value] }
|
212
212
|
end
|
213
213
|
|
214
|
+
def no_audit_created!
|
215
|
+
event = nil
|
216
|
+
expect{
|
217
|
+
event = yield
|
218
|
+
}.to_not change{ CIA::Event.count }
|
219
|
+
|
220
|
+
event.should == nil
|
221
|
+
end
|
222
|
+
|
214
223
|
it "records attributes in transaction" do
|
215
224
|
event = nil
|
216
225
|
CIA.audit :actor => User.create!, :ip_address => "1.2.3.4" do
|
@@ -262,12 +271,7 @@ describe CIA do
|
|
262
271
|
it "does not record unaudited attribute changes" do
|
263
272
|
source = Car.create!
|
264
273
|
source.drivers = 2
|
265
|
-
|
266
|
-
expect{
|
267
|
-
event = CIA.record(:update, source)
|
268
|
-
}.to_not change{ CIA::Event.count }
|
269
|
-
|
270
|
-
event.should == nil
|
274
|
+
no_audit_created!{ CIA.record(:update, source) }
|
271
275
|
end
|
272
276
|
|
273
277
|
it "records audit_message as message even if there are no changes" do
|
@@ -279,10 +283,15 @@ describe CIA do
|
|
279
283
|
parse_event_changes(event).should == []
|
280
284
|
end
|
281
285
|
|
286
|
+
it "does not record if it's empty and there are no changes" do
|
287
|
+
source = CarWithAMessage.create!
|
288
|
+
source.audit_message = " "
|
289
|
+
no_audit_created!{ CIA.record(:update, source) }
|
290
|
+
end
|
291
|
+
|
282
292
|
it "record non-updates even without changes" do
|
283
293
|
source = Car.create!
|
284
294
|
event = CIA.record(:create, source)
|
285
|
-
|
286
295
|
parse_event_changes(event).should == []
|
287
296
|
end
|
288
297
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: michael@grosser.it
|
@@ -53,7 +53,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
segments:
|
55
55
|
- 0
|
56
|
-
hash:
|
56
|
+
hash: 3219662641279385344
|
57
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
58
|
none: false
|
59
59
|
requirements:
|
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
62
|
version: '0'
|
63
63
|
segments:
|
64
64
|
- 0
|
65
|
-
hash:
|
65
|
+
hash: 3219662641279385344
|
66
66
|
requirements: []
|
67
67
|
rubyforge_project:
|
68
68
|
rubygems_version: 1.8.25
|