ahoy_email 0.5.2 → 1.0.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.
data/.gitignore DELETED
@@ -1,24 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- *.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- *.bundle
19
- *.so
20
- *.o
21
- *.a
22
- mkmf.log
23
- *.log
24
- *.sqlite
data/.travis.yml DELETED
@@ -1,16 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4.2
4
- sudo: false
5
- script: bundle exec rake test
6
- before_script:
7
- - gem install bundler
8
- notifications:
9
- email:
10
- on_success: never
11
- on_failure: change
12
- gemfile:
13
- - Gemfile
14
- - test/gemfiles/actionmailer51.gemfile
15
- - test/gemfiles/actionmailer50.gemfile
16
- - test/gemfiles/actionmailer42.gemfile
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in ahoy_email.gemspec
4
- gemspec
5
-
6
- gem "actionmailer", "~> 5.2.0"
data/Rakefile DELETED
@@ -1,9 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- task default: :test
5
- Rake::TestTask.new do |t|
6
- t.libs << "test"
7
- t.pattern = "test/**/*_test.rb"
8
- t.warning = false
9
- end
data/ahoy_email.gemspec DELETED
@@ -1,35 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "ahoy_email/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "ahoy_email"
8
- spec.version = AhoyEmail::VERSION
9
- spec.authors = ["Andrew Kane"]
10
- spec.email = ["andrew@chartkick.com"]
11
- spec.summary = "Simple, powerful email tracking for Rails"
12
- spec.homepage = "https://github.com/ankane/ahoy_email"
13
- spec.license = "MIT"
14
-
15
- spec.files = `git ls-files -z`.split("\x0")
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
19
-
20
- spec.required_ruby_version = ">= 2.2.0"
21
-
22
- spec.add_runtime_dependency "railties"
23
- spec.add_runtime_dependency "actionmailer"
24
- spec.add_runtime_dependency "activerecord"
25
- spec.add_runtime_dependency "addressable", ">= 2.3.2"
26
- spec.add_runtime_dependency "nokogiri"
27
- spec.add_runtime_dependency "safely_block", ">= 0.1.1"
28
-
29
- spec.add_development_dependency "bundler"
30
- spec.add_development_dependency "rake"
31
- spec.add_development_dependency "minitest"
32
- spec.add_development_dependency "combustion"
33
- spec.add_development_dependency "rails"
34
- spec.add_development_dependency "sqlite3"
35
- end
@@ -1,30 +0,0 @@
1
- class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %>
2
- def change
3
- create_table :ahoy_messages do |t|
4
- t.string :token
5
-
6
- # user
7
- t.text :to
8
- t.references :user, polymorphic: true
9
-
10
- # optional - feel free to remove
11
- t.string :mailer
12
- t.text :subject
13
- # t.text :content
14
-
15
- # optional
16
- # t.string :utm_source
17
- # t.string :utm_medium
18
- # t.string :utm_term
19
- # t.string :utm_content
20
- # t.string :utm_campaign
21
-
22
- # timestamps
23
- t.timestamp :sent_at
24
- t.timestamp :opened_at
25
- t.timestamp :clicked_at
26
- end
27
-
28
- add_index :ahoy_messages, [:token]
29
- end
30
- end
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in ahoy_email.gemspec
4
- gemspec path: "../../"
5
-
6
- gem "actionmailer", "~> 4.2.0"
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in ahoy_email.gemspec
4
- gemspec path: "../../"
5
-
6
- gem "actionmailer", "~> 5.0.0"
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in ahoy_email.gemspec
4
- gemspec path: "../../"
5
-
6
- gem "actionmailer", "~> 5.1.0"
@@ -1,3 +0,0 @@
1
- test:
2
- adapter: sqlite3
3
- database: db/combustion_test.sqlite
@@ -1,3 +0,0 @@
1
- Rails.application.routes.draw do
2
- #
3
- end
@@ -1,30 +0,0 @@
1
- ActiveRecord::Schema.define do
2
- create_table :ahoy_messages, force: true do |t|
3
- t.string :token
4
-
5
- # user
6
- t.text :to
7
- t.integer :user_id
8
- t.string :user_type
9
-
10
- # optional - feel free to remove
11
- t.string :mailer
12
- t.text :subject
13
- t.text :content
14
-
15
- # optional
16
- t.string :utm_source
17
- t.string :utm_medium
18
- t.string :utm_term
19
- t.string :utm_content
20
- t.string :utm_campaign
21
-
22
- # timestamps
23
- t.timestamp :sent_at
24
- t.timestamp :opened_at
25
- t.timestamp :clicked_at
26
- end
27
-
28
- add_index :ahoy_messages, [:token]
29
- add_index :ahoy_messages, [:user_id, :user_type]
30
- end
data/test/mailer_test.rb DELETED
@@ -1,153 +0,0 @@
1
- require_relative "test_helper"
2
-
3
- class UserMailer < ActionMailer::Base
4
- default from: "from@example.com"
5
- after_action :prevent_delivery_to_guests, only: [:welcome2] if Rails.version >= "4.0.0"
6
-
7
- def welcome
8
- mail to: "test@example.org", subject: "Hello", body: "World"
9
- end
10
-
11
- def welcome2
12
- mail to: "test@example.org", subject: "Hello", body: "World"
13
- end
14
-
15
- def welcome3
16
- track message: false
17
- mail to: "test@example.org", subject: "Hello", body: "World"
18
- end
19
-
20
- def welcome4
21
- html_message('<a href="http://example.org">Hi<a>')
22
- end
23
-
24
- def welcome5
25
- html_message('<a href="http://example.org?baz[]=1&amp;baz[]=2">Hi<a>')
26
- end
27
-
28
- def heuristic_parse
29
- track heuristic_parse: true
30
- html_message('<a href="example.org">Hi<a>')
31
- end
32
-
33
- def mailto
34
- track heuristic_parse: true
35
- html_message('<a href="mailto:someone@yoursite.com">Email Us</a>')
36
- end
37
-
38
- def app_link
39
- track heuristic_parse: true
40
- html_message('<a href="fb://profile/33138223345">Email Us</a>')
41
- end
42
-
43
- def welcome4_heuristic
44
- track heuristic_parse: true
45
- html_message('<a href="http://example.org">Hi<a>')
46
- end
47
-
48
- def welcome5_heuristic
49
- track heuristic_parse: true
50
- html_message('<a href="http://example.org?baz[]=1&amp;baz[]=2">Hi<a>')
51
- end
52
-
53
- private
54
-
55
- def prevent_delivery_to_guests
56
- mail.perform_deliveries = false
57
- end
58
-
59
- def html_message(html)
60
- track click: false
61
- mail to: "test@example.org", subject: "Hello" do |format|
62
- format.html { render plain: html }
63
- end
64
- end
65
- end
66
-
67
- class MailerTest < Minitest::Test
68
- def setup
69
- Ahoy::Message.delete_all
70
- end
71
-
72
- def test_basic
73
- assert_message :welcome
74
- end
75
-
76
- def test_prevent_delivery
77
- assert_message :welcome2
78
- if Rails.version >= "4.0.0"
79
- assert_nil Ahoy::Message.first.sent_at
80
- end
81
- end
82
-
83
- def test_no_message
84
- UserMailer.welcome3.to
85
- assert_equal 0, Ahoy::Message.count
86
- end
87
-
88
- def test_utm_params
89
- message = UserMailer.welcome4
90
- body = message.body.to_s
91
- assert_match "utm_campaign=welcome4", body
92
- assert_match "utm_medium=email", body
93
- assert_match "utm_source=user_mailer", body
94
- end
95
-
96
- def test_array_params
97
- message = UserMailer.welcome5
98
- body = message.body.to_s
99
- assert_match "baz%5B%5D=1&amp;baz%5B%5D=2", body
100
- end
101
-
102
- def test_heuristic_parse
103
- # Should convert the URI fragment into a URI
104
- message = UserMailer.heuristic_parse
105
- body = message.body.to_s
106
- assert_match "http://example.org", body
107
- end
108
-
109
- def test_mailto
110
- # heuristic parse should ignore the mailto link
111
- message = UserMailer.mailto
112
- body = message.body.to_s
113
- assert_match "<a href=\"mailto:someone@yoursite.com\">", body
114
- end
115
-
116
- def test_app_link
117
- # heuristic parse should ignore the app link
118
- message = UserMailer.app_link
119
- body = message.body.to_s
120
- assert_match "<a href=\"fb://profile/33138223345\">", body
121
- end
122
-
123
- def test_utm_params_heuristic_parse
124
- # heuristic parse should not have unexpected side effects
125
- message = UserMailer.welcome4_heuristic
126
- body = message.body.to_s
127
- assert_match "utm_campaign=welcome4", body
128
- assert_match "utm_medium=email", body
129
- assert_match "utm_source=user_mailer", body
130
- end
131
-
132
- def test_array_params_heuristic_parse
133
- # heuristic parse should not have unexpected side effects
134
- message = UserMailer.welcome5_heuristic
135
- body = message.body.to_s
136
- assert_match "baz%5B%5D=1&amp;baz%5B%5D=2", body
137
- end
138
-
139
- private
140
-
141
- def assert_message(method)
142
- message = UserMailer.send(method)
143
- message.respond_to?(:deliver_now) ? message.deliver_now : message.deliver
144
- ahoy_message = Ahoy::Message.first
145
- assert_equal 1, Ahoy::Message.count
146
- assert_equal "test@example.org", ahoy_message.to
147
- assert_equal "UserMailer##{method}", ahoy_message.mailer
148
- assert_equal "Hello", ahoy_message.subject
149
- assert_equal "user_mailer", ahoy_message.utm_source
150
- assert_equal "email", ahoy_message.utm_medium
151
- assert_equal method.to_s, ahoy_message.utm_campaign
152
- end
153
- end
data/test/test_helper.rb DELETED
@@ -1,16 +0,0 @@
1
- require "bundler/setup"
2
- Bundler.require(:default)
3
- require "minitest/autorun"
4
- require "minitest/pride"
5
- require "combustion"
6
-
7
- Minitest::Test = Minitest::Unit::TestCase unless defined?(Minitest::Test)
8
-
9
- Combustion.path = "test/internal"
10
- Combustion.initialize! :all do
11
- if config.active_record.sqlite3.respond_to?(:represent_boolean_as_integer)
12
- config.active_record.sqlite3.represent_boolean_as_integer = true
13
- end
14
- end
15
-
16
- ActionMailer::Base.delivery_method = :test