espinita 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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.7
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-15 00:00:00.000000000 Z
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: factory_girl
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: factory_girl_rails
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-matchers
112
+ name: shoulda
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - ~>
115
+ - - '='
102
116
  - !ruby/object:Gem::Version
103
- version: '1.0'
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: '1.0'
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
@@ -1,28 +0,0 @@
1
-  (1.8ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
2
-  (1.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
4
- Migrating to CreateAuditableAudits (20131029200927)
5
-  (0.1ms) begin transaction
6
-  (0.4ms) CREATE 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) 
7
-  (0.1ms) CREATE INDEX "index_auditable_audits_on_auditable_id_and_auditable_type" ON "auditable_audits" ("auditable_id", "auditable_type")
8
-  (0.1ms) CREATE INDEX "index_auditable_audits_on_user_id_and_user_type" ON "auditable_audits" ("user_id", "user_type")
9
- SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20131029200927"]]
10
-  (1.4ms) commit transaction
11
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
12
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
13
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
14
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
15
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
16
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
17
- Migrating to CreateGeneralModels (20131029211126)
18
-  (0.1ms) begin transaction
19
-  (0.6ms) CREATE 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) 
20
-  (0.1ms) CREATE INDEX "index_general_models_on_user_id" ON "general_models" ("user_id")
21
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20131029211126"]]
22
-  (2.6ms) commit transaction
23
- Migrating to CreateUsers (20131030014901)
24
-  (0.1ms) begin transaction
25
-  (0.4ms) 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
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20131030014901"]]
27
-  (1.6ms) commit transaction
28
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"