notifykit 0.1.0 → 0.2.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d96baaa9ac5a0a64a5f914b4a31daa06a06e2fcc
|
4
|
+
data.tar.gz: 39ac9eda71d9fe5bcfebd394d792f8d5b125b30a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3156b96771dbd2806f606571727d8ad0ae82680f3c21fc9019ca478864c4ec975b7d93cfd7db6f43ea6b5b82d711c4bd25d86143090ce5e9f73ba2172626f7b
|
7
|
+
data.tar.gz: 151d51d7e9c410424d61f8f80b51ec646ebaff300b6a250854e297a14e95fb6519ea7e37e60f5e43fb12a15d50104d465c70540a2bf7874c1671c4635e5ce5fa
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Changes
|
2
|
+
|
3
|
+
Version 0.2.0
|
4
|
+
-------------
|
5
|
+
Adjust notifications_controller to allow certain actions without logging in:
|
6
|
+
- Mark as read
|
7
|
+
- Click
|
8
|
+
- Unsubscribe
|
9
|
+
|
10
|
+
|
11
|
+
Version 0.1.0
|
12
|
+
-------------
|
13
|
+
Initial release of notifykit, support for notifications and mailers and tracking
|
14
|
+
|
@@ -1,6 +1,7 @@
|
|
1
1
|
class NotificationsController < ::ApplicationController
|
2
|
-
before_filter :require_login
|
3
|
-
before_filter :require_notification
|
2
|
+
before_filter :require_login, except: [:click, :read, :unsubscribe]
|
3
|
+
before_filter :require_notification, except: [:click, :read, :unsubscribe]
|
4
|
+
before_filter :require_trackable, only: [:click, :read, :unsubscribe]
|
4
5
|
|
5
6
|
include NotificationsHelper
|
6
7
|
|
@@ -22,12 +23,12 @@ class NotificationsController < ::ApplicationController
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def click
|
25
|
-
|
26
|
+
trackable.click
|
26
27
|
|
27
28
|
# To prevent a bare redirect, validate that the redirect url
|
28
29
|
# was generated when the email was sent
|
29
30
|
target_url = params[:r]
|
30
|
-
target_url = root_url if
|
31
|
+
target_url = root_url if trackable.email_urls.blank? || !trackable.email_urls.split("\n").index(target_url)
|
31
32
|
|
32
33
|
respond_to do |format|
|
33
34
|
format.json { head :no_content }
|
@@ -36,12 +37,12 @@ class NotificationsController < ::ApplicationController
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def read
|
39
|
-
|
40
|
+
trackable.read
|
40
41
|
respond_with_no_content
|
41
42
|
end
|
42
43
|
|
43
44
|
def unsubscribe
|
44
|
-
|
45
|
+
trackable.unsubscribe
|
45
46
|
|
46
47
|
# TODO you may want to improve the unsubscribe logic here
|
47
48
|
respond_to do |format|
|
@@ -74,22 +75,32 @@ class NotificationsController < ::ApplicationController
|
|
74
75
|
notification
|
75
76
|
end
|
76
77
|
|
78
|
+
def require_trackable
|
79
|
+
trackable
|
80
|
+
end
|
81
|
+
|
77
82
|
def notification
|
78
83
|
return @notification if defined?(@notification)
|
79
84
|
@notification = current_user.notifications.where(token: params[:token]).first || raise(ActiveRecord::RecordNotFound)
|
80
85
|
end
|
81
86
|
|
87
|
+
def trackable
|
88
|
+
return @trackable if defined?(@trackable)
|
89
|
+
@trackable = Notification.where(token: params[:token]).first || raise(ActiveRecord::RecordNotFound)
|
90
|
+
end
|
91
|
+
|
82
92
|
def respond_with_no_content
|
83
93
|
respond_to do |format|
|
84
94
|
format.json { head :no_content }
|
85
|
-
format.html {
|
95
|
+
format.html { redirect_to root_url }
|
96
|
+
format.gif {
|
86
97
|
send_data Notifykit.tracking_pixel, :filename => 'blank.gif', :type => 'image/gif', :disposition => 'inline'
|
87
98
|
}
|
88
99
|
end
|
89
100
|
end
|
90
101
|
|
91
102
|
def append_tracking_params(url)
|
92
|
-
return url if
|
103
|
+
return url if trackable.do_not_track
|
93
104
|
query = []
|
94
105
|
query << "utm_campaign=#{utm_campaign}" unless url =~ /utm_campaign/
|
95
106
|
query << "utm_medium=#{utm_medium}" unless url =~ /utm_medium/
|
@@ -103,7 +114,7 @@ class NotificationsController < ::ApplicationController
|
|
103
114
|
end
|
104
115
|
|
105
116
|
def utm_campaign
|
106
|
-
|
117
|
+
trackable.kind
|
107
118
|
end
|
108
119
|
|
109
120
|
def utm_medium
|
@@ -25,13 +25,13 @@ describe NotificationsController do
|
|
25
25
|
|
26
26
|
it "redirects the if there is no user" do
|
27
27
|
controller.stub(:current_user).and_return(nil)
|
28
|
-
get :
|
28
|
+
get :view, valid_params
|
29
29
|
response.should be_redirect
|
30
30
|
end
|
31
31
|
|
32
32
|
it "returns success if there is a user" do
|
33
33
|
controller.stub(:current_user).and_return(user)
|
34
|
-
get :
|
34
|
+
get :view, valid_params
|
35
35
|
response.should be_success
|
36
36
|
end
|
37
37
|
end
|
@@ -51,14 +51,14 @@ describe NotificationsController do
|
|
51
51
|
expect {
|
52
52
|
notification.user = User.create(email: "another@example.com")
|
53
53
|
notification.save
|
54
|
-
get :
|
54
|
+
get :view, valid_params
|
55
55
|
}.to raise_error(ActiveRecord::RecordNotFound)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "returns success if there is a notification" do
|
59
59
|
expect {
|
60
60
|
notification.save
|
61
|
-
get :
|
61
|
+
get :view, valid_params
|
62
62
|
response.should be_success
|
63
63
|
}.not_to raise_error
|
64
64
|
end
|
@@ -68,6 +68,7 @@ describe NotificationsController do
|
|
68
68
|
before(:each) do
|
69
69
|
controller.stub(:current_user).and_return(user)
|
70
70
|
controller.stub(:notification).and_return(notification)
|
71
|
+
controller.stub(:trackable).and_return(notification)
|
71
72
|
end
|
72
73
|
|
73
74
|
describe "recent" do
|
@@ -122,7 +123,7 @@ describe NotificationsController do
|
|
122
123
|
it "should mark the notification as read" do
|
123
124
|
notification.should_receive(:read)
|
124
125
|
get :read, valid_params
|
125
|
-
response.should
|
126
|
+
response.should redirect_to(root_url)
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
@@ -175,7 +176,7 @@ describe NotificationsController do
|
|
175
176
|
before(:each) do
|
176
177
|
notification.email_urls = target_url
|
177
178
|
controller.stub(:current_user).and_return(user)
|
178
|
-
controller.stub(:
|
179
|
+
controller.stub(:trackable).and_return(notification)
|
179
180
|
end
|
180
181
|
|
181
182
|
it "should set the utm source" do
|
data/lib/notifykit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifykit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Rafter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,6 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- .gitignore
|
77
|
+
- CHANGELOG.md
|
77
78
|
- FEATURES.md
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE.txt
|