activity_notification 1.7.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +3 -0
  3. data/.travis.yml +16 -2
  4. data/CHANGELOG.md +22 -2
  5. data/Gemfile +7 -0
  6. data/Procfile +2 -0
  7. data/README.md +366 -32
  8. data/Rakefile +19 -10
  9. data/activity_notification.gemspec +5 -3
  10. data/app/channels/activity_notification/notification_channel.rb +37 -0
  11. data/app/channels/activity_notification/notification_with_devise_channel.rb +51 -0
  12. data/app/controllers/activity_notification/notifications_controller.rb +1 -1
  13. data/app/controllers/activity_notification/subscriptions_controller.rb +1 -1
  14. data/app/jobs/activity_notification/notify_all_job.rb +16 -0
  15. data/app/jobs/activity_notification/notify_job.rb +17 -0
  16. data/app/jobs/activity_notification/notify_to_job.rb +16 -0
  17. data/app/views/activity_notification/notifications/default/_default_without_grouping.html.erb +1 -1
  18. data/app/views/activity_notification/notifications/default/index.html.erb +55 -2
  19. data/bin/_dynamodblocal +4 -0
  20. data/{scripts → bin}/bundle_update.sh +1 -0
  21. data/bin/deploy_on_heroku.sh +14 -0
  22. data/bin/install_dynamodblocal.sh +5 -0
  23. data/bin/start_dynamodblocal.sh +47 -0
  24. data/bin/stop_dynamodblocal.sh +34 -0
  25. data/gemfiles/Gemfile.rails-4.2 +1 -0
  26. data/gemfiles/Gemfile.rails-5.0 +2 -0
  27. data/gemfiles/Gemfile.rails-5.1 +1 -0
  28. data/gemfiles/Gemfile.rails-5.2 +1 -0
  29. data/gemfiles/Gemfile.rails-6.0.rc +21 -0
  30. data/lib/activity_notification.rb +1 -0
  31. data/lib/activity_notification/apis/notification_api.rb +289 -136
  32. data/lib/activity_notification/apis/subscription_api.rb +80 -53
  33. data/lib/activity_notification/common.rb +3 -3
  34. data/lib/activity_notification/config.rb +89 -33
  35. data/lib/activity_notification/controllers/common_controller.rb +19 -7
  36. data/lib/activity_notification/helpers/errors.rb +4 -0
  37. data/lib/activity_notification/helpers/view_helpers.rb +1 -1
  38. data/lib/activity_notification/models/concerns/notifiable.rb +61 -53
  39. data/lib/activity_notification/models/concerns/subscriber.rb +7 -6
  40. data/lib/activity_notification/models/concerns/target.rb +73 -28
  41. data/lib/activity_notification/optional_targets/base.rb +2 -2
  42. data/lib/activity_notification/orm/active_record/notification.rb +4 -23
  43. data/lib/activity_notification/orm/dynamoid.rb +495 -0
  44. data/lib/activity_notification/orm/dynamoid/extension.rb +184 -0
  45. data/lib/activity_notification/orm/dynamoid/notification.rb +189 -0
  46. data/lib/activity_notification/orm/dynamoid/subscription.rb +82 -0
  47. data/lib/activity_notification/orm/mongoid.rb +4 -1
  48. data/lib/activity_notification/orm/mongoid/notification.rb +8 -25
  49. data/lib/activity_notification/orm/mongoid/subscription.rb +1 -1
  50. data/lib/activity_notification/roles/acts_as_notifiable.rb +33 -5
  51. data/lib/activity_notification/roles/acts_as_target.rb +62 -9
  52. data/lib/activity_notification/version.rb +1 -1
  53. data/lib/generators/templates/activity_notification.rb +30 -7
  54. data/lib/tasks/activity_notification_tasks.rake +14 -4
  55. data/spec/channels/notification_channel_shared_examples.rb +59 -0
  56. data/spec/channels/notification_channel_spec.rb +50 -0
  57. data/spec/channels/notification_with_devise_channel_spec.rb +99 -0
  58. data/spec/concerns/apis/notification_api_spec.rb +2 -2
  59. data/spec/concerns/apis/subscription_api_spec.rb +2 -2
  60. data/spec/concerns/models/notifiable_spec.rb +72 -7
  61. data/spec/concerns/models/subscriber_spec.rb +53 -49
  62. data/spec/concerns/models/target_spec.rb +135 -13
  63. data/spec/config_spec.rb +41 -1
  64. data/spec/controllers/notifications_controller_shared_examples.rb +7 -3
  65. data/spec/controllers/subscriptions_controller_shared_examples.rb +7 -3
  66. data/spec/helpers/view_helpers_spec.rb +12 -10
  67. data/spec/models/dummy/dummy_group_spec.rb +4 -0
  68. data/spec/models/dummy/dummy_notifiable_spec.rb +4 -0
  69. data/spec/models/dummy/dummy_notifier_spec.rb +4 -0
  70. data/spec/models/dummy/dummy_subscriber_spec.rb +3 -0
  71. data/spec/models/dummy/dummy_target_spec.rb +4 -0
  72. data/spec/models/notification_spec.rb +164 -45
  73. data/spec/models/subscription_spec.rb +69 -14
  74. data/spec/orm/dynamoid_spec.rb +115 -0
  75. data/spec/rails_app/app/assets/javascripts/application.js +2 -1
  76. data/spec/rails_app/app/assets/javascripts/cable.js +12 -0
  77. data/spec/rails_app/app/controllers/comments_controller.rb +3 -4
  78. data/spec/rails_app/app/models/admin.rb +6 -4
  79. data/spec/rails_app/app/models/article.rb +2 -2
  80. data/spec/rails_app/app/models/comment.rb +17 -5
  81. data/spec/rails_app/app/models/user.rb +5 -3
  82. data/spec/rails_app/app/views/activity_notification/notifications/users/overridden/custom/_test.html.erb +1 -0
  83. data/spec/rails_app/config/application.rb +6 -1
  84. data/spec/rails_app/config/cable.yml +8 -0
  85. data/spec/rails_app/config/dynamoid.rb +5 -0
  86. data/spec/rails_app/config/environment.rb +4 -1
  87. data/spec/rails_app/config/environments/production.rb +1 -1
  88. data/spec/rails_app/config/initializers/activity_notification.rb +30 -7
  89. data/spec/rails_app/config/locales/activity_notification.en.yml +2 -0
  90. data/spec/rails_app/db/seeds.rb +21 -5
  91. data/spec/rails_app/lib/mailer_previews/mailer_preview.rb +12 -4
  92. data/spec/roles/acts_as_notifiable_spec.rb +2 -2
  93. data/spec/roles/acts_as_target_spec.rb +1 -1
  94. data/spec/spec_helper.rb +15 -8
  95. metadata +67 -20
  96. data/spec/rails_app/app/models/.keep +0 -0
  97. data/spec/rails_app/app/views/activity_notification/notifications/users/overriden/custom/_test.html.erb +0 -1
@@ -1,3 +1,6 @@
1
+ # To run as single test for debugging
2
+ # require Rails.root.join('../../spec/concerns/apis/subscription_api_spec.rb').to_s
3
+
1
4
  describe ActivityNotification::Subscription, type: :model do
2
5
 
3
6
  it_behaves_like :subscription_api
@@ -92,16 +95,22 @@ describe ActivityNotification::Subscription, type: :model do
92
95
 
93
96
  context 'with custom_filter options' do
94
97
  it "works with filtered_by_options scope" do
95
- if ActivityNotification.config.orm == :active_record
96
- subscriptions = ActivityNotification::Subscription.filtered_by_options({ custom_filter: ["subscriptions.key = ?", @key_1] })
97
- expect(subscriptions.size).to eq(1)
98
- expect(subscriptions.first).to eq(@subscription_1)
99
- end
100
-
101
98
  subscriptions = ActivityNotification::Subscription.filtered_by_options({ custom_filter: { key: @key_2 } })
102
99
  expect(subscriptions.size).to eq(1)
103
100
  expect(subscriptions.first).to eq(@subscription_2)
104
101
  end
102
+
103
+ it "works with filtered_by_options scope with filter depending on ORM" do
104
+ options =
105
+ case ActivityNotification.config.orm
106
+ when :active_record then { custom_filter: ["subscriptions.key = ?", @key_1] }
107
+ when :mongoid then { custom_filter: { key: {'$eq': @key_1} } }
108
+ when :dynamoid then { custom_filter: {'key.begins_with': @key_1} }
109
+ end
110
+ subscriptions = ActivityNotification::Subscription.filtered_by_options(options)
111
+ expect(subscriptions.size).to eq(1)
112
+ expect(subscriptions.first).to eq(@subscription_1)
113
+ end
105
114
  end
106
115
 
107
116
  context 'with no options' do
@@ -116,21 +125,67 @@ describe ActivityNotification::Subscription, type: :model do
116
125
  context "to make order by created_at" do
117
126
  before do
118
127
  ActivityNotification::Subscription.delete_all
119
- @subscription_1 = create(:subscription, key: 'key.1')
120
- @subscription_2 = create(:subscription, key: 'key.2', created_at: @subscription_1.created_at + 10.second)
121
- @subscription_3 = create(:subscription, key: 'key.3', created_at: @subscription_1.created_at + 20.second)
122
- @subscription_4 = create(:subscription, key: 'key.4', created_at: @subscription_1.created_at + 30.second)
128
+ @target = create(:confirmed_user)
129
+ @subscription_1 = create(:subscription, target: @target, key: 'key.1')
130
+ @subscription_2 = create(:subscription, target: @target, key: 'key.2', created_at: @subscription_1.created_at + 10.second)
131
+ @subscription_3 = create(:subscription, target: @target, key: 'key.3', created_at: @subscription_1.created_at + 20.second)
132
+ @subscription_4 = create(:subscription, target: @target, key: 'key.4', created_at: @subscription_1.created_at + 30.second)
133
+ end
134
+
135
+ unless ActivityNotification.config.orm == :dynamoid
136
+ context "using ORM other than dynamoid, you can directly call latest/earliest order method from class objects" do
137
+
138
+ it "works with latest_order scope" do
139
+ subscriptions = ActivityNotification::Subscription.latest_order
140
+ expect(subscriptions.size).to eq(4)
141
+ expect(subscriptions.first).to eq(@subscription_4)
142
+ expect(subscriptions.last).to eq(@subscription_1)
143
+ end
144
+
145
+ it "works with earliest_order scope" do
146
+ subscriptions = ActivityNotification::Subscription.earliest_order
147
+ expect(subscriptions.size).to eq(4)
148
+ expect(subscriptions.first).to eq(@subscription_1)
149
+ expect(subscriptions.last).to eq(@subscription_4)
150
+ end
151
+
152
+ end
153
+ else
154
+ context "using dynamoid, you can call latest/earliest order method only with query using partition key of Global Secondary Index" do
155
+
156
+ it "works with latest_order scope" do
157
+ subscriptions = ActivityNotification::Subscription.filtered_by_target(@target).latest_order
158
+ expect(subscriptions.size).to eq(4)
159
+ expect(subscriptions.first).to eq(@subscription_4)
160
+ expect(subscriptions.last).to eq(@subscription_1)
161
+ end
162
+
163
+ it "works with earliest_order scope" do
164
+ subscriptions = ActivityNotification::Subscription.filtered_by_target(@target).earliest_order
165
+ expect(subscriptions.size).to eq(4)
166
+ expect(subscriptions.first).to eq(@subscription_1)
167
+ expect(subscriptions.last).to eq(@subscription_4)
168
+ end
169
+
170
+ end
123
171
  end
124
172
 
125
- it "works with latest_order scope" do
126
- subscriptions = ActivityNotification::Subscription.latest_order
173
+ it "works with latest_order! scope" do
174
+ subscriptions = ActivityNotification::Subscription.latest_order!
127
175
  expect(subscriptions.size).to eq(4)
128
176
  expect(subscriptions.first).to eq(@subscription_4)
129
177
  expect(subscriptions.last).to eq(@subscription_1)
130
178
  end
131
179
 
132
- it "works with earliest_order scope" do
133
- subscriptions = ActivityNotification::Subscription.earliest_order
180
+ it "works with latest_order!(reverse=true) scope" do
181
+ subscriptions = ActivityNotification::Subscription.latest_order!(true)
182
+ expect(subscriptions.size).to eq(4)
183
+ expect(subscriptions.first).to eq(@subscription_1)
184
+ expect(subscriptions.last).to eq(@subscription_4)
185
+ end
186
+
187
+ it "works with earliest_order! scope" do
188
+ subscriptions = ActivityNotification::Subscription.earliest_order!
134
189
  expect(subscriptions.size).to eq(4)
135
190
  expect(subscriptions.first).to eq(@subscription_1)
136
191
  expect(subscriptions.last).to eq(@subscription_4)
@@ -0,0 +1,115 @@
1
+ if ActivityNotification.config.orm == :dynamoid
2
+ describe Dynamoid::Criteria::None do
3
+ let(:none) { ActivityNotification::Notification.none }
4
+
5
+ it "is a Dynamoid::Criteria::None" do
6
+ expect(none).to be_a(Dynamoid::Criteria::None)
7
+ end
8
+
9
+ context "== operator" do
10
+ it "returns true against other None object" do
11
+ expect(none).to eq(ActivityNotification::Notification.none)
12
+ end
13
+
14
+ it "returns false against other objects" do
15
+ expect(none).not_to eq(1)
16
+ end
17
+ end
18
+
19
+ context "records" do
20
+ it "returns empty array" do
21
+ expect(none.records).to eq([])
22
+ end
23
+ end
24
+
25
+ context "all" do
26
+ it "returns empty array" do
27
+ expect(none.all).to eq([])
28
+ end
29
+ end
30
+
31
+ context "count" do
32
+ it "returns 0" do
33
+ expect(none.count).to eq(0)
34
+ end
35
+ end
36
+
37
+ context "delete_all" do
38
+ it "does nothing" do
39
+ expect(none.delete_all).to be_nil
40
+ end
41
+ end
42
+
43
+ context "empty?" do
44
+ it "returns true" do
45
+ expect(none.empty?).to be_truthy
46
+ end
47
+ end
48
+ end
49
+
50
+ describe Dynamoid::Criteria::Chain do
51
+ let(:chain) { ActivityNotification::Notification.scan_index_forward(true) }
52
+
53
+ before do
54
+ ActivityNotification::Notification.delete_all
55
+ end
56
+
57
+ it "is a Dynamoid::Criteria::None" do
58
+ expect(chain).to be_a(Dynamoid::Criteria::Chain)
59
+ end
60
+
61
+ context "none" do
62
+ it "returns Dynamoid::Criteria::None" do
63
+ expect(chain.none).to be_a(Dynamoid::Criteria::None)
64
+ end
65
+ end
66
+
67
+ context "limit" do
68
+ before do
69
+ create(:notification)
70
+ create(:notification)
71
+ end
72
+
73
+ it "returns limited records by record_limit" do
74
+ expect(chain.count).to eq(2)
75
+ expect(chain.limit(1).count).to eq(1)
76
+ end
77
+ end
78
+
79
+ context "exists?" do
80
+ it "returns false when the record does not exist" do
81
+ expect(chain.exists?).to be_falsy
82
+ end
83
+
84
+ it "returns true when the record exists" do
85
+ create(:notification)
86
+ expect(chain.exists?).to be_truthy
87
+ end
88
+ end
89
+
90
+ context "size" do
91
+ it "returns same value as count" do
92
+ expect(chain.count).to eq(0)
93
+ expect(chain.size).to eq(0)
94
+ create(:notification)
95
+ expect(chain.count).to eq(1)
96
+ expect(chain.size).to eq(1)
97
+ end
98
+ end
99
+
100
+ context "update_all" do
101
+ before do
102
+ create(:notification)
103
+ create(:notification)
104
+ end
105
+
106
+ it "updates all records" do
107
+ expect(ActivityNotification::Notification.where(key: "default.default").count).to eq(2)
108
+ expect(ActivityNotification::Notification.where(key: "updated.all").count).to eq(0)
109
+ chain.update_all(key: "updated.all")
110
+ expect(ActivityNotification::Notification.where(key: "default.default").count).to eq(0)
111
+ expect(ActivityNotification::Notification.where(key: "updated.all").count).to eq(2)
112
+ end
113
+ end
114
+ end
115
+ end
@@ -1,2 +1,3 @@
1
1
  //= require jquery
2
- //= require jquery_ujs
2
+ //= require jquery_ujs
3
+ //= require_tree .
@@ -0,0 +1,12 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+
7
+ (function() {
8
+ this.App || (this.App = {});
9
+
10
+ App.cable = ActionCable.createConsumer();
11
+
12
+ }).call(this);
@@ -7,10 +7,9 @@ class CommentsController < ApplicationController
7
7
  @comment.user = current_user
8
8
 
9
9
  if @comment.save
10
- @comment.notify_later :users, key: 'comment.create.later'
11
- # @comment.notify :users, key: 'comment.create.later', notify_later: true
12
- @comment.notify_now :users, key: 'comment.create.now'
13
- # @comment.notify :users, key: 'comment.create.now'
10
+ @comment.notify_now :users, key: 'comment.create', parameters: { notifier_name: @comment.user.printable_notifier_name, article_title: @comment.article.title }
11
+ # @comment.notify_later :users, key: 'comment.create', parameters: { notifier_name: @comment.user.printable_notifier_name, article_title: @comment.article.title }
12
+ # @comment.notify :users, key: 'comment.create', notify_later: true, parameters: { notifier_name: @comment.user.printable_notifier_name, article_title: @comment.article.title }
14
13
  redirect_to @comment.article, notice: 'Comment was successfully created.'
15
14
  else
16
15
  redirect_to @comment.article
@@ -7,8 +7,9 @@ unless ENV['AN_TEST_DB'] == 'mongodb'
7
7
  subscription_allowed: true,
8
8
  devise_resource: :user,
9
9
  current_devise_target: ->(current_user) { current_user.admin },
10
- printable_name: ->(admin) { "admin (#{admin.user.name})" }
11
- end
10
+ printable_name: ->(admin) { "admin (#{admin.user.name})" },
11
+ action_cable_allowed: true, action_cable_with_devise: true
12
+ end
12
13
  else
13
14
  require 'mongoid'
14
15
  class Admin
@@ -27,6 +28,7 @@ else
27
28
  subscription_allowed: true,
28
29
  devise_resource: :user,
29
30
  current_devise_target: ->(current_user) { current_user.admin },
30
- printable_name: ->(admin) { "admin (#{admin.user.name})" }
31
- end
31
+ printable_name: ->(admin) { "admin (#{admin.user.name})" },
32
+ action_cable_allowed: true, action_cable_with_devise: true
33
+ end
32
34
  end
@@ -7,7 +7,7 @@ unless ENV['AN_TEST_DB'] == 'mongodb'
7
7
 
8
8
  acts_as_notifiable :users,
9
9
  targets: ->(article) { User.all.to_a - [article.user] },
10
- notifier: :user, email_allowed: true,
10
+ notifier: :user, email_allowed: true, action_cable_allowed: true,
11
11
  printable_name: ->(article) { "new article \"#{article.title}\"" },
12
12
  dependent_notifications: :delete_all
13
13
  acts_as_notification_group printable_name: ->(article) { "article \"#{article.title}\"" }
@@ -33,7 +33,7 @@ else
33
33
  include ActivityNotification::Models
34
34
  acts_as_notifiable :users,
35
35
  targets: ->(article) { User.all.to_a - [article.user] },
36
- notifier: :user, email_allowed: true,
36
+ notifier: :user, email_allowed: true, action_cable_allowed: true,
37
37
  printable_name: ->(article) { "new article \"#{article.title}\"" },
38
38
  dependent_notifications: :delete_all
39
39
  acts_as_notification_group printable_name: ->(article) { "article \"#{article.title}\"" }
@@ -8,13 +8,14 @@ unless ENV['AN_TEST_DB'] == 'mongodb'
8
8
  acts_as_notifiable :users,
9
9
  targets: ->(comment, key) { ([comment.article.user] + comment.article.commented_users.to_a - [comment.user]).uniq },
10
10
  group: :article, notifier: :user, email_allowed: true,
11
+ action_cable_allowed: true,
11
12
  parameters: { 'test_default_param' => '1' },
12
13
  notifiable_path: :article_notifiable_path,
13
14
  printable_name: ->(comment) { "comment \"#{comment.body}\"" },
14
15
  dependent_notifications: :update_group_and_delete_all
15
16
 
16
17
  require 'custom_optional_targets/console_output'
17
- optional_targets = { CustomOptionalTarget::ConsoleOutput => {} }
18
+ # optional_targets = { CustomOptionalTarget::ConsoleOutput => {} }
18
19
  if ENV['OPTIONAL_TARGET_AMAZON_SNS']
19
20
  require 'activity_notification/optional_targets/amazon_sns'
20
21
  if ENV['OPTIONAL_TARGET_AMAZON_SNS_TOPIC_ARN']
@@ -37,13 +38,18 @@ unless ENV['AN_TEST_DB'] == 'mongodb'
37
38
  }
38
39
  )
39
40
  end
40
- acts_as_notifiable :admins, targets: [Admin.first].compact,
41
+ acts_as_notifiable :admins,
42
+ targets: Admin.all.to_a,
41
43
  group: :article, notifier: :user, notifiable_path: :article_notifiable_path,
42
- tracked: { only: [:create] },
44
+ action_cable_allowed: true,
45
+ tracked: { only: [:create], action_cable_rendering: { fallback: :default } },
43
46
  printable_name: ->(comment) { "comment \"#{comment.body}\"" },
44
47
  dependent_notifications: :delete_all,
45
48
  optional_targets: optional_targets
46
49
 
50
+ # For testing
51
+ acts_as_group
52
+
47
53
  def article_notifiable_path
48
54
  article_path(article)
49
55
  end
@@ -69,6 +75,7 @@ else
69
75
  acts_as_notifiable :users,
70
76
  targets: ->(comment, key) { ([comment.article.user] + comment.article.commented_users.to_a - [comment.user]).uniq },
71
77
  group: :article, notifier: :user, email_allowed: true,
78
+ action_cable_allowed: true,
72
79
  parameters: { 'test_default_param' => '1' },
73
80
  notifiable_path: :article_notifiable_path,
74
81
  printable_name: ->(comment) { "comment \"#{comment.body}\"" },
@@ -98,13 +105,18 @@ else
98
105
  }
99
106
  )
100
107
  end
101
- acts_as_notifiable :admins, targets: [Admin.first].compact,
108
+ acts_as_notifiable :admins,
109
+ targets: Admin.all.to_a,
102
110
  group: :article, notifier: :user, notifiable_path: :article_notifiable_path,
103
- tracked: { only: [:create] },
111
+ action_cable_allowed: true,
112
+ tracked: { only: [:create], action_cable_rendering: { fallback: :default } },
104
113
  printable_name: ->(comment) { "comment \"#{comment.body}\"" },
105
114
  dependent_notifications: :delete_all,
106
115
  optional_targets: optional_targets
107
116
 
117
+ # For testing
118
+ acts_as_group
119
+
108
120
  def article_notifiable_path
109
121
  article_path(article)
110
122
  end
@@ -6,7 +6,8 @@ unless ENV['AN_TEST_DB'] == 'mongodb'
6
6
  has_one :admin, dependent: :destroy
7
7
 
8
8
  acts_as_target email: :email, email_allowed: :confirmed_at, batch_email_allowed: :confirmed_at,
9
- subscription_allowed: true, printable_name: :name
9
+ subscription_allowed: true, printable_name: :name,
10
+ action_cable_allowed: true, action_cable_with_devise: true
10
11
  acts_as_notifier printable_name: :name
11
12
 
12
13
  def admin?
@@ -37,8 +38,9 @@ else
37
38
 
38
39
  include ActivityNotification::Models
39
40
  acts_as_target email: :email, email_allowed: :confirmed_at, batch_email_allowed: :confirmed_at,
40
- subscription_allowed: true, printable_name: :name
41
- acts_as_notifier printable_name: :name
41
+ subscription_allowed: true, printable_name: :name,
42
+ action_cable_allowed: true, action_cable_with_devise: true
43
+ acts_as_notifier printable_name: :name
42
44
 
43
45
  def admin?
44
46
  admin.present?
@@ -0,0 +1 @@
1
+ Overridden custom template root for user target: <%= notification.id %>
@@ -7,6 +7,10 @@ if ENV['AN_ORM'] == 'mongoid'
7
7
  if Rails.env != 'test'
8
8
  Mongoid.load!(File.expand_path("config/mongoid.yml"), :development)
9
9
  end
10
+ elsif ENV['AN_ORM'] == 'dynamoid'
11
+ require 'dynamoid'
12
+ require 'rails'
13
+ require File.expand_path('../dynamoid', __FILE__)
10
14
  end
11
15
 
12
16
  # Pick the frameworks you want:
@@ -17,7 +21,7 @@ require "action_controller/railtie"
17
21
  require "action_mailer/railtie"
18
22
  require "action_view/railtie"
19
23
  require "sprockets/railtie"
20
- # require "rails/test_unit/railtie"
24
+ require 'action_cable/engine' if Rails::VERSION::MAJOR >= 5
21
25
 
22
26
  Bundler.require(*Rails.groups)
23
27
  require "activity_notification"
@@ -34,3 +38,4 @@ module Dummy
34
38
  end
35
39
  end
36
40
 
41
+ puts "ActivityNotification test parameters: AN_ORM=#{ENV['AN_ORM'] || 'active_record(default)'} AN_TEST_DB=#{ENV['AN_TEST_DB'] || 'sqlite(default)'}"
@@ -0,0 +1,8 @@
1
+ production:
2
+ adapter: async
3
+
4
+ development:
5
+ adapter: async
6
+
7
+ test:
8
+ adapter: test
@@ -0,0 +1,5 @@
1
+ Dynamoid.configure do |config|
2
+ config.namespace = "activity_notification_#{Rails.env}"
3
+ config.endpoint = 'http://localhost:8000'
4
+ # config.store_datetime_as_string = true
5
+ end
@@ -1,6 +1,9 @@
1
1
  # Load the Rails application.
2
2
  require File.expand_path('../application', __FILE__)
3
3
 
4
+ # Demo application uses Devise
5
+ require 'devise'
6
+
4
7
  # Initialize the Rails application.
5
8
  Rails.application.initialize!
6
9
 
@@ -15,7 +18,7 @@ def silent_stdout(&block)
15
18
  end
16
19
 
17
20
  # Load database schema
18
- if Rails.env.test? && ENV['AN_TEST_DB'] != 'mongodb'
21
+ if Rails.env.test? && ['mongodb', 'dynamodb'].exclude?(ENV['AN_TEST_DB'])
19
22
  silent_stdout do
20
23
  load "#{Rails.root}/db/schema.rb"
21
24
  end