notify_on 1.0.1
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +29 -0
- data/Rakefile +37 -0
- data/app/assets/config/notify_on_manifest.js +2 -0
- data/app/assets/javascripts/notify_on/application.js +13 -0
- data/app/assets/stylesheets/notify_on/application.css +15 -0
- data/app/controllers/notify_on/application_controller.rb +5 -0
- data/app/helpers/notify_on/application_helper.rb +4 -0
- data/app/helpers/notify_on/mailer_helper.rb +9 -0
- data/app/jobs/notify_on/application_job.rb +4 -0
- data/app/mailers/notify_on/application_mailer.rb +6 -0
- data/app/mailers/notify_on/notification_mailer.rb +26 -0
- data/app/models/concerns/notify_on/email_support.rb +97 -0
- data/app/models/concerns/notify_on/pusher_support.rb +66 -0
- data/app/models/concerns/notify_on/string_interpolation.rb +39 -0
- data/app/models/notify_on/application_record.rb +5 -0
- data/app/models/notify_on/notification.rb +86 -0
- data/app/views/layouts/notify_on/application.html.erb +17 -0
- data/app/views/notifications/notify.html.erb +9 -0
- data/config/database.travis.yml +4 -0
- data/config/routes.rb +2 -0
- data/lib/generators/notify_on/install_generator.rb +29 -0
- data/lib/generators/templates/notifications.yml +19 -0
- data/lib/generators/templates/notify_on.rb +64 -0
- data/lib/notify_on.rb +29 -0
- data/lib/notify_on/bulk_config.rb +36 -0
- data/lib/notify_on/configuration.rb +22 -0
- data/lib/notify_on/creator.rb +85 -0
- data/lib/notify_on/engine.rb +19 -0
- data/lib/notify_on/notify_on.rb +36 -0
- data/lib/notify_on/receives_notifications.rb +11 -0
- data/lib/notify_on/utilities.rb +13 -0
- data/lib/notify_on/version.rb +3 -0
- data/lib/tasks/notify_on_tasks.rake +4 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +5 -0
- data/spec/dummy/app/assets/javascripts/application.js +7 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.scss +28 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +7 -0
- data/spec/dummy/app/controllers/messages_controller.rb +31 -0
- data/spec/dummy/app/helpers/application_helper.rb +8 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/mailers/notification_mailer.rb +15 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/comment.rb +10 -0
- data/spec/dummy/app/models/message.rb +45 -0
- data/spec/dummy/app/models/post.rb +11 -0
- data/spec/dummy/app/models/user.rb +21 -0
- data/spec/dummy/app/views/application/_header.html.erb +44 -0
- data/spec/dummy/app/views/application/home.html.erb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +19 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/app/views/messages/_message.html.erb +6 -0
- data/spec/dummy/app/views/messages/index.html.erb +33 -0
- data/spec/dummy/app/views/messages/new.html.erb +5 -0
- data/spec/dummy/app/views/messages/show.html.erb +7 -0
- data/spec/dummy/app/views/notifications/new_message.html.erb +9 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +34 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config/application.rb +35 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/database.yml +12 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +58 -0
- data/spec/dummy/config/environments/production.rb +86 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/devise.rb +274 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +24 -0
- data/spec/dummy/config/initializers/notify_on.rb +64 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/simple_form.rb +165 -0
- data/spec/dummy/config/initializers/simple_form_bootstrap.rb +149 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/devise.en.yml +62 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/locales/simple_form.en.yml +31 -0
- data/spec/dummy/config/notifications.yml +20 -0
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +14 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/db/migrate/20160801112429_devise_create_users.rb +42 -0
- data/spec/dummy/db/migrate/20160801130804_create_messages.rb +11 -0
- data/spec/dummy/db/migrate/20160823102904_create_notify_on_notifications.rb +20 -0
- data/spec/dummy/db/migrate/20161021100707_create_comments.rb +11 -0
- data/spec/dummy/db/migrate/20161021100842_create_posts.rb +11 -0
- data/spec/dummy/db/schema.rb +77 -0
- data/spec/dummy/db/seeds.rb +4 -0
- data/spec/dummy/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/spec/controllers/messages_controller_spec.rb +5 -0
- data/spec/dummy/spec/factories/comments.rb +7 -0
- data/spec/dummy/spec/factories/messages.rb +7 -0
- data/spec/dummy/spec/factories/posts.rb +6 -0
- data/spec/dummy/spec/factories/users.rb +6 -0
- data/spec/dummy/spec/features/send_message_spec.rb +25 -0
- data/spec/dummy/spec/mailers/notify_on/notification_mailer_spec.rb +30 -0
- data/spec/dummy/spec/mailers/previews/notification_mailer_preview.rb +4 -0
- data/spec/dummy/spec/models/comment_spec.rb +22 -0
- data/spec/dummy/spec/models/message_spec.rb +60 -0
- data/spec/dummy/spec/models/post_spec.rb +23 -0
- data/spec/dummy/spec/models/user_spec.rb +21 -0
- data/spec/factories/notify_on_notifications.rb +10 -0
- data/spec/lib/notify_on/configuration_spec.rb +53 -0
- data/spec/mailers/notify_on/notification_mailer_spec.rb +6 -0
- data/spec/mailers/previews/notify_on/notification_mailer_preview.rb +6 -0
- data/spec/models/notify_on/notification_spec.rb +335 -0
- data/spec/rails_helper.rb +95 -0
- data/spec/spec_helper.rb +103 -0
- data/spec/support/feature_helpers.rb +19 -0
- data/spec/support/general_helpers.rb +19 -0
- metadata +543 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
background-color: #EFEFEF;
|
|
9
|
+
color: #2E2F30;
|
|
10
|
+
text-align: center;
|
|
11
|
+
font-family: arial, sans-serif;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
div.dialog {
|
|
16
|
+
width: 95%;
|
|
17
|
+
max-width: 33em;
|
|
18
|
+
margin: 4em auto 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
div.dialog > div {
|
|
22
|
+
border: 1px solid #CCC;
|
|
23
|
+
border-right-color: #999;
|
|
24
|
+
border-left-color: #999;
|
|
25
|
+
border-bottom-color: #BBB;
|
|
26
|
+
border-top: #B00100 solid 4px;
|
|
27
|
+
border-top-left-radius: 9px;
|
|
28
|
+
border-top-right-radius: 9px;
|
|
29
|
+
background-color: white;
|
|
30
|
+
padding: 7px 12% 0;
|
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h1 {
|
|
35
|
+
font-size: 100%;
|
|
36
|
+
color: #730E15;
|
|
37
|
+
line-height: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
div.dialog > p {
|
|
41
|
+
margin: 0 0 1em;
|
|
42
|
+
padding: 1em;
|
|
43
|
+
background-color: #F7F7F7;
|
|
44
|
+
border: 1px solid #CCC;
|
|
45
|
+
border-right-color: #999;
|
|
46
|
+
border-left-color: #999;
|
|
47
|
+
border-bottom-color: #999;
|
|
48
|
+
border-bottom-left-radius: 4px;
|
|
49
|
+
border-bottom-right-radius: 4px;
|
|
50
|
+
border-top-color: #DADADA;
|
|
51
|
+
color: #666;
|
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
|
|
57
|
+
<body>
|
|
58
|
+
<!-- This file lives in public/422.html -->
|
|
59
|
+
<div class="dialog">
|
|
60
|
+
<div>
|
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
|
63
|
+
</div>
|
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
65
|
+
</div>
|
|
66
|
+
</body>
|
|
67
|
+
</html>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
background-color: #EFEFEF;
|
|
9
|
+
color: #2E2F30;
|
|
10
|
+
text-align: center;
|
|
11
|
+
font-family: arial, sans-serif;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
div.dialog {
|
|
16
|
+
width: 95%;
|
|
17
|
+
max-width: 33em;
|
|
18
|
+
margin: 4em auto 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
div.dialog > div {
|
|
22
|
+
border: 1px solid #CCC;
|
|
23
|
+
border-right-color: #999;
|
|
24
|
+
border-left-color: #999;
|
|
25
|
+
border-bottom-color: #BBB;
|
|
26
|
+
border-top: #B00100 solid 4px;
|
|
27
|
+
border-top-left-radius: 9px;
|
|
28
|
+
border-top-right-radius: 9px;
|
|
29
|
+
background-color: white;
|
|
30
|
+
padding: 7px 12% 0;
|
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h1 {
|
|
35
|
+
font-size: 100%;
|
|
36
|
+
color: #730E15;
|
|
37
|
+
line-height: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
div.dialog > p {
|
|
41
|
+
margin: 0 0 1em;
|
|
42
|
+
padding: 1em;
|
|
43
|
+
background-color: #F7F7F7;
|
|
44
|
+
border: 1px solid #CCC;
|
|
45
|
+
border-right-color: #999;
|
|
46
|
+
border-left-color: #999;
|
|
47
|
+
border-bottom-color: #999;
|
|
48
|
+
border-bottom-left-radius: 4px;
|
|
49
|
+
border-bottom-right-radius: 4px;
|
|
50
|
+
border-top-color: #DADADA;
|
|
51
|
+
color: #666;
|
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
|
|
57
|
+
<body>
|
|
58
|
+
<!-- This file lives in public/500.html -->
|
|
59
|
+
<div class="dialog">
|
|
60
|
+
<div>
|
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
|
62
|
+
</div>
|
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
64
|
+
</div>
|
|
65
|
+
</body>
|
|
66
|
+
</html>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
feature 'Send Message' do
|
|
4
|
+
|
|
5
|
+
scenario 'Creates a notification for the other user' do
|
|
6
|
+
me = create(:user)
|
|
7
|
+
other_user = create(:user)
|
|
8
|
+
|
|
9
|
+
sign_in_as me
|
|
10
|
+
visit new_message_path
|
|
11
|
+
|
|
12
|
+
expect(NotifyOn::Notification.count).to eq(0)
|
|
13
|
+
|
|
14
|
+
select other_user.email, :from => 'message_user_id'
|
|
15
|
+
fill_in 'message_content', :with => Faker::Lorem.paragraph
|
|
16
|
+
click_button 'Create Message'
|
|
17
|
+
|
|
18
|
+
expect(NotifyOn::Notification.count).to eq(1)
|
|
19
|
+
notification = NotifyOn::Notification.first
|
|
20
|
+
expect(notification.recipient).to eq(other_user)
|
|
21
|
+
expect(notification.sender).to eq(me)
|
|
22
|
+
expect(notification.description).to eq("#{me.email} sent you a message.")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require "rails_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe NotifyOn::NotificationMailer, :type => :mailer do
|
|
4
|
+
|
|
5
|
+
# describe 'message notifications on create' do
|
|
6
|
+
# it 'can be overridden with a customized view' do
|
|
7
|
+
# message = create(:message)
|
|
8
|
+
# n = first_notification
|
|
9
|
+
# mail = NotifyOn::NotificationMailer.notify(n.id, 'new_message')
|
|
10
|
+
# expect(mail.to).to eq([message.user.email])
|
|
11
|
+
# expect(mail.from).to eq([message.author.email])
|
|
12
|
+
# expect(mail.body.encoded)
|
|
13
|
+
# .to include("#{message.author.to_s} sent you a message:")
|
|
14
|
+
# end
|
|
15
|
+
# it 'will use a custom mailer if configured to do so' do
|
|
16
|
+
# # Note: We're setting this on the fly instead of overriding throughout the
|
|
17
|
+
# # dummy app.
|
|
18
|
+
# NotifyOn.configure { |config| config.mailer_class = 'NotificationMailer' }
|
|
19
|
+
# message = create(:message)
|
|
20
|
+
# mail = emails[0]
|
|
21
|
+
# # We only change one iteme in this mailer -- just enough to show us we're
|
|
22
|
+
# # using the correct one.
|
|
23
|
+
# expect(mail.from).to eq(['admin@bobross.com'])
|
|
24
|
+
# NotifyOn.configure do |config|
|
|
25
|
+
# config.mailer_class = 'NotifyOn::NotificationMailer'
|
|
26
|
+
# end
|
|
27
|
+
# end
|
|
28
|
+
# end
|
|
29
|
+
|
|
30
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Comment, type: :model do
|
|
4
|
+
|
|
5
|
+
let(:comment) { create(:comment) }
|
|
6
|
+
|
|
7
|
+
it 'updates the original notification within the appropriate scope' do
|
|
8
|
+
comment
|
|
9
|
+
n = comment.notifications.first
|
|
10
|
+
expect(notification_count).to eq(1)
|
|
11
|
+
# This should update the notification.
|
|
12
|
+
create(:comment, :user => comment.user, :post => comment.post)
|
|
13
|
+
expect(notification_count).to eq(1)
|
|
14
|
+
# This does not apply to the update -- a new notification is created.
|
|
15
|
+
create(:comment, :post => comment.post)
|
|
16
|
+
expect(notification_count).to eq(2)
|
|
17
|
+
# Nor does this -- a new notification is created.
|
|
18
|
+
create(:comment, :user => comment.user)
|
|
19
|
+
expect(notification_count).to eq(3)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Message, :type => :model do
|
|
4
|
+
|
|
5
|
+
let(:message) { create(:message) }
|
|
6
|
+
|
|
7
|
+
context 'creates a notification that' do
|
|
8
|
+
before(:each) do
|
|
9
|
+
@message = message
|
|
10
|
+
@notification = first_notification
|
|
11
|
+
end
|
|
12
|
+
it 'is the only notification' do
|
|
13
|
+
[notification_count, email_count].each { |n| expect(n).to eq(1) }
|
|
14
|
+
end
|
|
15
|
+
it 'gets deleted when it is deleted' do
|
|
16
|
+
message.destroy
|
|
17
|
+
expect(notification_count).to eq(0)
|
|
18
|
+
end
|
|
19
|
+
it 'can be skipped by using "skip_notifications"' do
|
|
20
|
+
expect { create(:message, :skip_notifications => true) }
|
|
21
|
+
.to change { notification_count }.by(0)
|
|
22
|
+
end
|
|
23
|
+
it 'is to the message "user"' do
|
|
24
|
+
expect(@notification.recipient).to eq(message.user)
|
|
25
|
+
end
|
|
26
|
+
it 'is from the message author' do
|
|
27
|
+
expect(@notification.sender).to eq(message.author)
|
|
28
|
+
end
|
|
29
|
+
it 'interpolates a description' do
|
|
30
|
+
msg = "#{message.author.email} sent you a message."
|
|
31
|
+
expect(@notification.description).to eq(msg)
|
|
32
|
+
end
|
|
33
|
+
it 'interpolates the link' do
|
|
34
|
+
expect(@notification.link).to eq("/messages/#{@message.id}")
|
|
35
|
+
end
|
|
36
|
+
it 'is accessible via an association' do
|
|
37
|
+
expect(@message.respond_to?(:notifications)).to eq(true)
|
|
38
|
+
expect(@message.notifications.to_a).to match_array([@notification])
|
|
39
|
+
end
|
|
40
|
+
context 'sends an email that' do
|
|
41
|
+
before(:each) { @email = emails[0] }
|
|
42
|
+
it 'is sent from the default address' do
|
|
43
|
+
# This is set in the initializer.
|
|
44
|
+
expect(@email.from).to eq(['noreply@example.com'])
|
|
45
|
+
end
|
|
46
|
+
it 'is sent to the notification recipient' do
|
|
47
|
+
expect(@email.to).to eq([@notification.recipient.email])
|
|
48
|
+
end
|
|
49
|
+
it 'has a fallback subject that matches the description' do
|
|
50
|
+
subject = "#{message.author.email} sent you a message."
|
|
51
|
+
expect(@email.subject).to eq(subject)
|
|
52
|
+
end
|
|
53
|
+
it 'uses the default template' do
|
|
54
|
+
expect(@email.body.encoded).to include('You have a new notification:')
|
|
55
|
+
expect(@email.body.encoded).to include(@notification.description)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Post, type: :model do
|
|
4
|
+
|
|
5
|
+
let(:post) { create(:post) }
|
|
6
|
+
|
|
7
|
+
context 'creates a notification that' do
|
|
8
|
+
let(:post) { create(:post, :state => :draft) }
|
|
9
|
+
it 'does not create a notification on create' do
|
|
10
|
+
post
|
|
11
|
+
expect(notification_count).to eq(0)
|
|
12
|
+
end
|
|
13
|
+
it 'does not create a notification when changing to "pending"' do
|
|
14
|
+
post.pending!
|
|
15
|
+
expect(notification_count).to eq(0)
|
|
16
|
+
end
|
|
17
|
+
it 'creates a notification when changing to "published"' do
|
|
18
|
+
post.published!
|
|
19
|
+
expect(notification_count).to eq(1)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe User, :type => :model do
|
|
4
|
+
|
|
5
|
+
let(:user) { create(:user) }
|
|
6
|
+
|
|
7
|
+
describe 'self#receives_notifications' do
|
|
8
|
+
it 'should be associated to notifications' do
|
|
9
|
+
expect(user.respond_to?(:notifications)).to eq(true)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'deletes its notifications when it is deleted' do
|
|
14
|
+
user
|
|
15
|
+
create(:message, :user => user)
|
|
16
|
+
expect(user.notifications.count).to eq(1)
|
|
17
|
+
user.destroy
|
|
18
|
+
expect(user.notifications.count).to eq(0)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
describe NotifyOn::Configuration do
|
|
4
|
+
|
|
5
|
+
# Reset the configuration to what the app was using after each spec here.
|
|
6
|
+
after(:each) do
|
|
7
|
+
NotifyOn.configure do |config|
|
|
8
|
+
config.default_email = 'NotifyOn <noreply@example.com>'
|
|
9
|
+
config.pusher_app_id = 'my_app_id'
|
|
10
|
+
config.pusher_key = 'my_key'
|
|
11
|
+
config.pusher_secret = 'my_secret'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'sets the expected defaults' do
|
|
16
|
+
NotifyOn.reset
|
|
17
|
+
config = NotifyOn.configuration
|
|
18
|
+
expect(config.default_email).to eq(nil)
|
|
19
|
+
expect(config.default_pusher_channel).to eq(nil)
|
|
20
|
+
expect(config.default_pusher_event).to eq(nil)
|
|
21
|
+
expect(config.deliver_mail).to eq(:now)
|
|
22
|
+
expect(config.mailer_class).to eq('NotifyOn::NotificationMailer')
|
|
23
|
+
expect(config.pusher_app_id).to eq(nil)
|
|
24
|
+
expect(config.pusher_key).to eq(nil)
|
|
25
|
+
expect(config.pusher_secret).to eq(nil)
|
|
26
|
+
expect(config.use_pusher_by_default).to eq(false)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'can be overridden' do
|
|
30
|
+
NotifyOn.configure do |config|
|
|
31
|
+
config.default_email = 'noreply@example.com'
|
|
32
|
+
config.default_pusher_channel = 'presence-message-{id}'
|
|
33
|
+
config.default_pusher_event = 'new_message'
|
|
34
|
+
config.deliver_mail = :later
|
|
35
|
+
config.mailer_class = 'NotificationMailer'
|
|
36
|
+
config.pusher_app_id = 'my_app_id'
|
|
37
|
+
config.pusher_key = 'my_key'
|
|
38
|
+
config.pusher_secret = 'my_secret'
|
|
39
|
+
config.use_pusher_by_default = true
|
|
40
|
+
end
|
|
41
|
+
config = NotifyOn.configuration
|
|
42
|
+
expect(config.default_email).to eq('noreply@example.com')
|
|
43
|
+
expect(config.default_pusher_channel).to eq('presence-message-{id}')
|
|
44
|
+
expect(config.default_pusher_event).to eq('new_message')
|
|
45
|
+
expect(config.deliver_mail).to eq(:later)
|
|
46
|
+
expect(config.mailer_class).to eq('NotificationMailer')
|
|
47
|
+
expect(config.pusher_app_id).to eq('my_app_id')
|
|
48
|
+
expect(config.pusher_key).to eq('my_key')
|
|
49
|
+
expect(config.pusher_secret).to eq('my_secret')
|
|
50
|
+
expect(config.use_pusher_by_default).to eq(true)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|