log_book 0.6.3 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile.lock +190 -112
- data/README.md +49 -1
- data/lib/log_book/plugin.rb +1 -0
- data/lib/log_book/utils.rb +3 -2
- data/lib/log_book/version.rb +1 -1
- data/log_book.gemspec +6 -5
- data/test/log_book_test.rb +40 -1
- data/test/plugin_test.rb +7 -1
- data/test/schema.rb +2 -1
- data/test/test_helper.rb +3 -3
- metadata +35 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1474333ffd6c632f4d40befae4fb7584a77667e39b3eacac0837ce274849f661
|
4
|
+
data.tar.gz: d033aec51acca9011ef5774cf65802261e627c74f4a5aacf09345d82e08889f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f1ca47bca5501cd4593d430392948399debd3d44bcd2852fdb46de009584f90a1b9661c122cd839f212d3d224340dd0fa41578aecb171cdde80ab89e496bb13
|
7
|
+
data.tar.gz: c1a403f79e91fe0c082d76efe7729694853456753675628fadd909d7e2c175cb732451a989d8c055758fd36ab8dfeebdbbbdc9fc3f30c94725902c574438b0a4
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,155 +1,233 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
log_book (0.
|
4
|
+
log_book (0.7.1)
|
5
5
|
acts-as-taggable-on (>= 8.0)
|
6
|
-
rails (
|
6
|
+
rails (>= 6.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actioncable (
|
12
|
-
actionpack (=
|
13
|
-
activesupport (=
|
11
|
+
actioncable (7.1.3.2)
|
12
|
+
actionpack (= 7.1.3.2)
|
13
|
+
activesupport (= 7.1.3.2)
|
14
14
|
nio4r (~> 2.0)
|
15
15
|
websocket-driver (>= 0.6.1)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
zeitwerk (~> 2.6)
|
17
|
+
actionmailbox (7.1.3.2)
|
18
|
+
actionpack (= 7.1.3.2)
|
19
|
+
activejob (= 7.1.3.2)
|
20
|
+
activerecord (= 7.1.3.2)
|
21
|
+
activestorage (= 7.1.3.2)
|
22
|
+
activesupport (= 7.1.3.2)
|
22
23
|
mail (>= 2.7.1)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
net-imap
|
25
|
+
net-pop
|
26
|
+
net-smtp
|
27
|
+
actionmailer (7.1.3.2)
|
28
|
+
actionpack (= 7.1.3.2)
|
29
|
+
actionview (= 7.1.3.2)
|
30
|
+
activejob (= 7.1.3.2)
|
31
|
+
activesupport (= 7.1.3.2)
|
28
32
|
mail (~> 2.5, >= 2.5.4)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
net-imap
|
34
|
+
net-pop
|
35
|
+
net-smtp
|
36
|
+
rails-dom-testing (~> 2.2)
|
37
|
+
actionpack (7.1.3.2)
|
38
|
+
actionview (= 7.1.3.2)
|
39
|
+
activesupport (= 7.1.3.2)
|
40
|
+
nokogiri (>= 1.8.5)
|
41
|
+
racc
|
42
|
+
rack (>= 2.2.4)
|
43
|
+
rack-session (>= 1.0.1)
|
34
44
|
rack-test (>= 0.6.3)
|
35
|
-
rails-dom-testing (~> 2.
|
36
|
-
rails-html-sanitizer (~> 1.
|
37
|
-
actiontext (
|
38
|
-
actionpack (=
|
39
|
-
activerecord (=
|
40
|
-
activestorage (=
|
41
|
-
activesupport (=
|
45
|
+
rails-dom-testing (~> 2.2)
|
46
|
+
rails-html-sanitizer (~> 1.6)
|
47
|
+
actiontext (7.1.3.2)
|
48
|
+
actionpack (= 7.1.3.2)
|
49
|
+
activerecord (= 7.1.3.2)
|
50
|
+
activestorage (= 7.1.3.2)
|
51
|
+
activesupport (= 7.1.3.2)
|
52
|
+
globalid (>= 0.6.0)
|
42
53
|
nokogiri (>= 1.8.5)
|
43
|
-
actionview (
|
44
|
-
activesupport (=
|
54
|
+
actionview (7.1.3.2)
|
55
|
+
activesupport (= 7.1.3.2)
|
45
56
|
builder (~> 3.1)
|
46
|
-
erubi (~> 1.
|
47
|
-
rails-dom-testing (~> 2.
|
48
|
-
rails-html-sanitizer (~> 1.
|
49
|
-
activejob (
|
50
|
-
activesupport (=
|
57
|
+
erubi (~> 1.11)
|
58
|
+
rails-dom-testing (~> 2.2)
|
59
|
+
rails-html-sanitizer (~> 1.6)
|
60
|
+
activejob (7.1.3.2)
|
61
|
+
activesupport (= 7.1.3.2)
|
51
62
|
globalid (>= 0.3.6)
|
52
|
-
activemodel (
|
53
|
-
activesupport (=
|
54
|
-
activerecord (
|
55
|
-
activemodel (=
|
56
|
-
activesupport (=
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
activesupport (
|
63
|
+
activemodel (7.1.3.2)
|
64
|
+
activesupport (= 7.1.3.2)
|
65
|
+
activerecord (7.1.3.2)
|
66
|
+
activemodel (= 7.1.3.2)
|
67
|
+
activesupport (= 7.1.3.2)
|
68
|
+
timeout (>= 0.4.0)
|
69
|
+
activestorage (7.1.3.2)
|
70
|
+
actionpack (= 7.1.3.2)
|
71
|
+
activejob (= 7.1.3.2)
|
72
|
+
activerecord (= 7.1.3.2)
|
73
|
+
activesupport (= 7.1.3.2)
|
74
|
+
marcel (~> 1.0)
|
75
|
+
activesupport (7.1.3.2)
|
76
|
+
base64
|
77
|
+
bigdecimal
|
65
78
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
79
|
+
connection_pool (>= 2.2.5)
|
80
|
+
drb
|
66
81
|
i18n (>= 1.6, < 2)
|
67
82
|
minitest (>= 5.1)
|
83
|
+
mutex_m
|
68
84
|
tzinfo (~> 2.0)
|
69
|
-
|
70
|
-
|
71
|
-
activerecord (>= 5.0, < 6.2)
|
85
|
+
acts-as-taggable-on (10.0.0)
|
86
|
+
activerecord (>= 6.1, < 7.2)
|
72
87
|
assert_difference (1.0.0)
|
73
88
|
activesupport (>= 3.0.0)
|
89
|
+
base64 (0.2.0)
|
90
|
+
bigdecimal (3.1.7)
|
74
91
|
builder (3.2.4)
|
75
|
-
concurrent-ruby (1.
|
92
|
+
concurrent-ruby (1.2.3)
|
93
|
+
connection_pool (2.4.1)
|
76
94
|
crass (1.0.6)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
95
|
+
date (3.3.4)
|
96
|
+
drb (2.2.1)
|
97
|
+
erubi (1.12.0)
|
98
|
+
globalid (1.2.1)
|
99
|
+
activesupport (>= 6.1)
|
100
|
+
i18n (1.14.4)
|
81
101
|
concurrent-ruby (~> 1.0)
|
82
|
-
|
102
|
+
io-console (0.7.2)
|
103
|
+
irb (1.12.0)
|
104
|
+
rdoc
|
105
|
+
reline (>= 0.4.2)
|
106
|
+
loofah (2.22.0)
|
83
107
|
crass (~> 1.0.2)
|
84
|
-
nokogiri (>= 1.
|
85
|
-
mail (2.
|
108
|
+
nokogiri (>= 1.12.0)
|
109
|
+
mail (2.8.1)
|
86
110
|
mini_mime (>= 0.1.1)
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
111
|
+
net-imap
|
112
|
+
net-pop
|
113
|
+
net-smtp
|
114
|
+
marcel (1.0.4)
|
115
|
+
mini_mime (1.1.5)
|
116
|
+
minitest (5.22.3)
|
117
|
+
mocha (2.2.0)
|
118
|
+
ruby2_keywords (>= 0.0.5)
|
119
|
+
mutex_m (0.2.0)
|
120
|
+
net-imap (0.4.10)
|
121
|
+
date
|
122
|
+
net-protocol
|
123
|
+
net-pop (0.1.2)
|
124
|
+
net-protocol
|
125
|
+
net-protocol (0.2.2)
|
126
|
+
timeout
|
127
|
+
net-smtp (0.5.0)
|
128
|
+
net-protocol
|
129
|
+
nio4r (2.7.1)
|
130
|
+
nokogiri (1.16.4-aarch64-linux)
|
131
|
+
racc (~> 1.4)
|
132
|
+
nokogiri (1.16.4-arm-linux)
|
133
|
+
racc (~> 1.4)
|
134
|
+
nokogiri (1.16.4-arm64-darwin)
|
135
|
+
racc (~> 1.4)
|
136
|
+
nokogiri (1.16.4-x86-linux)
|
94
137
|
racc (~> 1.4)
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
138
|
+
nokogiri (1.16.4-x86_64-darwin)
|
139
|
+
racc (~> 1.4)
|
140
|
+
nokogiri (1.16.4-x86_64-linux)
|
141
|
+
racc (~> 1.4)
|
142
|
+
psych (5.1.2)
|
143
|
+
stringio
|
144
|
+
racc (1.7.3)
|
145
|
+
rack (3.0.10)
|
146
|
+
rack-session (2.0.0)
|
147
|
+
rack (>= 3.0.0)
|
148
|
+
rack-test (2.1.0)
|
149
|
+
rack (>= 1.3)
|
150
|
+
rackup (2.1.0)
|
151
|
+
rack (>= 3)
|
152
|
+
webrick (~> 1.8)
|
153
|
+
rails (7.1.3.2)
|
154
|
+
actioncable (= 7.1.3.2)
|
155
|
+
actionmailbox (= 7.1.3.2)
|
156
|
+
actionmailer (= 7.1.3.2)
|
157
|
+
actionpack (= 7.1.3.2)
|
158
|
+
actiontext (= 7.1.3.2)
|
159
|
+
actionview (= 7.1.3.2)
|
160
|
+
activejob (= 7.1.3.2)
|
161
|
+
activemodel (= 7.1.3.2)
|
162
|
+
activerecord (= 7.1.3.2)
|
163
|
+
activestorage (= 7.1.3.2)
|
164
|
+
activesupport (= 7.1.3.2)
|
111
165
|
bundler (>= 1.15.0)
|
112
|
-
railties (=
|
113
|
-
|
114
|
-
|
115
|
-
|
166
|
+
railties (= 7.1.3.2)
|
167
|
+
rails-dom-testing (2.2.0)
|
168
|
+
activesupport (>= 5.0.0)
|
169
|
+
minitest
|
116
170
|
nokogiri (>= 1.6)
|
117
|
-
rails-html-sanitizer (1.
|
118
|
-
loofah (~> 2.
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
171
|
+
rails-html-sanitizer (1.6.0)
|
172
|
+
loofah (~> 2.21)
|
173
|
+
nokogiri (~> 1.14)
|
174
|
+
railties (7.1.3.2)
|
175
|
+
actionpack (= 7.1.3.2)
|
176
|
+
activesupport (= 7.1.3.2)
|
177
|
+
irb
|
178
|
+
rackup (>= 1.0.0)
|
179
|
+
rake (>= 12.2)
|
180
|
+
thor (~> 1.0, >= 1.2.2)
|
181
|
+
zeitwerk (~> 2.6)
|
182
|
+
rake (13.2.1)
|
183
|
+
rdoc (6.6.3.1)
|
184
|
+
psych (>= 4.0.0)
|
185
|
+
reline (0.5.2)
|
186
|
+
io-console (~> 0.5)
|
187
|
+
ruby2_keywords (0.0.5)
|
188
|
+
sqlite3 (1.7.3-aarch64-linux)
|
189
|
+
sqlite3 (1.7.3-arm-linux)
|
190
|
+
sqlite3 (1.7.3-arm64-darwin)
|
191
|
+
sqlite3 (1.7.3-x86-linux)
|
192
|
+
sqlite3 (1.7.3-x86_64-darwin)
|
193
|
+
sqlite3 (1.7.3-x86_64-linux)
|
194
|
+
stringio (3.1.0)
|
195
|
+
thor (1.3.1)
|
196
|
+
timecop (0.9.8)
|
197
|
+
timeout (0.4.1)
|
198
|
+
tzinfo (2.0.6)
|
136
199
|
concurrent-ruby (~> 1.0)
|
137
|
-
|
200
|
+
webrick (1.8.1)
|
201
|
+
websocket-driver (0.7.6)
|
138
202
|
websocket-extensions (>= 0.1.0)
|
139
203
|
websocket-extensions (0.1.5)
|
140
|
-
zeitwerk (2.
|
204
|
+
zeitwerk (2.6.13)
|
141
205
|
|
142
206
|
PLATFORMS
|
143
|
-
|
207
|
+
aarch64-linux
|
208
|
+
aarch64-linux-gnu
|
209
|
+
aarch64-linux-musl
|
210
|
+
arm-linux
|
211
|
+
arm-linux-gnu
|
212
|
+
arm-linux-musl
|
213
|
+
arm64-darwin
|
214
|
+
x86-linux
|
215
|
+
x86-linux-gnu
|
216
|
+
x86-linux-musl
|
217
|
+
x86_64-darwin
|
218
|
+
x86_64-linux
|
219
|
+
x86_64-linux-gnu
|
220
|
+
x86_64-linux-musl
|
144
221
|
|
145
222
|
DEPENDENCIES
|
146
|
-
assert_difference (
|
223
|
+
assert_difference (>= 1.0)
|
147
224
|
bundler (>= 2.0)
|
148
225
|
log_book!
|
149
226
|
minitest (>= 5.1)
|
150
|
-
mocha (~>
|
227
|
+
mocha (~> 2.2)
|
151
228
|
rake (>= 0.13)
|
152
|
-
sqlite3 (~> 1.
|
229
|
+
sqlite3 (~> 1.4)
|
230
|
+
timecop
|
153
231
|
|
154
232
|
BUNDLED WITH
|
155
|
-
2.
|
233
|
+
2.5.7
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# LogBook
|
2
2
|
|
3
|
-
|
3
|
+
Ruby on Rails, Automatically keeping record of all Model Changes
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -83,6 +83,10 @@ Check this example project to see how LogBook is integrated:
|
|
83
83
|
|
84
84
|
- [Skeleton](https://github.com/fguillen/Skeleton)
|
85
85
|
|
86
|
+
Or this commit in a more modern Rails project:
|
87
|
+
|
88
|
+
- [RailsSkeleton](https://github.com/fguillen/RailsSkeleton/commit/4c16c6402254bf4c44b7589b404fc22c746bae15)
|
89
|
+
|
86
90
|
## TODO
|
87
91
|
|
88
92
|
Use block configuration instead of `model.log_book_historian` do something like:
|
@@ -95,3 +99,47 @@ Use block configuration instead of `model.log_book_historian` do something like:
|
|
95
99
|
## Sate of the art
|
96
100
|
|
97
101
|
Beta version but already used in production environments
|
102
|
+
|
103
|
+
## In case your IDs are strings
|
104
|
+
|
105
|
+
Change the migration with this one in your project:
|
106
|
+
|
107
|
+
```
|
108
|
+
class CreateLogBookEventsUuidsSupport < ActiveRecord::Migration[4.2]
|
109
|
+
def self.up
|
110
|
+
create_table :log_book_events do |t|
|
111
|
+
t.string :historian_id
|
112
|
+
t.string :historian_type
|
113
|
+
t.string :historizable_id
|
114
|
+
t.string :historizable_type
|
115
|
+
t.text :differences, :limit => 16777215 # mediumtext
|
116
|
+
|
117
|
+
t.timestamps :null => false
|
118
|
+
end
|
119
|
+
|
120
|
+
add_index :log_book_events, [:historizable_id, :historizable_type, :created_at], :name => "index_log_book_events_on_historizable_and_created_at"
|
121
|
+
add_index :log_book_events, [:created_at]
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.down
|
125
|
+
drop_table :log_book_events
|
126
|
+
end
|
127
|
+
end
|
128
|
+
```
|
129
|
+
|
130
|
+
## Development
|
131
|
+
|
132
|
+
### Running test
|
133
|
+
|
134
|
+
```
|
135
|
+
rake test
|
136
|
+
```
|
137
|
+
|
138
|
+
### Bump new version
|
139
|
+
|
140
|
+
Update: `lib/log_book/version.rb`
|
141
|
+
|
142
|
+
```
|
143
|
+
git tag -a v{version} -m "Changelog..."
|
144
|
+
git push origin v{version}
|
145
|
+
```
|
data/lib/log_book/plugin.rb
CHANGED
@@ -8,6 +8,7 @@ module LogBook::Plugin
|
|
8
8
|
def log_book(opts = {})
|
9
9
|
after_create :log_book_event_on_create
|
10
10
|
after_update :log_book_event_on_update
|
11
|
+
after_touch :log_book_event_on_update
|
11
12
|
before_destroy :log_book_event_on_destroy
|
12
13
|
|
13
14
|
has_many :log_book_events, :class_name => "LogBook::Event", :as => :historizable, :dependent => (opts[:dependent] || :nullify)
|
data/lib/log_book/utils.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
puts "Loading LogBook::Utils"
|
1
2
|
module LogBook::Utils
|
2
3
|
def self.pretty_changes(model)
|
3
4
|
# TODO: this line of code is duplicated
|
@@ -12,8 +13,8 @@ module LogBook::Utils
|
|
12
13
|
old_value = v[0]
|
13
14
|
new_value = v[1]
|
14
15
|
|
15
|
-
old_value = old_value.
|
16
|
-
new_value = new_value.
|
16
|
+
old_value = old_value.utc.strftime("%Y-%m-%d %H:%M:%S") if old_value.is_a? Time
|
17
|
+
new_value = new_value.utc.strftime("%Y-%m-%d %H:%M:%S") if new_value.is_a? Time
|
17
18
|
|
18
19
|
{
|
19
20
|
"key" => k,
|
data/lib/log_book/version.rb
CHANGED
data/log_book.gemspec
CHANGED
@@ -18,13 +18,14 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "rails", "
|
21
|
+
spec.add_runtime_dependency "rails", ">= 6.0"
|
22
22
|
spec.add_runtime_dependency "acts-as-taggable-on", ">= 8.0"
|
23
23
|
|
24
|
+
spec.add_development_dependency "assert_difference", ">= 1.0"
|
24
25
|
spec.add_development_dependency "bundler", ">= 2.0"
|
25
|
-
spec.add_development_dependency "rake", ">= 0.13"
|
26
|
-
spec.add_development_dependency "mocha", "~> 1.13"
|
27
|
-
spec.add_development_dependency "sqlite3", "~> 1.0"
|
28
|
-
spec.add_development_dependency "assert_difference", "~> 1.0"
|
29
26
|
spec.add_development_dependency "minitest", ">= 5.1"
|
27
|
+
spec.add_development_dependency "mocha", "~> 2.2"
|
28
|
+
spec.add_development_dependency "rake", ">= 0.13"
|
29
|
+
spec.add_development_dependency "sqlite3", "~> 1.4"
|
30
|
+
spec.add_development_dependency "timecop"
|
30
31
|
end
|
data/test/log_book_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative "test_helper"
|
2
2
|
|
3
|
-
class LogBookTest <
|
3
|
+
class LogBookTest < Minitest::Test
|
4
4
|
def setup
|
5
5
|
LogBook::Event.destroy_all
|
6
6
|
User.destroy_all
|
@@ -66,6 +66,22 @@ class LogBookTest < MiniTest::Test
|
|
66
66
|
@item.update!(:title => "Other Title")
|
67
67
|
end
|
68
68
|
|
69
|
+
def test_updated_datetime_field
|
70
|
+
item = Item.create(:open_at => "2024-01-02 03:04:05")
|
71
|
+
|
72
|
+
differences = [
|
73
|
+
{
|
74
|
+
"key" => "open_at",
|
75
|
+
"before" => "2024-01-02 03:04:05",
|
76
|
+
"after" => "2024-01-03 03:04:05"
|
77
|
+
}
|
78
|
+
]
|
79
|
+
|
80
|
+
LogBook.expects(:event).with(nil, item, differences, LogBook::OPERATIONS[:update])
|
81
|
+
|
82
|
+
item.update!(:open_at => "2024-01-03 03:04:05")
|
83
|
+
end
|
84
|
+
|
69
85
|
def test_updated_when_muted
|
70
86
|
LogBook.expects(:event).never
|
71
87
|
|
@@ -89,6 +105,29 @@ class LogBookTest < MiniTest::Test
|
|
89
105
|
item_with_opts.update!(:title => "Other Title", :my_counter => 10)
|
90
106
|
end
|
91
107
|
|
108
|
+
def test_touch
|
109
|
+
differences = [
|
110
|
+
{
|
111
|
+
"key" => "open_at",
|
112
|
+
"before" => nil,
|
113
|
+
"after" => "2024-04-01 10:11:12"
|
114
|
+
}
|
115
|
+
]
|
116
|
+
|
117
|
+
LogBook.expects(:event).with(@user, @item, differences, LogBook::OPERATIONS[:update])
|
118
|
+
|
119
|
+
Timecop.freeze("2024-04-01 10:11:12 UTC") do
|
120
|
+
@item.touch(:open_at)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_touch_when_muted
|
125
|
+
LogBook.expects(:event).never
|
126
|
+
|
127
|
+
@item.log_book_mute = true
|
128
|
+
@item.touch(:open_at)
|
129
|
+
end
|
130
|
+
|
92
131
|
def test_item_destroyed
|
93
132
|
LogBook.expects(:event).with(@user, @item, nil, LogBook::OPERATIONS[:destroy])
|
94
133
|
|
data/test/plugin_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative "test_helper"
|
2
2
|
|
3
|
-
class PluginTest <
|
3
|
+
class PluginTest < Minitest::Test
|
4
4
|
def setup
|
5
5
|
LogBook::Event.destroy_all
|
6
6
|
User.destroy_all
|
@@ -27,4 +27,10 @@ class PluginTest < MiniTest::Test
|
|
27
27
|
LogBook.expects(:destroyed).with(@user, @item)
|
28
28
|
@item.destroy
|
29
29
|
end
|
30
|
+
|
31
|
+
def test_event_on_touch
|
32
|
+
@item.log_book_historian = @user
|
33
|
+
LogBook.expects(:updated).with(@user, @item)
|
34
|
+
@item.touch(:open_at)
|
35
|
+
end
|
30
36
|
end
|
data/test/schema.rb
CHANGED
@@ -6,6 +6,7 @@ ActiveRecord::Schema.define :version => 0 do
|
|
6
6
|
create_table :items, :force => true do |t|
|
7
7
|
t.string :title
|
8
8
|
t.integer :my_counter
|
9
|
+
t.datetime :open_at
|
9
10
|
end
|
10
11
|
|
11
12
|
# acts-as-taggable-on
|
@@ -29,4 +30,4 @@ ActiveRecord::Schema.define :version => 0 do
|
|
29
30
|
add_index 'taggings',
|
30
31
|
['tag_id', 'taggable_id', 'taggable_type', 'context', 'tagger_id', 'tagger_type'],
|
31
32
|
unique: true, name: 'taggings_idx'
|
32
|
-
end
|
33
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -6,7 +6,8 @@ require "acts-as-taggable-on"
|
|
6
6
|
|
7
7
|
# require "minitest/unit"
|
8
8
|
require "minitest/autorun"
|
9
|
-
require "mocha/
|
9
|
+
require "mocha/minitest"
|
10
|
+
require "timecop"
|
10
11
|
|
11
12
|
require_relative "../lib/log_book"
|
12
13
|
|
@@ -25,8 +26,7 @@ CreateLogBookEvents.up
|
|
25
26
|
load("#{File.dirname(__FILE__)}/schema.rb")
|
26
27
|
load("#{File.dirname(__FILE__)}/models.rb")
|
27
28
|
|
28
|
-
class
|
29
|
+
class Minitest::Test
|
29
30
|
include AssertDifference
|
30
31
|
FIXTURES = File.expand_path("#{File.dirname(__FILE__)}/fixtures")
|
31
32
|
end
|
32
|
-
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log_book
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernando Guillen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '6.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '8.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: assert_difference
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,75 +67,75 @@ dependencies:
|
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '2.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: minitest
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
75
|
+
version: '5.1'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '5.1'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: mocha
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
89
|
+
version: '2.2'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
96
|
+
version: '2.2'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- - "
|
101
|
+
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
103
|
+
version: '0.13'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- - "
|
108
|
+
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
110
|
+
version: '0.13'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
112
|
+
name: sqlite3
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1.
|
117
|
+
version: '1.4'
|
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.
|
124
|
+
version: '1.4'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
126
|
+
name: timecop
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - ">="
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
131
|
+
version: '0'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - ">="
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
138
|
+
version: '0'
|
125
139
|
description: Storing an events log book
|
126
140
|
email:
|
127
141
|
- fguillen.mail@gmail.com
|
@@ -169,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
183
|
- !ruby/object:Gem::Version
|
170
184
|
version: '0'
|
171
185
|
requirements: []
|
172
|
-
rubygems_version: 3.
|
186
|
+
rubygems_version: 3.5.7
|
173
187
|
signing_key:
|
174
188
|
specification_version: 4
|
175
189
|
summary: Storing an events log book
|