email_form_generator 1.0.3 → 1.0.4
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/History.txt +9 -0
- data/README.rdoc +3 -3
- data/email_form_generator.rb +2 -2
- data/templates/config.rb +1 -1
- data/templates/config.yml +3 -3
- data/templates/controller.rb +14 -18
- data/templates/functional_test.rb +2 -19
- data/templates/mailer.rb +5 -6
- data/templates/mailer_test.rb +2 -2
- data/templates/model.rb +5 -2
- data/templates/unit_test.rb +7 -7
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 1.0.4 / 2009-07-03
|
2
|
+
* Tests updated for Rails 2.3x
|
3
|
+
* Fixed broken generator.
|
4
|
+
* Fixed horrible formatting
|
5
|
+
* Changed variables in the config file
|
6
|
+
* added the default url options to the mailer
|
7
|
+
* changed method name of mailer to be more specific so you could easily make your own changes and use the mailer the way you want it.
|
8
|
+
== 1.0.3 / 2009-05-25
|
9
|
+
* Some minor internal changes relating to templates
|
1
10
|
== 1.0.2 / 2009-02-13
|
2
11
|
* minor changes to the config file that originally was included
|
3
12
|
== 1.0.1 / 2008-05-21
|
data/README.rdoc
CHANGED
@@ -56,17 +56,17 @@ When the generator runs, it creates a configuration file called email.yml. You
|
|
56
56
|
authentication: none
|
57
57
|
username:
|
58
58
|
password:
|
59
|
-
|
59
|
+
site_admin_email: admin@yourdomain.com
|
60
60
|
production:
|
61
61
|
web_host: http://localhost:3000
|
62
62
|
email:
|
63
63
|
delivery_method: sendmail
|
64
|
-
|
64
|
+
site_admin_email: admin@yourdomain.com
|
65
65
|
test:
|
66
66
|
web_host: http://localhost:3000
|
67
67
|
email:
|
68
68
|
delivery_method: test
|
69
|
-
|
69
|
+
site_admin_email: admin@yourdomain.com
|
70
70
|
|
71
71
|
This file is read by config/initializers/email_config.rb, where it configures ActionMailer's settings. It should work fine out of the box for most environments.
|
72
72
|
|
data/email_form_generator.rb
CHANGED
@@ -60,7 +60,7 @@ class EmailFormGenerator < Rails::Generator::NamedBase
|
|
60
60
|
# mailer template
|
61
61
|
m.template(
|
62
62
|
"view_form.html.erb",
|
63
|
-
File.join('app/views', controller_class_path, file_name + "_mailer", "
|
63
|
+
File.join('app/views', controller_class_path, file_name + "_mailer", file_name + ".html.erb")
|
64
64
|
)
|
65
65
|
|
66
66
|
|
@@ -107,7 +107,7 @@ class EmailFormGenerator < Rails::Generator::NamedBase
|
|
107
107
|
protected
|
108
108
|
|
109
109
|
def ran_before?
|
110
|
-
options[:rspec] || (File.exist?('app/models/tableless.rb')
|
110
|
+
options[:rspec] || (File.exist?('app/models/tableless.rb'))
|
111
111
|
end
|
112
112
|
|
113
113
|
# Override with your own usage banner.
|
data/templates/config.rb
CHANGED
data/templates/config.yml
CHANGED
@@ -8,14 +8,14 @@ development:
|
|
8
8
|
authentication: none
|
9
9
|
username:
|
10
10
|
password:
|
11
|
-
|
11
|
+
site_admin_email: admin@yourdomain.com
|
12
12
|
production:
|
13
13
|
web_host: http://localhost:3000
|
14
14
|
email:
|
15
15
|
delivery_method: sendmail
|
16
|
-
|
16
|
+
site_admin_email: admin@yourdomain.com
|
17
17
|
test:
|
18
18
|
web_host: http://localhost:3000
|
19
19
|
email:
|
20
20
|
delivery_method: test
|
21
|
-
|
21
|
+
site_admin_email: admin@yourdomain.com
|
data/templates/controller.rb
CHANGED
@@ -1,34 +1,30 @@
|
|
1
1
|
class <%= controller_class_name %>Controller < ApplicationController
|
2
2
|
|
3
3
|
|
4
|
-
# GET /<%= table_name %>/new
|
5
|
-
# GET /<%= table_name %>/new.xml
|
6
|
-
def new
|
7
|
-
@<%= file_name %> = <%= class_name %>.new
|
8
|
-
|
9
|
-
|
10
|
-
format.
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
4
|
+
# GET /<%= table_name %>/new
|
5
|
+
# GET /<%= table_name %>/new.xml
|
6
|
+
def new
|
7
|
+
@<%= file_name %> = <%= class_name %>.new
|
8
|
+
respond_to do |format|
|
9
|
+
format.html # new.html.erb
|
10
|
+
format.xml { render :xml => @<%= file_name %> }
|
11
|
+
end
|
12
|
+
end
|
14
13
|
|
15
|
-
|
16
14
|
# POST /<%= table_name %>
|
17
15
|
# POST /<%= table_name %>.xml
|
18
16
|
def create
|
19
17
|
@<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])
|
20
|
-
|
21
|
-
|
22
|
-
if @<%= file_name %>.deliver
|
18
|
+
respond_to do |format|
|
19
|
+
if @<%= file_name %>.deliver
|
23
20
|
flash[:notice] = 'The message was sent successfully.'
|
24
21
|
format.html { render :action=>"success" }
|
25
|
-
format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> }
|
26
|
-
else
|
27
|
-
format.html { render :action => "new" }
|
22
|
+
format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> }
|
23
|
+
else
|
24
|
+
format.html { render :action => "new" }
|
28
25
|
format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
|
29
26
|
end
|
30
27
|
end
|
31
28
|
end
|
32
29
|
|
33
|
-
|
34
30
|
end
|
@@ -1,25 +1,11 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
-
require '<%= controller_file_name %>_controller'
|
3
|
-
|
4
|
-
# requires mocha gem - gem install mocha
|
5
|
-
require 'mocha'
|
6
|
-
|
7
|
-
# Re-raise errors caught by the controller.
|
8
|
-
class <%= controller_class_name %>Controller; def rescue_action(e) raise e end; end
|
9
|
-
|
10
|
-
class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
|
11
|
-
|
12
2
|
|
3
|
+
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
|
13
4
|
|
14
5
|
def setup
|
15
|
-
@controller = <%= controller_class_name %>Controller.new
|
16
|
-
@request = ActionController::TestRequest.new
|
17
|
-
@response = ActionController::TestResponse.new
|
18
|
-
|
19
6
|
ActionMailer::Base.delivery_method = :test
|
20
7
|
ActionMailer::Base.perform_deliveries = false
|
21
8
|
ActionMailer::Base.deliveries = []
|
22
|
-
|
23
9
|
end
|
24
10
|
|
25
11
|
def test_should_display_form
|
@@ -28,8 +14,8 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
|
|
28
14
|
assert_response :success
|
29
15
|
end
|
30
16
|
|
31
|
-
|
32
17
|
def test_should_show_success_when_created
|
18
|
+
<%=class_name %>.any_instance.expects(:deliver).returns(true)
|
33
19
|
post :create, {:<%= file_name %> => {} }
|
34
20
|
assert_response :success
|
35
21
|
assert_template "success"
|
@@ -37,11 +23,8 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
|
|
37
23
|
|
38
24
|
def test_should_fail_to_send_and_show_form_again
|
39
25
|
<%=class_name %>.any_instance.expects(:deliver).returns(false)
|
40
|
-
|
41
26
|
post :create
|
42
27
|
assert_response :success
|
43
28
|
assert_template "new"
|
44
29
|
end
|
45
|
-
|
46
|
-
|
47
30
|
end
|
data/templates/mailer.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
class <%= class_name %>Mailer < ActionMailer::Base
|
2
|
-
|
2
|
+
default_url_options[:host] = WEB_HOST
|
3
|
+
|
4
|
+
def <%=singular_name %>(<%= file_name %>)
|
3
5
|
setup_email(<%= file_name %>)
|
4
6
|
@subject += 'Message from the site'
|
5
|
-
@recipients =
|
6
|
-
|
7
|
+
@recipients = SITE_ADMIN_EMAIL
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
10
|
protected
|
12
11
|
def setup_email(<%= file_name %>)
|
13
12
|
@from = "ADMINEMAIL"
|
14
|
-
@subject = "[YOURSITE]
|
13
|
+
@subject = "[YOURSITE]"
|
15
14
|
@sent_on = Time.now
|
16
15
|
@body[:<%= file_name %>] = <%= file_name %>
|
17
16
|
end
|
data/templates/mailer_test.rb
CHANGED
@@ -12,14 +12,14 @@ class <%= class_name %>MailerTest < Test::Unit::TestCase
|
|
12
12
|
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def test_deliver_<%=singular_name %>
|
16
16
|
@f = <%=class_name %>.new
|
17
17
|
|
18
18
|
<% attributes.each do |attribute| %>
|
19
19
|
@f.<%=attribute.name %> = "foo"
|
20
20
|
<% end %>
|
21
21
|
|
22
|
-
<%=class_name%>Mailer::
|
22
|
+
<%=class_name%>Mailer::deliver_<%=singular_name %>(@f)
|
23
23
|
assert_equal 1, ActionMailer::Base.deliveries.length
|
24
24
|
|
25
25
|
end
|
data/templates/model.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
class <%= class_name %> < Tableless
|
2
2
|
<% for attribute in attributes -%>
|
3
|
-
<%= "column :#{attribute.name}, :#{attribute.type}" %>
|
3
|
+
<%= "column :#{attribute.name}, :#{attribute.type}" %>
|
4
4
|
<% end -%>
|
5
5
|
|
6
|
+
<% for attribute in attributes -%>
|
7
|
+
<%= "validates_presence_of :#{attribute.name}" %>
|
8
|
+
<% end -%>
|
6
9
|
|
7
10
|
def deliver
|
8
11
|
if valid?
|
9
12
|
begin
|
10
|
-
<%= class_name %>Mailer::
|
13
|
+
<%= class_name %>Mailer::deliver_<%=singular_name %>(self)
|
11
14
|
rescue
|
12
15
|
@errors.add_to_base "Your message could not be sent due to configuration issues with the server."
|
13
16
|
return false
|
data/templates/unit_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
|
-
class <%= class_name %>Test <
|
3
|
+
class <%= class_name %>Test < ActiveSupport::TestCase
|
4
4
|
|
5
5
|
def test_should_deliver_message
|
6
6
|
|
@@ -15,12 +15,12 @@ class <%= class_name %>Test < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
# modify this test in such a way as to cause the
|
17
17
|
# validations to fail, if you have any.
|
18
|
-
def test_should_not_deliver_message
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
18
|
+
# def test_should_not_deliver_message
|
19
|
+
#
|
20
|
+
# @f = <%=class_name %>.new
|
21
|
+
# assert ! @f.deliver
|
22
|
+
#
|
23
|
+
# end
|
24
24
|
|
25
25
|
|
26
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_form_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Hogan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-07-03 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|