cia 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,4 +1,3 @@
1
1
  rvm:
2
- - ree
3
- - 1.9.2
4
2
  - 1.9.3
3
+ - 2.0.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cia (0.5.1)
4
+ cia (0.5.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/cia
3
3
  specs:
4
- cia (0.4.4)
4
+ cia (0.5.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/cia
3
3
  specs:
4
- cia (0.4.4)
4
+ cia (0.5.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
@@ -1,3 +1,3 @@
1
1
  module CIA
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
3
3
  end
@@ -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
- event = nil
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
@@ -15,6 +15,7 @@ ActiveRecord::Base.establish_connection(
15
15
  :database => ":memory:"
16
16
  )
17
17
 
18
+ ActiveRecord::Schema.verbose = false
18
19
  ActiveRecord::Schema.define(:version => 1) do
19
20
  eval(File.read(File.expand_path('../../MIGRATION.rb', __FILE__)))
20
21
 
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.1
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-03 00:00:00.000000000 Z
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: 763715577879063056
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: 763715577879063056
65
+ hash: 3219662641279385344
66
66
  requirements: []
67
67
  rubyforge_project:
68
68
  rubygems_version: 1.8.25