notifiable-rails 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/notifiable/install/templates/create_notifiable_notifications.rb +5 -1
- data/lib/notifiable/notification.rb +1 -9
- data/lib/notifiable/version.rb +1 -1
- data/spec/notifiable_server_spec.rb +4 -4
- data/spec/notification_spec.rb +5 -11
- data/spec/test_app/db/migrate/20131228225140_create_notifiable_notifications.rb +5 -1
- data/spec/test_app/db/schema.rb +5 -1
- data/spec/test_app/db/test.sqlite3 +0 -0
- data/spec/test_app/log/test.log +8783 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39b16fa6a22178fc28e5ce367b72f065ebaba804
|
4
|
+
data.tar.gz: 67bd6e6fbe7c05b79b5af04bb810abe78c9f9f54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7e405b314ead10453aae774684a9fef411adcc9736e57198135cc4f84b0a5e6db66aa5b1e38fdc1d8694ef9a0b1af70045ba0707e9e8a44e629e6871f78f79d
|
7
|
+
data.tar.gz: 1df7aa3df2289fa1f58624c6d5bfcc9e1919de6a99b92a32927eb048bcf4c10fc3b7a8e9b61758fbea85dfc6b167a3e73eac341a8d669eacdb013c719843cce6
|
@@ -2,8 +2,12 @@ class CreateNotifiableNotifications < ActiveRecord::Migration
|
|
2
2
|
|
3
3
|
def change
|
4
4
|
create_table :notifiable_notifications do |t|
|
5
|
+
t.text :title
|
5
6
|
t.text :message
|
6
|
-
t.text :
|
7
|
+
t.text :params
|
8
|
+
t.integer :badge
|
9
|
+
t.text :sound
|
10
|
+
t.datetime :expiry
|
7
11
|
t.timestamps
|
8
12
|
end
|
9
13
|
end
|
@@ -1,16 +1,8 @@
|
|
1
1
|
module Notifiable
|
2
2
|
class Notification < ActiveRecord::Base
|
3
3
|
|
4
|
-
serialize :
|
4
|
+
serialize :params
|
5
5
|
|
6
6
|
has_many :notification_device_tokens, :class_name => 'Notifiable::NotificationDeviceToken'
|
7
|
-
|
8
|
-
def provider_value(provider, key)
|
9
|
-
if self.payload && self.payload[provider] && self.payload[provider][key]
|
10
|
-
self.payload[provider][key]
|
11
|
-
elsif self.respond_to? key
|
12
|
-
self.send(key)
|
13
|
-
end
|
14
|
-
end
|
15
7
|
end
|
16
8
|
end
|
data/lib/notifiable/version.rb
CHANGED
@@ -16,11 +16,11 @@ describe Notifiable do
|
|
16
16
|
|
17
17
|
all_notifications = Notifiable::NotificationDeviceToken.all
|
18
18
|
first_notification_token = all_notifications[0]
|
19
|
-
first_notification_token.notification.
|
19
|
+
first_notification_token.notification.message.should eql "First test message"
|
20
20
|
first_notification_token.device_token.should eql user1.device_tokens[0]
|
21
21
|
|
22
22
|
second_notification_token = all_notifications[1]
|
23
|
-
second_notification_token.notification.
|
23
|
+
second_notification_token.notification.message.should eql "First test message"
|
24
24
|
second_notification_token.device_token.should eql user2.device_tokens[0]
|
25
25
|
end
|
26
26
|
|
@@ -34,11 +34,11 @@ describe Notifiable do
|
|
34
34
|
|
35
35
|
all_notifications = Notifiable::NotificationDeviceToken.all
|
36
36
|
first_notification_token = all_notifications[0]
|
37
|
-
first_notification_token.notification.
|
37
|
+
first_notification_token.notification.message.should eql "First test message"
|
38
38
|
first_notification_token.device_token.should eql user1.device_tokens[0]
|
39
39
|
|
40
40
|
second_notification_token = all_notifications[1]
|
41
|
-
second_notification_token.notification.
|
41
|
+
second_notification_token.notification.message.should eql "Second test message"
|
42
42
|
second_notification_token.device_token.should eql user2.device_tokens[0]
|
43
43
|
end
|
44
44
|
|
data/spec/notification_spec.rb
CHANGED
@@ -3,21 +3,15 @@ require 'spec_helper'
|
|
3
3
|
describe Notifiable::Notification do
|
4
4
|
|
5
5
|
it "stores a message" do
|
6
|
-
Notifiable::Notification.create
|
6
|
+
Notifiable::Notification.create(:message => "Test message")
|
7
7
|
|
8
|
-
Notifiable::Notification.first.
|
8
|
+
Notifiable::Notification.first.message.should eql "Test message"
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
12
|
-
Notifiable::Notification.create :
|
11
|
+
it "stores params" do
|
12
|
+
Notifiable::Notification.create :params => {:custom_property => "A different message"}
|
13
13
|
|
14
|
-
Notifiable::Notification.first.
|
15
|
-
end
|
16
|
-
|
17
|
-
it "returns nil for a property that doesnt exist" do
|
18
|
-
Notifiable::Notification.create :message => "Test message"
|
19
|
-
|
20
|
-
Notifiable::Notification.first.provider_value(:mock, :sound).should be_nil
|
14
|
+
Notifiable::Notification.first.params.should == {:custom_property => "A different message"}
|
21
15
|
end
|
22
16
|
|
23
17
|
end
|
@@ -2,8 +2,12 @@ class CreateNotifiableNotifications < ActiveRecord::Migration
|
|
2
2
|
|
3
3
|
def change
|
4
4
|
create_table :notifiable_notifications do |t|
|
5
|
+
t.text :title
|
5
6
|
t.text :message
|
6
|
-
t.text :
|
7
|
+
t.text :params
|
8
|
+
t.integer :badge
|
9
|
+
t.text :sound
|
10
|
+
t.datetime :expiry
|
7
11
|
t.timestamps
|
8
12
|
end
|
9
13
|
end
|
data/spec/test_app/db/schema.rb
CHANGED
@@ -35,8 +35,12 @@ ActiveRecord::Schema.define(version: 20131229104039) do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
create_table "notifiable_notifications", force: true do |t|
|
38
|
+
t.text "title"
|
38
39
|
t.text "message"
|
39
|
-
t.text "
|
40
|
+
t.text "params"
|
41
|
+
t.integer "badge"
|
42
|
+
t.text "sound"
|
43
|
+
t.datetime "expiry"
|
40
44
|
t.datetime "created_at"
|
41
45
|
t.datetime "updated_at"
|
42
46
|
end
|
Binary file
|