acts_as_mailable 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.gitignore +1 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +135 -0
- data/LICENSE.txt +20 -0
- data/README.md +49 -0
- data/Rakefile +10 -0
- data/acts_as_mailable.gemspec +16 -0
- data/init.rb +1 -0
- data/lib/acts_as_mailable.rb +2 -0
- data/lib/email_template_methods.rb +32 -0
- data/lib/generators/email_template/USEGA +6 -0
- data/lib/generators/email_template/email_template_generator.rb +6 -0
- data/lib/generators/email_template/mailable_template_generator.rb +6 -0
- data/lib/generators/email_template/template_generator.rb +13 -0
- data/lib/generators/email_template/templates/create_email_templates.rb +19 -0
- data/lib/generators/email_template/templates/create_mailable_templates.rb +21 -0
- data/lib/generators/email_template/templates/email_template.rb +9 -0
- data/lib/generators/email_template/templates/mailable_template.rb +4 -0
- data/lib/mailable_methods.rb +33 -0
- data/rails/init.rb +1 -0
- data/test/acts_as_mailable_test.rb +89 -0
- data/test/models.rb +6 -0
- data/test/schema.rb +12 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1ff3332015a7ed1d1495cfa5bfde4573ce9fba2c
|
4
|
+
data.tar.gz: 2b366862795f619edd2c2efa413bc6c677f898d9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 124d16630eea130d2849f888bf082ae070804b71cb4746cd6e6e05bc148d6af2eaf7f6156307a10f649c86450514ac8b97227e0746420b9eeeb74f8b30640d2a
|
7
|
+
data.tar.gz: a7fb1d254361e16b99410832378f453d83653b86e2cef82d666af2512967d14f94fb95146064db7a0f08557c0a2a3cc97a9048ce0f6266881badf8d8ece5897f
|
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
gem "rails", "~> 4.0.0"
|
6
|
+
gem "sqlite3"
|
7
|
+
|
8
|
+
# Add dependencies to develop your gem here.
|
9
|
+
# Include everything needed to run rake, tests, features, etc.
|
10
|
+
group :development do
|
11
|
+
gem "shoulda", ">= 3.5.0"
|
12
|
+
gem "rdoc", "~> 4.0.1"
|
13
|
+
gem "bundler", ">= 1.3.5"
|
14
|
+
gem "jeweler", "~> 1.8.7"
|
15
|
+
gem "simplecov", ">= 0.7.1"
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionmailer (4.0.0)
|
5
|
+
actionpack (= 4.0.0)
|
6
|
+
mail (~> 2.5.3)
|
7
|
+
actionpack (4.0.0)
|
8
|
+
activesupport (= 4.0.0)
|
9
|
+
builder (~> 3.1.0)
|
10
|
+
erubis (~> 2.7.0)
|
11
|
+
rack (~> 1.5.2)
|
12
|
+
rack-test (~> 0.6.2)
|
13
|
+
activemodel (4.0.0)
|
14
|
+
activesupport (= 4.0.0)
|
15
|
+
builder (~> 3.1.0)
|
16
|
+
activerecord (4.0.0)
|
17
|
+
activemodel (= 4.0.0)
|
18
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
19
|
+
activesupport (= 4.0.0)
|
20
|
+
arel (~> 4.0.0)
|
21
|
+
activerecord-deprecated_finders (1.0.3)
|
22
|
+
activesupport (4.0.0)
|
23
|
+
i18n (~> 0.6, >= 0.6.4)
|
24
|
+
minitest (~> 4.2)
|
25
|
+
multi_json (~> 1.3)
|
26
|
+
thread_safe (~> 0.1)
|
27
|
+
tzinfo (~> 0.3.37)
|
28
|
+
addressable (2.3.5)
|
29
|
+
arel (4.0.0)
|
30
|
+
atomic (1.1.14)
|
31
|
+
builder (3.1.4)
|
32
|
+
erubis (2.7.0)
|
33
|
+
faraday (0.8.8)
|
34
|
+
multipart-post (~> 1.2.0)
|
35
|
+
git (1.2.6)
|
36
|
+
github_api (0.10.1)
|
37
|
+
addressable
|
38
|
+
faraday (~> 0.8.1)
|
39
|
+
hashie (>= 1.2)
|
40
|
+
multi_json (~> 1.4)
|
41
|
+
nokogiri (~> 1.5.2)
|
42
|
+
oauth2
|
43
|
+
hashie (2.0.5)
|
44
|
+
highline (1.6.19)
|
45
|
+
hike (1.2.3)
|
46
|
+
httpauth (0.2.0)
|
47
|
+
i18n (0.6.5)
|
48
|
+
jeweler (1.8.7)
|
49
|
+
builder
|
50
|
+
bundler (~> 1.0)
|
51
|
+
git (>= 1.2.5)
|
52
|
+
github_api (= 0.10.1)
|
53
|
+
highline (>= 1.6.15)
|
54
|
+
nokogiri (= 1.5.10)
|
55
|
+
rake
|
56
|
+
rdoc
|
57
|
+
json (1.8.0)
|
58
|
+
jwt (0.1.8)
|
59
|
+
multi_json (>= 1.5)
|
60
|
+
mail (2.5.4)
|
61
|
+
mime-types (~> 1.16)
|
62
|
+
treetop (~> 1.4.8)
|
63
|
+
mime-types (1.25)
|
64
|
+
minitest (4.7.5)
|
65
|
+
multi_json (1.8.0)
|
66
|
+
multi_xml (0.5.5)
|
67
|
+
multipart-post (1.2.0)
|
68
|
+
nokogiri (1.5.10)
|
69
|
+
oauth2 (0.9.2)
|
70
|
+
faraday (~> 0.8)
|
71
|
+
httpauth (~> 0.2)
|
72
|
+
jwt (~> 0.1.4)
|
73
|
+
multi_json (~> 1.0)
|
74
|
+
multi_xml (~> 0.5)
|
75
|
+
rack (~> 1.2)
|
76
|
+
polyglot (0.3.3)
|
77
|
+
rack (1.5.2)
|
78
|
+
rack-test (0.6.2)
|
79
|
+
rack (>= 1.0)
|
80
|
+
rails (4.0.0)
|
81
|
+
actionmailer (= 4.0.0)
|
82
|
+
actionpack (= 4.0.0)
|
83
|
+
activerecord (= 4.0.0)
|
84
|
+
activesupport (= 4.0.0)
|
85
|
+
bundler (>= 1.3.0, < 2.0)
|
86
|
+
railties (= 4.0.0)
|
87
|
+
sprockets-rails (~> 2.0.0)
|
88
|
+
railties (4.0.0)
|
89
|
+
actionpack (= 4.0.0)
|
90
|
+
activesupport (= 4.0.0)
|
91
|
+
rake (>= 0.8.7)
|
92
|
+
thor (>= 0.18.1, < 2.0)
|
93
|
+
rake (10.1.0)
|
94
|
+
rdoc (4.0.1)
|
95
|
+
json (~> 1.4)
|
96
|
+
shoulda (3.5.0)
|
97
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
98
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
99
|
+
shoulda-context (1.1.5)
|
100
|
+
shoulda-matchers (2.4.0)
|
101
|
+
activesupport (>= 3.0.0)
|
102
|
+
simplecov (0.7.1)
|
103
|
+
multi_json (~> 1.0)
|
104
|
+
simplecov-html (~> 0.7.1)
|
105
|
+
simplecov-html (0.7.1)
|
106
|
+
sprockets (2.10.0)
|
107
|
+
hike (~> 1.2)
|
108
|
+
multi_json (~> 1.0)
|
109
|
+
rack (~> 1.0)
|
110
|
+
tilt (~> 1.1, != 1.3.0)
|
111
|
+
sprockets-rails (2.0.0)
|
112
|
+
actionpack (>= 3.0)
|
113
|
+
activesupport (>= 3.0)
|
114
|
+
sprockets (~> 2.8)
|
115
|
+
sqlite3 (1.3.8)
|
116
|
+
thor (0.18.1)
|
117
|
+
thread_safe (0.1.3)
|
118
|
+
atomic
|
119
|
+
tilt (1.4.1)
|
120
|
+
treetop (1.4.15)
|
121
|
+
polyglot
|
122
|
+
polyglot (>= 0.3.1)
|
123
|
+
tzinfo (0.3.37)
|
124
|
+
|
125
|
+
PLATFORMS
|
126
|
+
ruby
|
127
|
+
|
128
|
+
DEPENDENCIES
|
129
|
+
bundler (>= 1.3.5)
|
130
|
+
jeweler (~> 1.8.7)
|
131
|
+
rails (~> 4.0.0)
|
132
|
+
rdoc (~> 4.0.1)
|
133
|
+
shoulda (>= 3.5.0)
|
134
|
+
simplecov (>= 0.7.1)
|
135
|
+
sqlite3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Lachlan Priest
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
[![Code Climate](https://codeclimate.com/github/lachlanp/acts_as_mailable.png)](https://codeclimate.com/github/lachlanp/acts_as_mailable)
|
2
|
+
# Acts As Mailable
|
3
|
+
|
4
|
+
Allows for email_templates to be added to multiple and different models.
|
5
|
+
|
6
|
+
## Installation :
|
7
|
+
|
8
|
+
Add the following line to your Gemfile
|
9
|
+
|
10
|
+
gem 'acts_as_mailable'
|
11
|
+
|
12
|
+
## Generator
|
13
|
+
|
14
|
+
Basic Email Templates
|
15
|
+
rails g email_template
|
16
|
+
|
17
|
+
And if you wish to keep a record of emails sent_at etc
|
18
|
+
|
19
|
+
rails g mailable_template
|
20
|
+
|
21
|
+
|
22
|
+
Then migrate your database:
|
23
|
+
|
24
|
+
rake db:migrate
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
Make your ActiveRecord model act as commentable:
|
29
|
+
|
30
|
+
class Organisation < ActiveRecord::Base
|
31
|
+
acts_as_mailable
|
32
|
+
end
|
33
|
+
|
34
|
+
Add a comment to a model instance:
|
35
|
+
|
36
|
+
mailable = Organisation.create(name: "King")
|
37
|
+
mailable.email_templates.create(name: "First template.", subject: "This is the first template.", body: "This is the body of the first template.")
|
38
|
+
|
39
|
+
Fetch email_templates for a mailable model:
|
40
|
+
|
41
|
+
organisation = Organisation.find(1)
|
42
|
+
organisation.email_templates.create(name: "First template.", subject: "This is the first template.", body: "This is the body of the first template.")
|
43
|
+
|
44
|
+
|
45
|
+
## Copyright
|
46
|
+
|
47
|
+
Copyright (c) 2013 Lachlan Priest. See LICENSE.txt for
|
48
|
+
further details.
|
49
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = %q{acts_as_mailable}
|
4
|
+
s.version = "0.0.1"
|
5
|
+
|
6
|
+
s.authors = ["Lachlan Priest"]
|
7
|
+
s.date = %q{2013-09-27}
|
8
|
+
s.description = %q{Plugin/gem that provides custom email templates and mailing functionality}
|
9
|
+
s.email = %q{lachlanpriest@gmail.com}
|
10
|
+
s.files = `git ls-files`.split("\n")
|
11
|
+
s.has_rdoc = false
|
12
|
+
s.license = 'MIT'
|
13
|
+
s.require_paths = ["lib"]
|
14
|
+
s.rubygems_version = %q{2.1.9}
|
15
|
+
s.summary = %q{Plugin/gem that provides custom email functionality}
|
16
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'rails', 'init')
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module ActsAsMailable
|
2
|
+
# including this module into your EmailTemplate model will give you finders and named scopes
|
3
|
+
# useful for working with EmailTemplates.
|
4
|
+
# The named scopes are:
|
5
|
+
# in_order: Returns email_templates in the order they were created (created_at ASC).
|
6
|
+
# recent: Returns email_templates by how recently they were created (created_at DESC).
|
7
|
+
# limit(N): Return no more than N email_templates.
|
8
|
+
module EmailTemplate
|
9
|
+
|
10
|
+
def self.included(email_template_model)
|
11
|
+
email_template_model.extend Finders
|
12
|
+
email_template_model.scope :in_order, -> { email_template_model.order('created_at ASC') }
|
13
|
+
email_template_model.scope :recent, -> { email_template_model.reorder('created_at DESC') }
|
14
|
+
end
|
15
|
+
|
16
|
+
module Finders
|
17
|
+
# Helper class method to look up all email_templates for
|
18
|
+
# mailable class name and mailable id.
|
19
|
+
def find_email_templates_for_mailable(mailable_str, mailable_id)
|
20
|
+
where(["mailable_type = ? and mailable_id = ?", mailable_str, mailable_id]).order("created_at DESC")
|
21
|
+
end
|
22
|
+
|
23
|
+
# Helper class method to look up a mailable object
|
24
|
+
# given the mailable class name and id
|
25
|
+
def find_mailable(mailable_str, mailable_id)
|
26
|
+
model = mailable_str.constantize
|
27
|
+
model.respond_to?(:find_email_templates_for) ? model.find(mailable_id) : nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
class TemplateGenerator < Rails::Generators::Base
|
4
|
+
include Rails::Generators::Migration
|
5
|
+
|
6
|
+
def self.source_root
|
7
|
+
@_acts_as_mailable_source_root ||= File.expand_path("../templates", __FILE__)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.next_migration_number(path)
|
11
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateEmailTemplates < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
##Email templates
|
4
|
+
create_table :email_templates do |t|
|
5
|
+
t.string :name
|
6
|
+
t.string :subject
|
7
|
+
t.text :body
|
8
|
+
t.references :mailable, polymorphic: true
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
add_index :email_templates, :mailable_type
|
12
|
+
add_index :email_templates, :mailable_id
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
drop_table :email_templates
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateMailableTemplates < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
|
4
|
+
## Email history
|
5
|
+
create_table :mailable_templates do |t|
|
6
|
+
t.integer :email_template_id
|
7
|
+
t.integer :author_id
|
8
|
+
t.string :recipients
|
9
|
+
# t.datetime :sent_at #uncomment if you intend to create templates before sending, ie maintenance emailing.
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index :mailable_templates, :author_id
|
14
|
+
add_index :mailable_templates, :email_template_id
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.down
|
18
|
+
drop_table :mailable_templates
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
#ActsAsMailable
|
4
|
+
module Monola
|
5
|
+
module Acts
|
6
|
+
module Mailable
|
7
|
+
|
8
|
+
def self.included(base)
|
9
|
+
base.extend ClassMethods
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def acts_as_mailable
|
14
|
+
has_many :email_templates, as: :mailable, dependent: :destroy
|
15
|
+
|
16
|
+
def self.find_email_templates_for(obj)
|
17
|
+
mailable = self.base_class.name
|
18
|
+
EmailTemplate.find_email_templates_for_mailable(mailable, obj.id)
|
19
|
+
end
|
20
|
+
|
21
|
+
def email_templates_ordered_by_submitted
|
22
|
+
EmailTemplate.find_email_templates_for_mailable(self.class.name, id).order("created_at")
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_email_template(email_template)
|
26
|
+
email_templates << email_template
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
ActiveRecord::Base.send(:include, Monola::Acts::Mailable)
|
data/rails/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'acts_as_mailable')
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'logger'
|
3
|
+
require 'pry'
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/../rails/init')
|
5
|
+
|
6
|
+
ActiveRecord::Migration.verbose = false
|
7
|
+
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
8
|
+
|
9
|
+
class ActsAsMailableTest < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def setup_mailable
|
12
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/generators/email_template/templates/create_email_templates.rb')
|
13
|
+
CreateEmailTemplates.up
|
14
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/generators/email_template/templates/create_mailable_templates.rb')
|
15
|
+
CreateMailableTemplates.up
|
16
|
+
load(File.expand_path(File.dirname(__FILE__) + '/../lib/generators/email_template/templates/email_template.rb'))
|
17
|
+
load(File.expand_path(File.dirname(__FILE__) + '/../lib/generators/email_template/templates/mailable_template.rb'))
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup_test_models
|
21
|
+
load(File.expand_path(File.dirname(__FILE__) + '/schema.rb'))
|
22
|
+
load(File.expand_path(File.dirname(__FILE__) + '/models.rb'))
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup
|
26
|
+
setup_mailable
|
27
|
+
setup_test_models
|
28
|
+
end
|
29
|
+
|
30
|
+
def teardown
|
31
|
+
ActiveRecord::Base.connection.tables.each do |table|
|
32
|
+
ActiveRecord::Base.connection.drop_table(table)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_create_email_template
|
37
|
+
organisation = Organisation.create(:name => "Organisation One")
|
38
|
+
assert_not_nil organisation.email_templates.create(:name => "First template.", :subject => "This is the first template.", body: "This is the body of the first template.").id
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_fetch_email_templates
|
42
|
+
organisation = Organisation.create(:name => "Organisation One")
|
43
|
+
organisation.email_templates.create(:name => "First template.", :subject => "This is the first template.", body: "This is the body of the first template.")
|
44
|
+
mailable = Organisation.find(1)
|
45
|
+
assert_equal 1, mailable.email_templates.length
|
46
|
+
assert_equal "First template.", mailable.email_templates.first.name
|
47
|
+
assert_equal "This is the first template.", mailable.email_templates.first.subject
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_find_email_templates_for_mailable
|
51
|
+
organisation = Organisation.create(:name => "Organisation One")
|
52
|
+
email_template = organisation.email_templates.create(:name => "First template.", :subject => "This is the first template.", body: "This is the body of the first template.")
|
53
|
+
assert_equal [email_template], EmailTemplate.find_email_templates_for_mailable(organisation.class.name, email_template.id)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_find_mailable
|
57
|
+
organisation = Organisation.create(:name => "Organisation One")
|
58
|
+
email_template = organisation.email_templates.create(:name => "First template.", :subject => "This is the first template.", body: "This is the body of the first template.")
|
59
|
+
assert_equal organisation, EmailTemplate.find_mailable(organisation.class.name, email_template.id)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_find_email_templates_for
|
63
|
+
organisation = Organisation.create(:name => "Organisation One")
|
64
|
+
email_template = organisation.email_templates.create(:name => "First template.", :subject => "This is the first template.", body: "This is the body of the first template.")
|
65
|
+
assert_equal [email_template], Organisation.find_email_templates_for(organisation)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_email_templates_ordered_by_submitted
|
69
|
+
organisation = Organisation.create(:name => "Organisation One")
|
70
|
+
email_template = organisation.email_templates.create(:name => "First template.", :subject => "This is the first template.", body: "This is the body of the first template.")
|
71
|
+
email_template2 = organisation.email_templates.create(:name => "Second template.", :subject => "This is the second template.")
|
72
|
+
assert_equal [email_template2, email_template], organisation.email_templates.recent
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_add_email_template
|
76
|
+
organisation = Organisation.create(:name => "Organisation One")
|
77
|
+
email_template = EmailTemplate.new(:name => "First template.", :subject => "This is the first template.", body: "This is the body of the first template.")
|
78
|
+
organisation.email_templates << email_template
|
79
|
+
assert_equal [email_template], organisation.email_templates
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_create_mailable_template
|
83
|
+
organisation = Organisation.create(:name => "Organisation One")
|
84
|
+
user = User.create(name: "James")
|
85
|
+
email_template = organisation.email_templates.create(:name => "First template.", :subject => "This is the first template.", body: "This is the body of the first template.")
|
86
|
+
assert_not_nil MailableTemplate.create(email_template_id: email_template.id, author_id: user.id).id
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
data/test/models.rb
ADDED
data/test/schema.rb
ADDED
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: acts_as_mailable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lachlan Priest
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Plugin/gem that provides custom email templates and mailing functionality
|
14
|
+
email: lachlanpriest@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- .document
|
20
|
+
- .gitignore
|
21
|
+
- Gemfile
|
22
|
+
- Gemfile.lock
|
23
|
+
- LICENSE.txt
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- acts_as_mailable.gemspec
|
27
|
+
- init.rb
|
28
|
+
- lib/acts_as_mailable.rb
|
29
|
+
- lib/email_template_methods.rb
|
30
|
+
- lib/generators/email_template/USEGA
|
31
|
+
- lib/generators/email_template/email_template_generator.rb
|
32
|
+
- lib/generators/email_template/mailable_template_generator.rb
|
33
|
+
- lib/generators/email_template/template_generator.rb
|
34
|
+
- lib/generators/email_template/templates/create_email_templates.rb
|
35
|
+
- lib/generators/email_template/templates/create_mailable_templates.rb
|
36
|
+
- lib/generators/email_template/templates/email_template.rb
|
37
|
+
- lib/generators/email_template/templates/mailable_template.rb
|
38
|
+
- lib/mailable_methods.rb
|
39
|
+
- rails/init.rb
|
40
|
+
- test/acts_as_mailable_test.rb
|
41
|
+
- test/models.rb
|
42
|
+
- test/schema.rb
|
43
|
+
homepage:
|
44
|
+
licenses:
|
45
|
+
- MIT
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 2.1.9
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: Plugin/gem that provides custom email functionality
|
67
|
+
test_files: []
|