hertz 1.0.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +27 -42
- data/Rakefile +5 -3
- data/app/models/hertz/delivery.rb +1 -0
- data/app/models/hertz/notification.rb +2 -0
- data/db/migrate/20160415174901_create_hertz_notifications.rb +1 -1
- data/db/migrate/20160627084018_create_hertz_notification_deliveries.rb +1 -1
- data/db/migrate/20160628084342_rename_notification_deliveries_to_deliveries.rb +1 -1
- data/lib/generators/hertz/install_generator.rb +2 -1
- data/lib/generators/hertz/templates/initializer.rb +1 -0
- data/lib/hertz.rb +1 -0
- data/lib/hertz/engine.rb +1 -0
- data/lib/hertz/notifiable.rb +1 -0
- data/lib/hertz/notification_deliverer.rb +2 -1
- data/lib/hertz/version.rb +2 -1
- data/spec/dummy/config/database.travis.yml +4 -0
- data/spec/factories/hertz/deliveries.rb +3 -2
- data/spec/factories/hertz/notifications.rb +3 -2
- data/spec/factories/users.rb +2 -1
- data/spec/hertz/hertz_spec.rb +2 -1
- data/spec/hertz/notifiable_spec.rb +25 -26
- data/spec/hertz/notification_deliverer_spec.rb +40 -47
- data/spec/models/hertz/notification_spec.rb +67 -57
- data/spec/spec_helper.rb +3 -0
- data/spec/support/factory_bot.rb +5 -0
- metadata +57 -72
- data/app/assets/javascripts/hertz/application.js +0 -13
- data/app/assets/stylesheets/hertz/application.css +0 -15
- data/app/controllers/hertz/application_controller.rb +0 -6
- data/app/helpers/hertz/application_helper.rb +0 -5
- data/app/views/layouts/hertz/application.html.erb +0 -14
- data/spec/dummy/config/database.yml +0 -19
- data/spec/dummy/log/development.log +0 -61
- data/spec/dummy/log/test.log +0 -217
- data/spec/examples.txt +0 -20
- data/spec/models/hertz/delivery_spec.rb +0 -12
- data/spec/support/factory_girl.rb +0 -5
- data/spec/support/shoulda.rb +0 -8
@@ -1,81 +1,91 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
2
|
+
|
3
|
+
RSpec.describe Hertz::Notification do
|
4
|
+
subject { build(:notification) }
|
5
|
+
|
6
|
+
describe '#read?' do
|
7
|
+
it 'returns whether read_at is present' do
|
8
|
+
expect {
|
9
|
+
subject.read_at = Time.zone.now
|
10
|
+
}.to change(subject, :read?).from(false).to(true)
|
12
11
|
end
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
14
|
+
describe '#unread?' do
|
15
|
+
it 'returns whether read_at is nil' do
|
16
|
+
expect {
|
17
|
+
subject.read_at = Time.zone.now
|
18
|
+
}.to change(subject, :unread?).from(true).to(false)
|
20
19
|
end
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
describe '#mark_as_read' do
|
23
|
+
subject { create(:notification) }
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
25
|
+
it 'touches read_at' do
|
26
|
+
expect {
|
27
|
+
subject.mark_as_read
|
28
|
+
}.to change(subject, :read_at).to(
|
29
|
+
an_instance_of(ActiveSupport::TimeWithZone)
|
30
|
+
)
|
32
31
|
end
|
32
|
+
end
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
describe '#mark_as_unread' do
|
35
|
+
subject { create(:notification, :read) }
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
37
|
+
it 'nullifies read_at' do
|
38
|
+
expect {
|
39
|
+
subject.mark_as_unread
|
40
|
+
}.to change(subject, :read_at).to(nil)
|
42
41
|
end
|
42
|
+
end
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
describe '#delivered_with?' do
|
45
|
+
subject { create(:notification) }
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
47
|
+
it 'returns whether it has been delivered with that courier' do
|
48
|
+
expect {
|
49
|
+
create(:delivery, notification: subject, courier: :test)
|
50
|
+
}.to change { subject.delivered_with?(:test) }.from(false).to(true)
|
52
51
|
end
|
52
|
+
end
|
53
53
|
|
54
|
-
|
55
|
-
|
54
|
+
describe '#mark_delivered_with' do
|
55
|
+
subject { create(:notification) }
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
57
|
+
it 'creates a delivery for that courier' do
|
58
|
+
expect {
|
59
|
+
subject.mark_delivered_with(:test)
|
60
|
+
}.to change(subject.deliveries, :count).by(1)
|
62
61
|
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '.read' do
|
65
|
+
before { create(:notification) }
|
63
66
|
|
64
|
-
|
65
|
-
let!(:unread_notification) { create(:notification) }
|
66
|
-
let!(:read_notification) { create(:notification, :read) }
|
67
|
+
let!(:read_notification) { create(:notification, :read) }
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
end
|
69
|
+
it 'returns the unread notifications' do
|
70
|
+
expect(described_class.read).to eq([read_notification])
|
71
71
|
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '.unread' do
|
75
|
+
let!(:unread_notification) { create(:notification) }
|
72
76
|
|
73
|
-
|
74
|
-
expect(Hertz::NotificationDeliverer).to receive(:deliver)
|
75
|
-
.with(subject)
|
76
|
-
.once
|
77
|
+
before { create(:notification, :read) }
|
77
78
|
|
78
|
-
|
79
|
+
it 'returns the unread notifications' do
|
80
|
+
expect(described_class.unread).to eq([unread_notification])
|
79
81
|
end
|
80
82
|
end
|
83
|
+
|
84
|
+
it 'delivers itself upon creation' do
|
85
|
+
expect(Hertz::NotificationDeliverer).to receive(:deliver)
|
86
|
+
.with(subject)
|
87
|
+
.once
|
88
|
+
|
89
|
+
subject.save!
|
90
|
+
end
|
81
91
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -16,6 +16,9 @@
|
|
16
16
|
# users commonly want.
|
17
17
|
#
|
18
18
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
require 'coveralls'
|
20
|
+
Coveralls.wear!
|
21
|
+
|
19
22
|
RSpec.configure do |config|
|
20
23
|
# rspec-expectations config goes here. You can use an alternate
|
21
24
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hertz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Desantis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 6.0.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: coveralls
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: database_cleaner
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
62
|
+
name: factory_bot_rails
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - ">="
|
@@ -73,7 +73,7 @@ dependencies:
|
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
76
|
+
name: faker
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
79
|
- - ">="
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
90
|
+
name: fuubar
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - ">="
|
@@ -101,21 +101,21 @@ dependencies:
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
104
|
+
name: pg
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- - "
|
107
|
+
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
109
|
+
version: '0.21'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- - "
|
114
|
+
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: '0'
|
116
|
+
version: '0.21'
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
|
-
name:
|
118
|
+
name: rspec-rails
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
121
|
- - ">="
|
@@ -129,7 +129,7 @@ dependencies:
|
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
|
-
name:
|
132
|
+
name: rubocop
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
135
|
- - ">="
|
@@ -143,7 +143,7 @@ dependencies:
|
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '0'
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
|
-
name:
|
146
|
+
name: rubocop-rspec
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
149
|
- - ">="
|
@@ -166,13 +166,8 @@ files:
|
|
166
166
|
- MIT-LICENSE
|
167
167
|
- README.md
|
168
168
|
- Rakefile
|
169
|
-
- app/assets/javascripts/hertz/application.js
|
170
|
-
- app/assets/stylesheets/hertz/application.css
|
171
|
-
- app/controllers/hertz/application_controller.rb
|
172
|
-
- app/helpers/hertz/application_helper.rb
|
173
169
|
- app/models/hertz/delivery.rb
|
174
170
|
- app/models/hertz/notification.rb
|
175
|
-
- app/views/layouts/hertz/application.html.erb
|
176
171
|
- config/routes.rb
|
177
172
|
- db/migrate/20160415174901_create_hertz_notifications.rb
|
178
173
|
- db/migrate/20160627084018_create_hertz_notification_deliveries.rb
|
@@ -202,7 +197,7 @@ files:
|
|
202
197
|
- spec/dummy/config/application.rb
|
203
198
|
- spec/dummy/config/boot.rb
|
204
199
|
- spec/dummy/config/database.example.yml
|
205
|
-
- spec/dummy/config/database.yml
|
200
|
+
- spec/dummy/config/database.travis.yml
|
206
201
|
- spec/dummy/config/environment.rb
|
207
202
|
- spec/dummy/config/environments/development.rb
|
208
203
|
- spec/dummy/config/environments/production.rb
|
@@ -226,27 +221,22 @@ files:
|
|
226
221
|
- spec/dummy/db/migrate/20160627084119_create_hertz_notification_deliveries.hertz.rb
|
227
222
|
- spec/dummy/db/migrate/20160628084413_rename_notification_deliveries_to_deliveries.hertz.rb
|
228
223
|
- spec/dummy/db/schema.rb
|
229
|
-
- spec/dummy/log/development.log
|
230
|
-
- spec/dummy/log/test.log
|
231
224
|
- spec/dummy/public/404.html
|
232
225
|
- spec/dummy/public/422.html
|
233
226
|
- spec/dummy/public/500.html
|
234
227
|
- spec/dummy/public/favicon.ico
|
235
|
-
- spec/examples.txt
|
236
228
|
- spec/factories/hertz/deliveries.rb
|
237
229
|
- spec/factories/hertz/notifications.rb
|
238
230
|
- spec/factories/users.rb
|
239
231
|
- spec/hertz/hertz_spec.rb
|
240
232
|
- spec/hertz/notifiable_spec.rb
|
241
233
|
- spec/hertz/notification_deliverer_spec.rb
|
242
|
-
- spec/models/hertz/delivery_spec.rb
|
243
234
|
- spec/models/hertz/notification_spec.rb
|
244
235
|
- spec/rails_helper.rb
|
245
236
|
- spec/spec_helper.rb
|
246
237
|
- spec/support/database_cleaner.rb
|
247
|
-
- spec/support/
|
238
|
+
- spec/support/factory_bot.rb
|
248
239
|
- spec/support/faker.rb
|
249
|
-
- spec/support/shoulda.rb
|
250
240
|
homepage: https://github.com/alessandro1997/hertz
|
251
241
|
licenses:
|
252
242
|
- MIT
|
@@ -267,71 +257,66 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
257
|
version: '0'
|
268
258
|
requirements: []
|
269
259
|
rubyforge_project:
|
270
|
-
rubygems_version: 2.
|
260
|
+
rubygems_version: 2.7.7
|
271
261
|
signing_key:
|
272
262
|
specification_version: 4
|
273
263
|
summary: A Rails engine for in-app notifications.
|
274
264
|
test_files:
|
275
|
-
- spec/
|
276
|
-
- spec/support/database_cleaner.rb
|
277
|
-
- spec/support/faker.rb
|
278
|
-
- spec/support/shoulda.rb
|
279
|
-
- spec/dummy/bin/rake
|
280
|
-
- spec/dummy/bin/bundle
|
281
|
-
- spec/dummy/bin/setup
|
282
|
-
- spec/dummy/bin/rails
|
283
|
-
- spec/dummy/README.rdoc
|
284
|
-
- spec/dummy/log/test.log
|
285
|
-
- spec/dummy/log/development.log
|
286
|
-
- spec/dummy/Rakefile
|
287
|
-
- spec/dummy/app/assets/javascripts/application.js
|
288
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
289
|
-
- spec/dummy/app/helpers/application_helper.rb
|
265
|
+
- spec/spec_helper.rb
|
290
266
|
- spec/dummy/app/models/test_notification.rb
|
291
267
|
- spec/dummy/app/models/user.rb
|
268
|
+
- spec/dummy/app/controllers/application_controller.rb
|
292
269
|
- spec/dummy/app/views/hertz/notification_mailer/test_notification.html.erb
|
293
270
|
- spec/dummy/app/views/layouts/application.html.erb
|
294
|
-
- spec/dummy/app/
|
295
|
-
- spec/dummy/
|
296
|
-
- spec/dummy/
|
271
|
+
- spec/dummy/app/assets/javascripts/application.js
|
272
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
273
|
+
- spec/dummy/app/helpers/application_helper.rb
|
274
|
+
- spec/dummy/bin/rake
|
275
|
+
- spec/dummy/bin/setup
|
276
|
+
- spec/dummy/bin/bundle
|
277
|
+
- spec/dummy/bin/rails
|
297
278
|
- spec/dummy/config/secrets.yml
|
298
|
-
- spec/dummy/config/
|
299
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
300
|
-
- spec/dummy/config/initializers/cookies_serializer.rb
|
301
|
-
- spec/dummy/config/initializers/session_store.rb
|
302
|
-
- spec/dummy/config/initializers/hertz.rb
|
303
|
-
- spec/dummy/config/initializers/assets.rb
|
304
|
-
- spec/dummy/config/initializers/mime_types.rb
|
305
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
306
|
-
- spec/dummy/config/initializers/inflections.rb
|
307
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
308
|
-
- spec/dummy/config/environment.rb
|
279
|
+
- spec/dummy/config/routes.rb
|
309
280
|
- spec/dummy/config/locales/en.yml
|
310
|
-
- spec/dummy/config/
|
281
|
+
- spec/dummy/config/database.example.yml
|
311
282
|
- spec/dummy/config/environments/production.rb
|
283
|
+
- spec/dummy/config/environments/development.rb
|
312
284
|
- spec/dummy/config/environments/test.rb
|
313
|
-
- spec/dummy/config/database.
|
285
|
+
- spec/dummy/config/database.travis.yml
|
286
|
+
- spec/dummy/config/environment.rb
|
287
|
+
- spec/dummy/config/application.rb
|
314
288
|
- spec/dummy/config/boot.rb
|
289
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
290
|
+
- spec/dummy/config/initializers/mime_types.rb
|
291
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
292
|
+
- spec/dummy/config/initializers/session_store.rb
|
293
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
294
|
+
- spec/dummy/config/initializers/assets.rb
|
295
|
+
- spec/dummy/config/initializers/cookies_serializer.rb
|
296
|
+
- spec/dummy/config/initializers/hertz.rb
|
297
|
+
- spec/dummy/config/initializers/inflections.rb
|
298
|
+
- spec/dummy/config.ru
|
299
|
+
- spec/dummy/Rakefile
|
315
300
|
- spec/dummy/public/favicon.ico
|
316
301
|
- spec/dummy/public/422.html
|
317
|
-
- spec/dummy/public/404.html
|
318
302
|
- spec/dummy/public/500.html
|
303
|
+
- spec/dummy/public/404.html
|
304
|
+
- spec/dummy/db/schema.rb
|
319
305
|
- spec/dummy/db/migrate/20160508094342_remove_email_from_users.rb
|
320
|
-
- spec/dummy/db/migrate/20160418122437_add_email_to_users.rb
|
321
|
-
- spec/dummy/db/migrate/20160415175358_create_hertz_notifications.hertz.rb
|
322
306
|
- spec/dummy/db/migrate/20160628084413_rename_notification_deliveries_to_deliveries.hertz.rb
|
307
|
+
- spec/dummy/db/migrate/20160418122437_add_email_to_users.rb
|
323
308
|
- spec/dummy/db/migrate/20160415175837_create_users.rb
|
309
|
+
- spec/dummy/db/migrate/20160415175358_create_hertz_notifications.hertz.rb
|
324
310
|
- spec/dummy/db/migrate/20160627084119_create_hertz_notification_deliveries.hertz.rb
|
325
|
-
- spec/dummy/
|
326
|
-
- spec/
|
327
|
-
- spec/spec_helper.rb
|
328
|
-
- spec/factories/hertz/notifications.rb
|
329
|
-
- spec/factories/hertz/deliveries.rb
|
330
|
-
- spec/factories/users.rb
|
331
|
-
- spec/examples.txt
|
332
|
-
- spec/models/hertz/notification_spec.rb
|
333
|
-
- spec/models/hertz/delivery_spec.rb
|
311
|
+
- spec/dummy/README.rdoc
|
312
|
+
- spec/hertz/notifiable_spec.rb
|
334
313
|
- spec/hertz/notification_deliverer_spec.rb
|
335
314
|
- spec/hertz/hertz_spec.rb
|
336
|
-
- spec/hertz/
|
315
|
+
- spec/models/hertz/notification_spec.rb
|
316
|
+
- spec/support/factory_bot.rb
|
317
|
+
- spec/support/faker.rb
|
318
|
+
- spec/support/database_cleaner.rb
|
319
|
+
- spec/factories/hertz/deliveries.rb
|
320
|
+
- spec/factories/hertz/notifications.rb
|
321
|
+
- spec/factories/users.rb
|
337
322
|
- spec/rails_helper.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
9
|
-
//
|
10
|
-
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
-
// about supported directives.
|
12
|
-
//
|
13
|
-
//= require_tree .
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
-
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
-
* file per style scope.
|
12
|
-
*
|
13
|
-
*= require_tree .
|
14
|
-
*= require_self
|
15
|
-
*/
|