user_notifier 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/Rakefile +0 -2
- data/app/mailers/user_notifier/base_mailer.rb +26 -0
- data/app/models/user_notifier/base.rb +32 -0
- data/app/workers/user_notifier/email_worker.rb +23 -0
- data/lib/generators/user_notifier/install/USAGE +2 -0
- data/lib/generators/user_notifier/install/install_generator.rb +11 -0
- data/lib/generators/user_notifier/install/templates/user_notifier.rb +22 -0
- data/lib/user_notifier.rb +7 -0
- data/lib/user_notifier/configuration.rb +38 -0
- data/lib/user_notifier/models/has_notifications.rb +43 -0
- data/lib/user_notifier/version.rb +1 -1
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20140625163719_create_users.rb +10 -0
- data/spec/dummy/db/migrate/20140625183616_create_user_notifications.rb +12 -0
- data/spec/dummy/db/schema.rb +32 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +33 -0
- data/spec/dummy/log/test.log +737 -0
- data/spec/lib/user_notifier/configuration_spec.rb +26 -0
- data/spec/models/user_notifier/base_spec.rb +55 -0
- data/spec/spec_helper.rb +37 -0
- metadata +126 -54
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe UserNotifier::Configuration do
|
4
|
+
before do
|
5
|
+
UserNotifier.reset
|
6
|
+
end
|
7
|
+
|
8
|
+
UserNotifier::Configuration::VALID_CONFIG_KEYS.each do |key|
|
9
|
+
describe ".#{key}" do
|
10
|
+
it 'should return the default value' do
|
11
|
+
expect(UserNotifier.send(key)).to eq UserNotifier::Configuration.const_get("DEFAULT_#{key.upcase}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.configure' do
|
17
|
+
UserNotifier::Configuration::VALID_CONFIG_KEYS.each do |key|
|
18
|
+
it "should set the #{key}" do
|
19
|
+
UserNotifier.configure do |config|
|
20
|
+
config.send("#{key}=", key)
|
21
|
+
expect(UserNotifier.send(key)).to eq key
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe UserNotifier::Base do
|
4
|
+
let(:user){ User.create email: 'foo@bar.com' }
|
5
|
+
let(:notification){ UserNotification.notify('test', user) }
|
6
|
+
before{ user }
|
7
|
+
|
8
|
+
describe "associations" do
|
9
|
+
subject{ user }
|
10
|
+
it{ should have_many :notifications }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".notify" do
|
14
|
+
subject{ notification }
|
15
|
+
|
16
|
+
it "should create notification in the database" do
|
17
|
+
subject
|
18
|
+
expect(UserNotification.last).to be_present
|
19
|
+
end
|
20
|
+
|
21
|
+
its(:template_name){ should eq 'test' }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#deliver" do
|
25
|
+
context "when sent_at is present" do
|
26
|
+
before do
|
27
|
+
notification.sent_at = Time.now
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should not call deliver!" do
|
31
|
+
expect(notification).to_not receive(:deliver!)
|
32
|
+
notification.deliver
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when sent_at is nil" do
|
37
|
+
before do
|
38
|
+
notification.sent_at = nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should call deliver!" do
|
42
|
+
expect(notification).to receive(:deliver!)
|
43
|
+
notification.deliver
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#deliver!" do
|
49
|
+
before do
|
50
|
+
notification.deliver!
|
51
|
+
end
|
52
|
+
subject{ notification }
|
53
|
+
its(:sent_at){ should be_present }
|
54
|
+
end
|
55
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
5
|
+
|
6
|
+
require 'rspec/rails'
|
7
|
+
require 'rspec/its'
|
8
|
+
require 'shoulda/matchers'
|
9
|
+
require 'sidekiq/testing'
|
10
|
+
|
11
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
12
|
+
# in spec/support/ and its subdirectories.
|
13
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.use_transactional_examples = true
|
17
|
+
|
18
|
+
config.before(:each) do
|
19
|
+
ActionMailer::Base.deliveries.clear
|
20
|
+
end
|
21
|
+
|
22
|
+
# If true, the base class of anonymous controllers will be inferred
|
23
|
+
# automatically. This will be the default behavior in future versions of
|
24
|
+
# rspec-rails.
|
25
|
+
config.infer_base_class_for_anonymous_controllers = false
|
26
|
+
|
27
|
+
# Run specs in random order to surface order dependencies. If you find an
|
28
|
+
# order dependency and want to debug it, you can fix the order by providing
|
29
|
+
# the seed, which is printed after each run.
|
30
|
+
# --seed 1234
|
31
|
+
config.order = "random"
|
32
|
+
|
33
|
+
config.expect_with :rspec do |c|
|
34
|
+
c.syntax = :expect
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
metadata
CHANGED
@@ -1,55 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: user_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diogo Biazus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-07-02 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: 4.0.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: 4.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sidekiq
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rspec-rails
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-its
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
32
60
|
- !ruby/object:Gem::Version
|
33
61
|
version: '0'
|
34
62
|
type: :development
|
35
63
|
prerelease: false
|
36
64
|
version_requirements: !ruby/object:Gem::Requirement
|
37
65
|
requirements:
|
38
|
-
- -
|
66
|
+
- - ">="
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: sqlite3
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
|
-
- -
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: shoulda-matchers
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
46
88
|
- !ruby/object:Gem::Version
|
47
89
|
version: '0'
|
48
90
|
type: :development
|
49
91
|
prerelease: false
|
50
92
|
version_requirements: !ruby/object:Gem::Requirement
|
51
93
|
requirements:
|
52
|
-
- -
|
94
|
+
- - ">="
|
53
95
|
- !ruby/object:Gem::Version
|
54
96
|
version: '0'
|
55
97
|
description: ''
|
@@ -59,45 +101,64 @@ executables: []
|
|
59
101
|
extensions: []
|
60
102
|
extra_rdoc_files: []
|
61
103
|
files:
|
104
|
+
- MIT-LICENSE
|
105
|
+
- README.rdoc
|
106
|
+
- Rakefile
|
107
|
+
- app/mailers/user_notifier/base_mailer.rb
|
108
|
+
- app/models/user_notifier/base.rb
|
109
|
+
- app/workers/user_notifier/email_worker.rb
|
62
110
|
- config/routes.rb
|
63
|
-
- lib/user_notifier
|
111
|
+
- lib/generators/user_notifier/install/USAGE
|
112
|
+
- lib/generators/user_notifier/install/install_generator.rb
|
113
|
+
- lib/generators/user_notifier/install/templates/user_notifier.rb
|
64
114
|
- lib/tasks/user_notifier_tasks.rake
|
65
|
-
- lib/user_notifier
|
115
|
+
- lib/user_notifier.rb
|
116
|
+
- lib/user_notifier/configuration.rb
|
66
117
|
- lib/user_notifier/engine.rb
|
67
|
-
-
|
68
|
-
-
|
69
|
-
- README.rdoc
|
118
|
+
- lib/user_notifier/models/has_notifications.rb
|
119
|
+
- lib/user_notifier/version.rb
|
120
|
+
- spec/dummy/README.rdoc
|
121
|
+
- spec/dummy/Rakefile
|
122
|
+
- spec/dummy/app/assets/javascripts/application.js
|
123
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
124
|
+
- spec/dummy/app/controllers/application_controller.rb
|
125
|
+
- spec/dummy/app/helpers/application_helper.rb
|
126
|
+
- spec/dummy/app/models/user.rb
|
127
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
70
128
|
- spec/dummy/bin/bundle
|
71
129
|
- spec/dummy/bin/rails
|
72
130
|
- spec/dummy/bin/rake
|
73
131
|
- spec/dummy/config.ru
|
74
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
75
|
-
- spec/dummy/app/helpers/application_helper.rb
|
76
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
77
|
-
- spec/dummy/app/assets/javascripts/application.js
|
78
|
-
- spec/dummy/app/controllers/application_controller.rb
|
79
|
-
- spec/dummy/Rakefile
|
80
|
-
- spec/dummy/README.rdoc
|
81
|
-
- spec/dummy/config/initializers/mime_types.rb
|
82
|
-
- spec/dummy/config/initializers/inflections.rb
|
83
|
-
- spec/dummy/config/initializers/session_store.rb
|
84
|
-
- spec/dummy/config/initializers/secret_token.rb
|
85
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
86
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
87
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
88
132
|
- spec/dummy/config/application.rb
|
133
|
+
- spec/dummy/config/boot.rb
|
134
|
+
- spec/dummy/config/database.yml
|
89
135
|
- spec/dummy/config/environment.rb
|
90
136
|
- spec/dummy/config/environments/development.rb
|
91
|
-
- spec/dummy/config/environments/test.rb
|
92
137
|
- spec/dummy/config/environments/production.rb
|
93
|
-
- spec/dummy/config/
|
138
|
+
- spec/dummy/config/environments/test.rb
|
139
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
140
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
141
|
+
- spec/dummy/config/initializers/inflections.rb
|
142
|
+
- spec/dummy/config/initializers/mime_types.rb
|
143
|
+
- spec/dummy/config/initializers/secret_token.rb
|
144
|
+
- spec/dummy/config/initializers/session_store.rb
|
145
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
94
146
|
- spec/dummy/config/locales/en.yml
|
95
|
-
- spec/dummy/config/
|
96
|
-
- spec/dummy/
|
97
|
-
- spec/dummy/
|
147
|
+
- spec/dummy/config/routes.rb
|
148
|
+
- spec/dummy/db/development.sqlite3
|
149
|
+
- spec/dummy/db/migrate/20140625163719_create_users.rb
|
150
|
+
- spec/dummy/db/migrate/20140625183616_create_user_notifications.rb
|
151
|
+
- spec/dummy/db/schema.rb
|
152
|
+
- spec/dummy/db/test.sqlite3
|
153
|
+
- spec/dummy/log/development.log
|
154
|
+
- spec/dummy/log/test.log
|
98
155
|
- spec/dummy/public/404.html
|
99
|
-
- spec/dummy/public/
|
156
|
+
- spec/dummy/public/422.html
|
100
157
|
- spec/dummy/public/500.html
|
158
|
+
- spec/dummy/public/favicon.ico
|
159
|
+
- spec/lib/user_notifier/configuration_spec.rb
|
160
|
+
- spec/models/user_notifier/base_spec.rb
|
161
|
+
- spec/spec_helper.rb
|
101
162
|
homepage: https://github.com/diogob/user_notifier
|
102
163
|
licenses: []
|
103
164
|
metadata: {}
|
@@ -107,50 +168,61 @@ require_paths:
|
|
107
168
|
- lib
|
108
169
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
170
|
requirements:
|
110
|
-
- -
|
171
|
+
- - ">="
|
111
172
|
- !ruby/object:Gem::Version
|
112
173
|
version: '0'
|
113
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
175
|
requirements:
|
115
|
-
- -
|
176
|
+
- - ">="
|
116
177
|
- !ruby/object:Gem::Version
|
117
178
|
version: '0'
|
118
179
|
requirements: []
|
119
180
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
181
|
+
rubygems_version: 2.2.2
|
121
182
|
signing_key:
|
122
183
|
specification_version: 4
|
123
184
|
summary: Simple pattern for keeping track of messages sent to users based on model
|
124
185
|
events with different templates.
|
125
186
|
test_files:
|
126
|
-
- spec/
|
127
|
-
- spec/
|
128
|
-
- spec/dummy/
|
187
|
+
- spec/models/user_notifier/base_spec.rb
|
188
|
+
- spec/spec_helper.rb
|
189
|
+
- spec/dummy/log/test.log
|
190
|
+
- spec/dummy/log/development.log
|
129
191
|
- spec/dummy/config.ru
|
192
|
+
- spec/dummy/app/models/user.rb
|
130
193
|
- spec/dummy/app/views/layouts/application.html.erb
|
194
|
+
- spec/dummy/app/controllers/application_controller.rb
|
131
195
|
- spec/dummy/app/helpers/application_helper.rb
|
132
196
|
- spec/dummy/app/assets/stylesheets/application.css
|
133
197
|
- spec/dummy/app/assets/javascripts/application.js
|
134
|
-
- spec/dummy/app/controllers/application_controller.rb
|
135
|
-
- spec/dummy/Rakefile
|
136
|
-
- spec/dummy/README.rdoc
|
137
|
-
- spec/dummy/config/initializers/mime_types.rb
|
138
|
-
- spec/dummy/config/initializers/inflections.rb
|
139
|
-
- spec/dummy/config/initializers/session_store.rb
|
140
|
-
- spec/dummy/config/initializers/secret_token.rb
|
141
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
142
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
143
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
144
198
|
- spec/dummy/config/application.rb
|
199
|
+
- spec/dummy/config/locales/en.yml
|
145
200
|
- spec/dummy/config/environment.rb
|
146
|
-
- spec/dummy/config/environments/development.rb
|
147
|
-
- spec/dummy/config/environments/test.rb
|
148
201
|
- spec/dummy/config/environments/production.rb
|
202
|
+
- spec/dummy/config/environments/test.rb
|
203
|
+
- spec/dummy/config/environments/development.rb
|
149
204
|
- spec/dummy/config/routes.rb
|
150
|
-
- spec/dummy/config/locales/en.yml
|
151
205
|
- spec/dummy/config/database.yml
|
152
206
|
- spec/dummy/config/boot.rb
|
153
|
-
- spec/dummy/
|
207
|
+
- spec/dummy/config/initializers/session_store.rb
|
208
|
+
- spec/dummy/config/initializers/secret_token.rb
|
209
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
210
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
211
|
+
- spec/dummy/config/initializers/mime_types.rb
|
212
|
+
- spec/dummy/config/initializers/inflections.rb
|
213
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
154
214
|
- spec/dummy/public/404.html
|
155
|
-
- spec/dummy/public/favicon.ico
|
156
215
|
- spec/dummy/public/500.html
|
216
|
+
- spec/dummy/public/favicon.ico
|
217
|
+
- spec/dummy/public/422.html
|
218
|
+
- spec/dummy/bin/rails
|
219
|
+
- spec/dummy/bin/bundle
|
220
|
+
- spec/dummy/bin/rake
|
221
|
+
- spec/dummy/db/development.sqlite3
|
222
|
+
- spec/dummy/db/schema.rb
|
223
|
+
- spec/dummy/db/migrate/20140625183616_create_user_notifications.rb
|
224
|
+
- spec/dummy/db/migrate/20140625163719_create_users.rb
|
225
|
+
- spec/dummy/db/test.sqlite3
|
226
|
+
- spec/dummy/Rakefile
|
227
|
+
- spec/dummy/README.rdoc
|
228
|
+
- spec/lib/user_notifier/configuration_spec.rb
|