espinita 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +36 -19
- data/Rakefile +15 -17
- data/lib/espinita/auditor_behavior.rb +10 -9
- data/lib/espinita/auditor_request.rb +4 -2
- data/lib/espinita/version.rb +1 -1
- data/spec/controllers/audits_controller_spec.rb +19 -5
- data/spec/dummy/log/test.log +7542 -23597
- data/spec/models/models/general_model_spec.rb +22 -8
- data/spec/spec_helper.rb +9 -2
- metadata +23 -13
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -28
@@ -54,8 +54,6 @@ describe GeneralModel do
|
|
54
54
|
it "model should be associated" do
|
55
55
|
expect(updated_model.audits).to have(2).audits
|
56
56
|
end
|
57
|
-
|
58
|
-
|
59
57
|
end
|
60
58
|
|
61
59
|
describe "update model with exclusion key" do
|
@@ -75,7 +73,7 @@ describe GeneralModel do
|
|
75
73
|
}
|
76
74
|
|
77
75
|
it "auditable should not save exluded cols in changes" do
|
78
|
-
|
76
|
+
|
79
77
|
expect(excluded_cols).to_not be_empty
|
80
78
|
end
|
81
79
|
|
@@ -84,7 +82,7 @@ describe GeneralModel do
|
|
84
82
|
expect(updated_model.audits.first.audited_changes.keys).to_not include("name")
|
85
83
|
end
|
86
84
|
|
87
|
-
it "model should have an array of 2 values on audited changes " do
|
85
|
+
it "model should have an array of 2 values on audited changes " do
|
88
86
|
updated_model.audits.last.audited_changes.keys.each do |key|
|
89
87
|
expect(updated_model.audits.last.audited_changes[key.to_sym].size).to eql(2)
|
90
88
|
end
|
@@ -92,7 +90,7 @@ describe GeneralModel do
|
|
92
90
|
end
|
93
91
|
|
94
92
|
describe "update with audit comment" do
|
95
|
-
|
93
|
+
|
96
94
|
let(:general_model) do
|
97
95
|
FactoryGirl.create(:general_model)
|
98
96
|
end
|
@@ -118,7 +116,7 @@ describe GeneralModel do
|
|
118
116
|
|
119
117
|
describe "save with current user" do
|
120
118
|
|
121
|
-
before :each do
|
119
|
+
before :each do
|
122
120
|
RequestStore.store[:audited_user] = current_user
|
123
121
|
end
|
124
122
|
|
@@ -156,11 +154,10 @@ describe GeneralModel do
|
|
156
154
|
it "should have 1 audit" do
|
157
155
|
expect(updated_model).to have(0).audits
|
158
156
|
end
|
159
|
-
|
160
157
|
end
|
161
158
|
|
162
159
|
describe "audit only on create" do
|
163
|
-
|
160
|
+
|
164
161
|
let(:general_model) do
|
165
162
|
[:create, :update, :destroy].each do |c|
|
166
163
|
GeneralModel.reset_callbacks(c)
|
@@ -203,4 +200,21 @@ describe GeneralModel do
|
|
203
200
|
end
|
204
201
|
end
|
205
202
|
|
203
|
+
describe "audit when delete model" do
|
204
|
+
let(:model) do
|
205
|
+
[:create, :update, :destroy].each do |c|
|
206
|
+
GeneralModel.reset_callbacks(c)
|
207
|
+
end
|
208
|
+
GeneralModel.auditable on: [:destroy]
|
209
|
+
FactoryGirl.create(:general_model)
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should create 1 audit when destroy" do
|
213
|
+
expect(model).to have(0).audits
|
214
|
+
model.destroy
|
215
|
+
expect(model).to have(1).audits
|
216
|
+
expect(model.audits.last.comment).to include("deleted model #{model.id}")
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
206
220
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -14,11 +14,18 @@ require 'capybara/rspec'
|
|
14
14
|
require 'shoulda/matchers/integrations/rspec'
|
15
15
|
|
16
16
|
require "espinita"
|
17
|
-
|
18
|
-
|
19
17
|
require 'support/schema'
|
20
18
|
require 'support/models'
|
21
19
|
|
22
20
|
RSpec.configure do |config|
|
23
21
|
config.infer_base_class_for_anonymous_controllers = false
|
22
|
+
|
23
|
+
config.before(:suite) do
|
24
|
+
DatabaseCleaner.strategy = :transaction
|
25
|
+
DatabaseCleaner.clean_with(:truncation)
|
26
|
+
end
|
27
|
+
|
28
|
+
config.before(:each) do
|
29
|
+
DatabaseCleaner.strategy = :truncation
|
30
|
+
end
|
24
31
|
end
|
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
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Michelson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03
|
11
|
+
date: 2014-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -54,6 +54,20 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: factory_girl
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - '>='
|
@@ -67,7 +81,7 @@ dependencies:
|
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: factory_girl_rails
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - '>='
|
@@ -81,7 +95,7 @@ dependencies:
|
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: rspec-collection_matchers
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - '>='
|
@@ -95,19 +109,19 @@ dependencies:
|
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name: shoulda
|
112
|
+
name: shoulda
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- -
|
115
|
+
- - '='
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
117
|
+
version: 3.5.0
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- -
|
122
|
+
- - '='
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
124
|
+
version: 3.5.0
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: database_cleaner
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -189,11 +203,9 @@ files:
|
|
189
203
|
- spec/dummy/config/locales/en.yml
|
190
204
|
- spec/dummy/config/routes.rb
|
191
205
|
- spec/dummy/config.ru
|
192
|
-
- spec/dummy/db/development.sqlite3
|
193
206
|
- spec/dummy/db/migrate/20131029211126_create_general_models.rb
|
194
207
|
- spec/dummy/db/migrate/20131030014901_create_users.rb
|
195
208
|
- spec/dummy/db/schema.rb
|
196
|
-
- spec/dummy/log/development.log
|
197
209
|
- spec/dummy/log/test.log
|
198
210
|
- spec/dummy/public/404.html
|
199
211
|
- spec/dummy/public/422.html
|
@@ -266,11 +278,9 @@ test_files:
|
|
266
278
|
- spec/dummy/config/locales/en.yml
|
267
279
|
- spec/dummy/config/routes.rb
|
268
280
|
- spec/dummy/config.ru
|
269
|
-
- spec/dummy/db/development.sqlite3
|
270
281
|
- spec/dummy/db/migrate/20131029211126_create_general_models.rb
|
271
282
|
- spec/dummy/db/migrate/20131030014901_create_users.rb
|
272
283
|
- spec/dummy/db/schema.rb
|
273
|
-
- spec/dummy/log/development.log
|
274
284
|
- spec/dummy/log/test.log
|
275
285
|
- spec/dummy/public/404.html
|
276
286
|
- spec/dummy/public/422.html
|
Binary file
|
@@ -1,28 +0,0 @@
|
|
1
|
-
[1m[36m (1.8ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
2
|
-
[1m[35m (1.4ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
3
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
4
|
-
Migrating to CreateAuditableAudits (20131029200927)
|
5
|
-
[1m[35m (0.1ms)[0m begin transaction
|
6
|
-
[1m[36m (0.4ms)[0m [1mCREATE TABLE "auditable_audits" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "auditable_id" integer, "auditable_type" varchar(255), "user_id" integer, "user_type" varchar(255), "audited_changes" text, "version" integer, "remote_address" varchar(255), "created_at" datetime, "updated_at" datetime) [0m
|
7
|
-
[1m[35m (0.1ms)[0m CREATE INDEX "index_auditable_audits_on_auditable_id_and_auditable_type" ON "auditable_audits" ("auditable_id", "auditable_type")
|
8
|
-
[1m[36m (0.1ms)[0m [1mCREATE INDEX "index_auditable_audits_on_user_id_and_user_type" ON "auditable_audits" ("user_id", "user_type")[0m
|
9
|
-
[1m[35mSQL (0.3ms)[0m INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20131029200927"]]
|
10
|
-
[1m[36m (1.4ms)[0m [1mcommit transaction[0m
|
11
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.2ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
12
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.2ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
13
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
14
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.2ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
15
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
16
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
17
|
-
Migrating to CreateGeneralModels (20131029211126)
|
18
|
-
[1m[35m (0.1ms)[0m begin transaction
|
19
|
-
[1m[36m (0.6ms)[0m [1mCREATE TABLE "general_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "name" varchar(255), "settings" text, "position" integer, "created_at" datetime, "updated_at" datetime) [0m
|
20
|
-
[1m[35m (0.1ms)[0m CREATE INDEX "index_general_models_on_user_id" ON "general_models" ("user_id")
|
21
|
-
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20131029211126"]]
|
22
|
-
[1m[35m (2.6ms)[0m commit transaction
|
23
|
-
Migrating to CreateUsers (20131030014901)
|
24
|
-
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
25
|
-
[1m[35m (0.4ms)[0m CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "last_name" varchar(255), "email" varchar(255), "created_at" datetime, "updated_at" datetime)
|
26
|
-
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20131030014901"]]
|
27
|
-
[1m[35m (1.6ms)[0m commit transaction
|
28
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|