notifiable-rails 0.19.9 → 0.20.0
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/Rakefile +1 -11
- data/app/controllers/notifiable/device_tokens_controller.rb +1 -1
- data/{lib/generators/notifiable/install/templates/create_notifiable_apps.rb → db/migrate/20131210115648_create_notifiable_apps.rb} +0 -0
- data/{lib/generators/notifiable/install/templates/create_notifiable_device_tokens.rb → db/migrate/20131210115649_create_notifiable_device_tokens.rb} +0 -0
- data/{lib/generators/notifiable/install/templates/create_notifiable_notifications.rb → db/migrate/20131210115650_create_notifiable_notifications.rb} +0 -0
- data/{lib/generators/notifiable/install/templates/create_notifiable_statuses.rb → db/migrate/20131210115651_create_notifiable_statuses.rb} +0 -0
- data/lib/notifiable/engine.rb +10 -0
- data/lib/notifiable/version.rb +1 -1
- data/spec/controllers/device_tokens_controller_spec.rb +114 -105
- data/spec/controllers/notifications_controller_spec.rb +45 -45
- data/spec/model/notifiable_app_spec.rb +25 -0
- data/spec/model/notifiable_spec.rb +25 -0
- data/spec/model/notification_spec.rb +105 -0
- data/spec/model/notifier_base_spec.rb +18 -0
- data/spec/spec_helper.rb +15 -1
- data/spec/test_app/app/controllers/application_controller.rb +2 -0
- data/spec/test_app/config/database.yml +6 -0
- data/spec/test_app/db/development.sqlite3 +0 -0
- data/spec/test_app/db/migrate/{20131210115648_create_users.rb → 20131210115652_create_users.rb} +0 -0
- data/spec/test_app/db/schema.rb +2 -2
- data/spec/test_app/db/test.sqlite3 +0 -0
- data/spec/test_app/log/development.log +186 -0
- data/spec/test_app/log/test.log +33197 -0
- metadata +48 -70
- data/spec/notifiable_app_spec.rb +0 -24
- data/spec/notifiable_spec.rb +0 -20
- data/spec/notification_spec.rb +0 -119
- data/spec/notifier_base_spec.rb +0 -27
- data/spec/test_app/db/migrate/20131210115649_create_notifiable_apps.rb +0 -10
- data/spec/test_app/db/migrate/20131228225139_create_notifiable_device_tokens.rb +0 -18
- data/spec/test_app/db/migrate/20131228225140_create_notifiable_notifications.rb +0 -26
- data/spec/test_app/db/migrate/20131229104039_create_notifiable_statuses.rb +0 -12
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifiable-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kamil Kocemba
|
@@ -9,160 +9,146 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 4.1.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 4.1.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rspec-rails
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: sqlite3
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: factory_girl_rails
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
63
|
-
type: :development
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: debugger
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - '>='
|
60
|
+
- - ">="
|
75
61
|
- !ruby/object:Gem::Version
|
76
62
|
version: '0'
|
77
63
|
type: :development
|
78
64
|
prerelease: false
|
79
65
|
version_requirements: !ruby/object:Gem::Requirement
|
80
66
|
requirements:
|
81
|
-
- -
|
67
|
+
- - ">="
|
82
68
|
- !ruby/object:Gem::Version
|
83
69
|
version: '0'
|
84
70
|
- !ruby/object:Gem::Dependency
|
85
71
|
name: simplecov
|
86
72
|
requirement: !ruby/object:Gem::Requirement
|
87
73
|
requirements:
|
88
|
-
- -
|
74
|
+
- - ">="
|
89
75
|
- !ruby/object:Gem::Version
|
90
76
|
version: '0'
|
91
77
|
type: :development
|
92
78
|
prerelease: false
|
93
79
|
version_requirements: !ruby/object:Gem::Requirement
|
94
80
|
requirements:
|
95
|
-
- -
|
81
|
+
- - ">="
|
96
82
|
- !ruby/object:Gem::Version
|
97
83
|
version: '0'
|
98
84
|
- !ruby/object:Gem::Dependency
|
99
85
|
name: simplecov-rcov
|
100
86
|
requirement: !ruby/object:Gem::Requirement
|
101
87
|
requirements:
|
102
|
-
- -
|
88
|
+
- - ">="
|
103
89
|
- !ruby/object:Gem::Version
|
104
90
|
version: '0'
|
105
91
|
type: :development
|
106
92
|
prerelease: false
|
107
93
|
version_requirements: !ruby/object:Gem::Requirement
|
108
94
|
requirements:
|
109
|
-
- -
|
95
|
+
- - ">="
|
110
96
|
- !ruby/object:Gem::Version
|
111
97
|
version: '0'
|
112
98
|
- !ruby/object:Gem::Dependency
|
113
99
|
name: database_cleaner
|
114
100
|
requirement: !ruby/object:Gem::Requirement
|
115
101
|
requirements:
|
116
|
-
- -
|
102
|
+
- - ">="
|
117
103
|
- !ruby/object:Gem::Version
|
118
104
|
version: '0'
|
119
105
|
type: :development
|
120
106
|
prerelease: false
|
121
107
|
version_requirements: !ruby/object:Gem::Requirement
|
122
108
|
requirements:
|
123
|
-
- -
|
109
|
+
- - ">="
|
124
110
|
- !ruby/object:Gem::Version
|
125
111
|
version: '0'
|
126
112
|
- !ruby/object:Gem::Dependency
|
127
113
|
name: brakeman
|
128
114
|
requirement: !ruby/object:Gem::Requirement
|
129
115
|
requirements:
|
130
|
-
- -
|
116
|
+
- - ">="
|
131
117
|
- !ruby/object:Gem::Version
|
132
118
|
version: '0'
|
133
119
|
type: :development
|
134
120
|
prerelease: false
|
135
121
|
version_requirements: !ruby/object:Gem::Requirement
|
136
122
|
requirements:
|
137
|
-
- -
|
123
|
+
- - ">="
|
138
124
|
- !ruby/object:Gem::Version
|
139
125
|
version: '0'
|
140
126
|
- !ruby/object:Gem::Dependency
|
141
127
|
name: puppet
|
142
128
|
requirement: !ruby/object:Gem::Requirement
|
143
129
|
requirements:
|
144
|
-
- -
|
130
|
+
- - ">="
|
145
131
|
- !ruby/object:Gem::Version
|
146
132
|
version: '0'
|
147
133
|
type: :development
|
148
134
|
prerelease: false
|
149
135
|
version_requirements: !ruby/object:Gem::Requirement
|
150
136
|
requirements:
|
151
|
-
- -
|
137
|
+
- - ">="
|
152
138
|
- !ruby/object:Gem::Version
|
153
139
|
version: '0'
|
154
140
|
- !ruby/object:Gem::Dependency
|
155
141
|
name: ruby-prof
|
156
142
|
requirement: !ruby/object:Gem::Requirement
|
157
143
|
requirements:
|
158
|
-
- -
|
144
|
+
- - ">="
|
159
145
|
- !ruby/object:Gem::Version
|
160
146
|
version: '0'
|
161
147
|
type: :development
|
162
148
|
prerelease: false
|
163
149
|
version_requirements: !ruby/object:Gem::Requirement
|
164
150
|
requirements:
|
165
|
-
- -
|
151
|
+
- - ">="
|
166
152
|
- !ruby/object:Gem::Version
|
167
153
|
version: '0'
|
168
154
|
description: 'Rails engine to make push notifications a bit easier. '
|
@@ -173,15 +159,18 @@ executables: []
|
|
173
159
|
extensions: []
|
174
160
|
extra_rdoc_files: []
|
175
161
|
files:
|
162
|
+
- LICENSE
|
163
|
+
- Rakefile
|
176
164
|
- app/controllers/notifiable/device_tokens_controller.rb
|
177
165
|
- app/controllers/notifiable/notifications_controller.rb
|
178
166
|
- config/routes.rb
|
167
|
+
- db/migrate/20131210115648_create_notifiable_apps.rb
|
168
|
+
- db/migrate/20131210115649_create_notifiable_device_tokens.rb
|
169
|
+
- db/migrate/20131210115650_create_notifiable_notifications.rb
|
170
|
+
- db/migrate/20131210115651_create_notifiable_statuses.rb
|
179
171
|
- lib/generators/notifiable/install/install_generator.rb
|
180
|
-
- lib/generators/notifiable/install/templates/create_notifiable_apps.rb
|
181
|
-
- lib/generators/notifiable/install/templates/create_notifiable_device_tokens.rb
|
182
|
-
- lib/generators/notifiable/install/templates/create_notifiable_notifications.rb
|
183
|
-
- lib/generators/notifiable/install/templates/create_notifiable_statuses.rb
|
184
172
|
- lib/generators/notifiable/install/templates/initializer.rb
|
173
|
+
- lib/notifiable.rb
|
185
174
|
- lib/notifiable/active_record.rb
|
186
175
|
- lib/notifiable/app.rb
|
187
176
|
- lib/notifiable/device_token.rb
|
@@ -192,20 +181,19 @@ files:
|
|
192
181
|
- lib/notifiable/notifier_base.rb
|
193
182
|
- lib/notifiable/railtie.rb
|
194
183
|
- lib/notifiable/version.rb
|
195
|
-
- lib/notifiable.rb
|
196
184
|
- lib/tasks/brakeman.rake
|
197
|
-
- LICENSE
|
198
|
-
- Rakefile
|
199
185
|
- spec/controllers/device_tokens_controller_spec.rb
|
200
186
|
- spec/controllers/notifications_controller_spec.rb
|
201
|
-
- spec/notifiable_app_spec.rb
|
202
|
-
- spec/notifiable_spec.rb
|
203
|
-
- spec/notification_spec.rb
|
204
|
-
- spec/notifier_base_spec.rb
|
187
|
+
- spec/model/notifiable_app_spec.rb
|
188
|
+
- spec/model/notifiable_spec.rb
|
189
|
+
- spec/model/notification_spec.rb
|
190
|
+
- spec/model/notifier_base_spec.rb
|
205
191
|
- spec/spec_helper.rb
|
206
192
|
- spec/support/engine_controller.rb
|
207
193
|
- spec/support/factories.rb
|
208
194
|
- spec/support/request_helpers.rb
|
195
|
+
- spec/test_app/README.rdoc
|
196
|
+
- spec/test_app/Rakefile
|
209
197
|
- spec/test_app/app/assets/javascripts/application.js
|
210
198
|
- spec/test_app/app/assets/stylesheets/application.css
|
211
199
|
- spec/test_app/app/controllers/application_controller.rb
|
@@ -215,6 +203,7 @@ files:
|
|
215
203
|
- spec/test_app/bin/bundle
|
216
204
|
- spec/test_app/bin/rails
|
217
205
|
- spec/test_app/bin/rake
|
206
|
+
- spec/test_app/config.ru
|
218
207
|
- spec/test_app/config/apns-development.pem
|
219
208
|
- spec/test_app/config/application.rb
|
220
209
|
- spec/test_app/config/boot.rb
|
@@ -233,13 +222,8 @@ files:
|
|
233
222
|
- spec/test_app/config/initializers/wrap_parameters.rb
|
234
223
|
- spec/test_app/config/locales/en.yml
|
235
224
|
- spec/test_app/config/routes.rb
|
236
|
-
- spec/test_app/config.ru
|
237
225
|
- spec/test_app/db/development.sqlite3
|
238
|
-
- spec/test_app/db/migrate/
|
239
|
-
- spec/test_app/db/migrate/20131210115649_create_notifiable_apps.rb
|
240
|
-
- spec/test_app/db/migrate/20131228225139_create_notifiable_device_tokens.rb
|
241
|
-
- spec/test_app/db/migrate/20131228225140_create_notifiable_notifications.rb
|
242
|
-
- spec/test_app/db/migrate/20131229104039_create_notifiable_statuses.rb
|
226
|
+
- spec/test_app/db/migrate/20131210115652_create_users.rb
|
243
227
|
- spec/test_app/db/schema.rb
|
244
228
|
- spec/test_app/db/test.sqlite3
|
245
229
|
- spec/test_app/log/development.log
|
@@ -248,8 +232,6 @@ files:
|
|
248
232
|
- spec/test_app/public/422.html
|
249
233
|
- spec/test_app/public/500.html
|
250
234
|
- spec/test_app/public/favicon.ico
|
251
|
-
- spec/test_app/Rakefile
|
252
|
-
- spec/test_app/README.rdoc
|
253
235
|
homepage: http://www.futureworkshops.com
|
254
236
|
licenses:
|
255
237
|
- Apache 2.0
|
@@ -260,27 +242,27 @@ require_paths:
|
|
260
242
|
- lib
|
261
243
|
required_ruby_version: !ruby/object:Gem::Requirement
|
262
244
|
requirements:
|
263
|
-
- -
|
245
|
+
- - "~>"
|
264
246
|
- !ruby/object:Gem::Version
|
265
|
-
version:
|
247
|
+
version: 2.1.0
|
266
248
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
249
|
requirements:
|
268
|
-
- -
|
250
|
+
- - ">="
|
269
251
|
- !ruby/object:Gem::Version
|
270
252
|
version: '0'
|
271
253
|
requirements: []
|
272
254
|
rubyforge_project:
|
273
|
-
rubygems_version: 2.
|
255
|
+
rubygems_version: 2.2.2
|
274
256
|
signing_key:
|
275
257
|
specification_version: 4
|
276
258
|
summary: Rails engine to make push notifications a bit easier.
|
277
259
|
test_files:
|
278
260
|
- spec/controllers/device_tokens_controller_spec.rb
|
279
261
|
- spec/controllers/notifications_controller_spec.rb
|
280
|
-
- spec/notifiable_app_spec.rb
|
281
|
-
- spec/notifiable_spec.rb
|
282
|
-
- spec/notification_spec.rb
|
283
|
-
- spec/notifier_base_spec.rb
|
262
|
+
- spec/model/notifiable_app_spec.rb
|
263
|
+
- spec/model/notifiable_spec.rb
|
264
|
+
- spec/model/notification_spec.rb
|
265
|
+
- spec/model/notifier_base_spec.rb
|
284
266
|
- spec/spec_helper.rb
|
285
267
|
- spec/support/engine_controller.rb
|
286
268
|
- spec/support/factories.rb
|
@@ -314,11 +296,7 @@ test_files:
|
|
314
296
|
- spec/test_app/config/routes.rb
|
315
297
|
- spec/test_app/config.ru
|
316
298
|
- spec/test_app/db/development.sqlite3
|
317
|
-
- spec/test_app/db/migrate/
|
318
|
-
- spec/test_app/db/migrate/20131210115649_create_notifiable_apps.rb
|
319
|
-
- spec/test_app/db/migrate/20131228225139_create_notifiable_device_tokens.rb
|
320
|
-
- spec/test_app/db/migrate/20131228225140_create_notifiable_notifications.rb
|
321
|
-
- spec/test_app/db/migrate/20131229104039_create_notifiable_statuses.rb
|
299
|
+
- spec/test_app/db/migrate/20131210115652_create_users.rb
|
322
300
|
- spec/test_app/db/schema.rb
|
323
301
|
- spec/test_app/db/test.sqlite3
|
324
302
|
- spec/test_app/log/development.log
|
data/spec/notifiable_app_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Notifiable::App do
|
4
|
-
|
5
|
-
let(:notifiable_app) { FactoryGirl.create(:app, :configuration => {:configurable_mock => {:use_sandbox => true}}) }
|
6
|
-
let(:notification) { FactoryGirl.create(:notification, :app => notifiable_app) }
|
7
|
-
let(:notifier) { ConfigurableMockNotifier.new(Rails.env, notification) }
|
8
|
-
|
9
|
-
it "contains notifications" do
|
10
|
-
notification.app.should_not be_nil
|
11
|
-
notifiable_app.notifications.count.should == 1
|
12
|
-
end
|
13
|
-
|
14
|
-
it "configures a notifier" do
|
15
|
-
notifiable_app.configure :configurable_mock, notifier
|
16
|
-
|
17
|
-
notifier.use_sandbox.should == true
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
class ConfigurableMockNotifier < Notifiable::NotifierBase
|
23
|
-
attr_accessor :use_sandbox
|
24
|
-
end
|
data/spec/notifiable_spec.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Notifiable::Concern do
|
4
|
-
let(:user1) { FactoryGirl.create(:user_with_mock_token) }
|
5
|
-
let(:invalid_token_user) { FactoryGirl.create(:user_with_invalid_mock_token) }
|
6
|
-
let(:notification1) { FactoryGirl.create(:notification, :message => "First test message")}
|
7
|
-
|
8
|
-
it "sends a single push notification" do
|
9
|
-
user1.send_notification(notification1)
|
10
|
-
|
11
|
-
Notifiable::NotificationStatus.count.should == 1
|
12
|
-
end
|
13
|
-
|
14
|
-
it "sends zero notifications if the device is not valid" do
|
15
|
-
invalid_token_user.send_notification(notification1)
|
16
|
-
|
17
|
-
Notifiable::NotificationStatus.count.should == 0
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
data/spec/notification_spec.rb
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Notifiable::Notification do
|
4
|
-
|
5
|
-
let(:user1) { FactoryGirl.create(:user_with_mock_token) }
|
6
|
-
let(:user2) { FactoryGirl.create(:user_with_mock_token) }
|
7
|
-
let(:notification1) { FactoryGirl.create(:notification, :message => "First test message")}
|
8
|
-
let(:notification2) { FactoryGirl.create(:notification, :message => "Second test message")}
|
9
|
-
|
10
|
-
it "stores a message" do
|
11
|
-
FactoryGirl.create(:notification, :message => "Test message")
|
12
|
-
|
13
|
-
Notifiable::Notification.first.message.should eql "Test message"
|
14
|
-
end
|
15
|
-
|
16
|
-
it "stores params" do
|
17
|
-
FactoryGirl.create(:notification, :params => {:custom_property => "A different message"})
|
18
|
-
|
19
|
-
Notifiable::Notification.first.params.should == {:custom_property => "A different message"}
|
20
|
-
end
|
21
|
-
|
22
|
-
it "destroys dependent NotificationStatuses" do
|
23
|
-
n = FactoryGirl.create(:notification, :params => {:custom_property => "A different message"})
|
24
|
-
Notifiable::NotificationStatus.create :notification => n
|
25
|
-
|
26
|
-
n.destroy
|
27
|
-
|
28
|
-
Notifiable::NotificationStatus.count.should == 0
|
29
|
-
end
|
30
|
-
|
31
|
-
it "adds a notifiable object" do
|
32
|
-
notification1.batch do |n|
|
33
|
-
n.add_notifiable(user1)
|
34
|
-
end
|
35
|
-
|
36
|
-
Notifiable::NotificationStatus.count.should == 1
|
37
|
-
saved_notification = Notifiable::Notification.first
|
38
|
-
saved_notification.sent_count.should == 1
|
39
|
-
saved_notification.gateway_accepted_count.should == 1
|
40
|
-
saved_notification.opened_count.should == 0
|
41
|
-
|
42
|
-
saved_status = Notifiable::NotificationStatus.first
|
43
|
-
saved_status.status.should == 0
|
44
|
-
saved_status.created_at.should_not be_nil
|
45
|
-
end
|
46
|
-
|
47
|
-
it "adds a device token" do
|
48
|
-
notification1.batch do |n|
|
49
|
-
n.add_device_token(user1.device_tokens.first)
|
50
|
-
end
|
51
|
-
|
52
|
-
Notifiable::NotificationStatus.count.should == 1
|
53
|
-
saved_notification = Notifiable::Notification.first
|
54
|
-
saved_notification.sent_count.should == 1
|
55
|
-
saved_notification.gateway_accepted_count.should == 1
|
56
|
-
end
|
57
|
-
|
58
|
-
it "sends a push notification to two users" do
|
59
|
-
notification1.batch do |n|
|
60
|
-
n.add_notifiable(user1)
|
61
|
-
n.add_notifiable(user2)
|
62
|
-
end
|
63
|
-
|
64
|
-
Notifiable::NotificationStatus.count.should == 2
|
65
|
-
|
66
|
-
all_notifications = Notifiable::NotificationStatus.all
|
67
|
-
first_notification_token = all_notifications[0]
|
68
|
-
first_notification_token.notification.message.should eql "First test message"
|
69
|
-
first_notification_token.device_token.should eql user1.device_tokens[0]
|
70
|
-
|
71
|
-
second_notification_token = all_notifications[1]
|
72
|
-
second_notification_token.notification.message.should eql "First test message"
|
73
|
-
second_notification_token.device_token.should eql user2.device_tokens[0]
|
74
|
-
end
|
75
|
-
|
76
|
-
it "sends separate push notifications" do
|
77
|
-
notification1.batch do |n|
|
78
|
-
n.add_notifiable(user1)
|
79
|
-
end
|
80
|
-
|
81
|
-
notification2.batch do |n|
|
82
|
-
n.add_notifiable(user2)
|
83
|
-
end
|
84
|
-
|
85
|
-
Notifiable::NotificationStatus.count.should == 2
|
86
|
-
|
87
|
-
all_notifications = Notifiable::NotificationStatus.all
|
88
|
-
first_notification_token = all_notifications[0]
|
89
|
-
first_notification_token.status.should == 0
|
90
|
-
first_notification_token.notification.message.should eql "First test message"
|
91
|
-
first_notification_token.device_token.should eql user1.device_tokens[0]
|
92
|
-
|
93
|
-
second_notification_token = all_notifications[1]
|
94
|
-
second_notification_token.status.should == 0
|
95
|
-
second_notification_token.notification.message.should eql "Second test message"
|
96
|
-
second_notification_token.device_token.should eql user2.device_tokens[0]
|
97
|
-
end
|
98
|
-
|
99
|
-
it "raise an error if notification provider isnt found" do
|
100
|
-
unconfigured_device_token = FactoryGirl.create(:mock_token, :provider => :sms)
|
101
|
-
|
102
|
-
notification1.batch do |n|
|
103
|
-
n.add_notifiable(user1)
|
104
|
-
|
105
|
-
raised_error = false
|
106
|
-
begin
|
107
|
-
n.add_device_token(unconfigured_device_token)
|
108
|
-
rescue
|
109
|
-
raised_error = true
|
110
|
-
end
|
111
|
-
raised_error.should be_true
|
112
|
-
|
113
|
-
n.add_notifiable(user2)
|
114
|
-
end
|
115
|
-
|
116
|
-
Notifiable::NotificationStatus.count.should == 2
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|