espinita 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,12 +43,20 @@ describe GeneralModel do
43
43
  general_model
44
44
  end
45
45
 
46
+ let(:excluded_cols){
47
+ updated_model.class.excluded_cols & updated_model.audits.last.audited_changes.keys.map(&:to_s)
48
+ }
49
+
50
+ it "auditable should not save exluded cols in changes" do
51
+ expect(excluded_cols).to be_empty
52
+ end
53
+
46
54
  it "model should be associated" do
47
55
  expect(updated_model.audits).to have(2).audits
48
56
  end
49
57
  end
50
58
 
51
- describe "update model with only name key" do
59
+ describe "update model with exclusion key" do
52
60
 
53
61
  let(:general_model) do
54
62
  FactoryGirl.create(:general_model)
@@ -60,8 +68,18 @@ describe GeneralModel do
60
68
  general_model
61
69
  end
62
70
 
63
- it "model should be associated" do
71
+ let(:excluded_cols){
72
+ updated_model.class.excluded_cols & updated_model.audits.last.audited_changes.keys.map(&:to_s)
73
+ }
74
+
75
+ it "auditable should not save exluded cols in changes" do
76
+
77
+ expect(excluded_cols).to_not be_empty
78
+ end
79
+
80
+ it "model should be associated and not include name in audited_changes" do
64
81
  expect(updated_model.audits).to have(1).audits
82
+ expect(updated_model.audits.first.audited_changes.keys).to_not include("name")
65
83
  end
66
84
  end
67
85
 
@@ -113,6 +131,26 @@ describe GeneralModel do
113
131
  end
114
132
  end
115
133
 
134
+ describe "audit defaults excepts" do
135
+ let(:general_model) do
136
+ [:create, :update, :destroy].each do |c|
137
+ GeneralModel.reset_callbacks(c)
138
+ end
139
+ GeneralModel.auditable on: [:update]
140
+ FactoryGirl.create(:general_model)
141
+ end
142
+
143
+ let(:updated_model) do
144
+ general_model.update_attributes(updated_at: 1.day.from_now )
145
+ general_model
146
+ end
147
+
148
+ it "should have 1 audit" do
149
+ expect(updated_model).to have(0).audits
150
+ end
151
+
152
+ end
153
+
116
154
  describe "audit only on create" do
117
155
 
118
156
  let(:general_model) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: espinita
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Michelson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-04 00:00:00.000000000 Z
11
+ date: 2013-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -204,7 +204,6 @@ files:
204
204
  - spec/factories/auditable_audits.rb
205
205
  - spec/factories/general_models.rb
206
206
  - spec/factories/users.rb
207
- - spec/integration/navigation_test.rb
208
207
  - spec/models/espinita/audit_spec.rb
209
208
  - spec/models/models/general_model_spec.rb
210
209
  - spec/models/models/user_spec.rb
@@ -282,7 +281,6 @@ test_files:
282
281
  - spec/factories/auditable_audits.rb
283
282
  - spec/factories/general_models.rb
284
283
  - spec/factories/users.rb
285
- - spec/integration/navigation_test.rb
286
284
  - spec/models/espinita/audit_spec.rb
287
285
  - spec/models/models/general_model_spec.rb
288
286
  - spec/models/models/user_spec.rb
@@ -1,10 +0,0 @@
1
- require 'test_helper'
2
-
3
- class NavigationTest < ActionDispatch::IntegrationTest
4
- fixtures :all
5
-
6
- # test "the truth" do
7
- # assert true
8
- # end
9
- end
10
-