radiant-mailer-extension 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +137 -7
- data/app/controllers/mail_controller.rb +1 -2
- data/app/models/mail.rb +97 -16
- data/app/models/mailer.rb +22 -9
- data/config/routes.rb +3 -0
- data/db/migrate/001_revert_mailer_page_class_to_page.rb +10 -0
- data/features/datasets/mailer_page_dataset.rb +37 -0
- data/features/fixtures/attachment.txt +1 -0
- data/features/mailer.feature +23 -0
- data/features/step_definitions/email_steps.rb +73 -0
- data/features/step_definitions/mailer_steps.rb +16 -0
- data/features/step_definitions/webrat_steps.rb +107 -0
- data/features/support/env.rb +28 -0
- data/features/support/paths.rb +21 -0
- data/lib/mailer_process.rb +6 -0
- data/lib/mailer_tags.rb +71 -14
- data/lib/radiant-mailer-extension.rb +8 -0
- data/mailer_extension.rb +5 -8
- data/radiant-mailer-extension.gemspec +23 -64
- data/spec/controllers/mail_controller_spec.rb +1 -1
- data/spec/{dataset/mailer_dataset.rb → datasets/mailer_page_dataset.rb} +5 -4
- data/spec/lib/mailer_process_spec.rb +11 -11
- data/spec/lib/mailer_tags_spec.rb +120 -25
- data/spec/models/mail_spec.rb +179 -16
- data/spec/models/mailer_spec.rb +31 -1
- data/spec/spec_helper.rb +5 -0
- metadata +44 -36
- data/.gitignore +0 -5
@@ -0,0 +1 @@
|
|
1
|
+
this is the attached file
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Feature: Radiant Mailer Extension
|
2
|
+
In order to have email sending capabilities
|
3
|
+
As an user
|
4
|
+
I want to send and receive email
|
5
|
+
|
6
|
+
Scenario: Sending email
|
7
|
+
Given I go to the contact page
|
8
|
+
When I fill in "name" with "Cristi"
|
9
|
+
And I fill in "email" with "cristi.duma@aissac.ro"
|
10
|
+
And I fill in "message" with "Have you heard?"
|
11
|
+
And I fill in "attached_file" with the attachment
|
12
|
+
And I press "Send"
|
13
|
+
Then I should be on the thank you page
|
14
|
+
|
15
|
+
Scenario: Receiving email
|
16
|
+
Given the above email has been sent
|
17
|
+
Then "example@aissac.ro" should receive 1 email
|
18
|
+
When I open the email
|
19
|
+
And I should see "From the website of Whatever" in the subject
|
20
|
+
And I should see "Name: Cristi" in the email
|
21
|
+
And I should see "Email: cristi.duma@aissac.ro" in the email
|
22
|
+
And I should see "Message: Have you heard?" in the email
|
23
|
+
And I should have an attachment
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#Commonly used email steps
|
2
|
+
#
|
3
|
+
# To add your own steps make a custom_email_steps.rb
|
4
|
+
# The provided methods are:
|
5
|
+
#
|
6
|
+
# reset_mailer
|
7
|
+
# open_last_email
|
8
|
+
# visit_in_email
|
9
|
+
# unread_emails_for
|
10
|
+
# mailbox_for
|
11
|
+
# current_email
|
12
|
+
# open_email
|
13
|
+
# read_emails_for
|
14
|
+
# find_email
|
15
|
+
|
16
|
+
module EmailHelpers
|
17
|
+
def current_email_address
|
18
|
+
"example@aissac.ro" # Replace with your a way to find your current_email. e.g current_user.email
|
19
|
+
end
|
20
|
+
end
|
21
|
+
World(EmailHelpers)
|
22
|
+
|
23
|
+
# Use this step to reset the e-mail queue within a scenario.
|
24
|
+
# This is done automatically before each scenario.
|
25
|
+
Given /^(?:a clear email queue|no emails have been sent)$/ do
|
26
|
+
reset_mailer
|
27
|
+
end
|
28
|
+
|
29
|
+
# Use this step to open the most recently sent e-mail.
|
30
|
+
When /^I open the email$/ do
|
31
|
+
open_email(current_email_address)
|
32
|
+
end
|
33
|
+
|
34
|
+
When %r{^I follow "([^"]*?)" in the email$} do |link|
|
35
|
+
visit_in_email(link)
|
36
|
+
end
|
37
|
+
|
38
|
+
Then /^I should receive (an|\d+) emails?$/ do |amount|
|
39
|
+
amount = 1 if amount == "an"
|
40
|
+
unread_emails_for(current_email_address).size.should == amount.to_i
|
41
|
+
end
|
42
|
+
|
43
|
+
Then %r{^"([^"]*?)" should receive (\d+) emails?$} do |address, n|
|
44
|
+
unread_emails_for(address).size.should == n.to_i
|
45
|
+
end
|
46
|
+
|
47
|
+
Then %r{^"([^"]*?)" should have (\d+) emails?$} do |address, n|
|
48
|
+
mailbox_for(address).size.should == n.to_i
|
49
|
+
end
|
50
|
+
|
51
|
+
Then %r{^"([^"]*?)" should not receive an email$} do |address|
|
52
|
+
find_email(address).should be_nil
|
53
|
+
end
|
54
|
+
|
55
|
+
Then %r{^I should see "([^"]*?)" in the subject$} do |text|
|
56
|
+
current_email.should have_subject(Regexp.new(text))
|
57
|
+
end
|
58
|
+
|
59
|
+
Then %r{^I should see "([^"]*?)" in the email$} do |text|
|
60
|
+
current_email.body.should =~ Regexp.new(text)
|
61
|
+
end
|
62
|
+
|
63
|
+
When %r{^"([^"]*?)" opens? the email with subject "([^"]*?)"$} do |address, subject|
|
64
|
+
open_email(address, :with_subject => subject)
|
65
|
+
end
|
66
|
+
|
67
|
+
When %r{^"([^"]*?)" opens? the email with text "([^"]*?)"$} do |address, text|
|
68
|
+
open_email(address, :with_text => text)
|
69
|
+
end
|
70
|
+
|
71
|
+
When /^I click the first link in the email$/ do
|
72
|
+
click_first_link_in_email
|
73
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Given /^the above email has been sent$/ do
|
2
|
+
Given "I go to the contact page"
|
3
|
+
When "I fill in \"name\" with \"Cristi\""
|
4
|
+
When "I fill in \"email\" with \"cristi.duma@aissac.ro\""
|
5
|
+
When "I fill in \"message\" with \"Have you heard?\""
|
6
|
+
When "I fill in \"attached_file\" with the attachment"
|
7
|
+
When "I press \"Send\""
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^I fill in "([^\"]*)" with the attachment$/ do |field|
|
11
|
+
fill_in(field, :with => RAILS_ROOT + "/vendor/extensions/mailer/features/fixtures/attachment.txt")
|
12
|
+
end
|
13
|
+
|
14
|
+
Then /^I should have an attachment$/ do
|
15
|
+
current_email.attachments.size.should == 1
|
16
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
2
|
+
|
3
|
+
# Commonly used webrat steps
|
4
|
+
# http://github.com/brynary/webrat
|
5
|
+
|
6
|
+
Given /^I am on (.+)$/ do |page_name|
|
7
|
+
visit path_to(page_name)
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^I go to (.+)$/ do |page_name|
|
11
|
+
visit path_to(page_name)
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^I press "([^\"]*)"$/ do |button|
|
15
|
+
click_button(button)
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^I follow "([^\"]*)"$/ do |link|
|
19
|
+
click_link(link)
|
20
|
+
end
|
21
|
+
|
22
|
+
When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
|
23
|
+
fill_in(field, :with => value)
|
24
|
+
end
|
25
|
+
|
26
|
+
When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
|
27
|
+
select(value, :from => field)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Use this step in conjunction with Rail's datetime_select helper. For example:
|
31
|
+
# When I select "December 25, 2008 10:00" as the date and time
|
32
|
+
When /^I select "([^\"]*)" as the date and time$/ do |time|
|
33
|
+
select_datetime(time)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Use this step when using multiple datetime_select helpers on a page or
|
37
|
+
# you want to specify which datetime to select. Given the following view:
|
38
|
+
# <%= f.label :preferred %><br />
|
39
|
+
# <%= f.datetime_select :preferred %>
|
40
|
+
# <%= f.label :alternative %><br />
|
41
|
+
# <%= f.datetime_select :alternative %>
|
42
|
+
# The following steps would fill out the form:
|
43
|
+
# When I select "November 23, 2004 11:20" as the "Preferred" data and time
|
44
|
+
# And I select "November 25, 2004 10:30" as the "Alternative" data and time
|
45
|
+
When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
|
46
|
+
select_datetime(datetime, :from => datetime_label)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Use this step in conjunction with Rail's time_select helper. For example:
|
50
|
+
# When I select "2:20PM" as the time
|
51
|
+
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
|
52
|
+
# will convert the 2:20PM to 14:20 and then select it.
|
53
|
+
When /^I select "([^\"]*)" as the time$/ do |time|
|
54
|
+
select_time(time)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Use this step when using multiple time_select helpers on a page or you want to
|
58
|
+
# specify the name of the time on the form. For example:
|
59
|
+
# When I select "7:30AM" as the "Gym" time
|
60
|
+
When /^I select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
|
61
|
+
select_time(time, :from => time_label)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Use this step in conjunction with Rail's date_select helper. For example:
|
65
|
+
# When I select "February 20, 1981" as the date
|
66
|
+
When /^I select "([^\"]*)" as the date$/ do |date|
|
67
|
+
select_date(date)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Use this step when using multiple date_select helpers on one page or
|
71
|
+
# you want to specify the name of the date on the form. For example:
|
72
|
+
# When I select "April 26, 1982" as the "Date of Birth" date
|
73
|
+
When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
|
74
|
+
select_date(date, :from => date_label)
|
75
|
+
end
|
76
|
+
|
77
|
+
When /^I check "([^\"]*)"$/ do |field|
|
78
|
+
check(field)
|
79
|
+
end
|
80
|
+
|
81
|
+
When /^I uncheck "([^\"]*)"$/ do |field|
|
82
|
+
uncheck(field)
|
83
|
+
end
|
84
|
+
|
85
|
+
When /^I choose "([^\"]*)"$/ do |field|
|
86
|
+
choose(field)
|
87
|
+
end
|
88
|
+
|
89
|
+
When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field|
|
90
|
+
attach_file(field, path)
|
91
|
+
end
|
92
|
+
|
93
|
+
Then /^I should see "([^\"]*)"$/ do |text|
|
94
|
+
response.should contain(text)
|
95
|
+
end
|
96
|
+
|
97
|
+
Then /^I should not see "([^\"]*)"$/ do |text|
|
98
|
+
response.should_not contain(text)
|
99
|
+
end
|
100
|
+
|
101
|
+
Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
|
102
|
+
field_labeled(label).should be_checked
|
103
|
+
end
|
104
|
+
|
105
|
+
Then /^I should be on (.+)$/ do |page_name|
|
106
|
+
URI.parse(current_url).path.should == path_to(page_name)
|
107
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Sets up the Rails environment for Cucumber
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
|
4
|
+
|
5
|
+
require 'cucumber/rails/world'
|
6
|
+
require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
|
7
|
+
|
8
|
+
require 'webrat'
|
9
|
+
|
10
|
+
Webrat.configure do |config|
|
11
|
+
config.mode = :rails
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'spec'
|
15
|
+
require 'email_spec/cucumber'
|
16
|
+
|
17
|
+
# Comment out the next two lines if you're not using RSpec's matchers (should / should_not) in your steps.
|
18
|
+
require 'cucumber/rails/rspec'
|
19
|
+
require 'webrat/core/matchers'
|
20
|
+
|
21
|
+
Cucumber::Rails::World.class_eval do
|
22
|
+
include Dataset
|
23
|
+
datasets_directory "#{RADIANT_ROOT}/spec/datasets"
|
24
|
+
Dataset::Resolver.default = Dataset::DirectoryResolver.new("#{RADIANT_ROOT}/spec/datasets", File.dirname(__FILE__) + '/../datasets')
|
25
|
+
self.datasets_database_dump_path = "#{Rails.root}/tmp/dataset"
|
26
|
+
|
27
|
+
dataset :pages, :users, :mailer_page
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module NavigationHelpers
|
2
|
+
def path_to(page_name)
|
3
|
+
case page_name
|
4
|
+
|
5
|
+
when /the welcome page/
|
6
|
+
admin_path
|
7
|
+
when /the contact page/
|
8
|
+
'/contact'
|
9
|
+
when /the thank you page/
|
10
|
+
'/contact/thank-you'
|
11
|
+
|
12
|
+
# Add more page name => path mappings here
|
13
|
+
|
14
|
+
else
|
15
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
16
|
+
"Now, go and add a mapping in features/support/paths.rb"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
World(NavigationHelpers)
|
data/lib/mailer_process.rb
CHANGED
@@ -13,6 +13,7 @@ module MailerProcess
|
|
13
13
|
|
14
14
|
mail = Mail.new(part_page, config, request.parameters[:mailer])
|
15
15
|
self.last_mail = part_page.last_mail = mail
|
16
|
+
process_mail(mail, config)
|
16
17
|
|
17
18
|
if mail.send
|
18
19
|
response.redirect(config[:redirect_to], "302 Found") and return if config[:redirect_to]
|
@@ -25,6 +26,11 @@ module MailerProcess
|
|
25
26
|
end
|
26
27
|
|
27
28
|
private
|
29
|
+
|
30
|
+
# Hook here to do additional things, like check a CAPTCHA
|
31
|
+
def process_mail(mail, config)
|
32
|
+
end
|
33
|
+
|
28
34
|
def mailer_config_and_page
|
29
35
|
page = self
|
30
36
|
until page.part(:mailer) or (not page.parent)
|
data/lib/mailer_tags.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module MailerTags
|
2
2
|
include Radiant::Taggable
|
3
3
|
include ActionView::Helpers::DateHelper
|
4
|
+
include ActionView::Helpers::TagHelper
|
4
5
|
|
5
|
-
def
|
6
|
-
@
|
7
|
-
page =
|
6
|
+
def mailer_config(mailer_page=self)
|
7
|
+
@mailer_config ||= begin
|
8
|
+
page = mailer_page
|
8
9
|
until page.part(:mailer) or (not page.parent)
|
9
10
|
page = page.parent
|
10
11
|
end
|
@@ -15,10 +16,10 @@ module MailerTags
|
|
15
16
|
|
16
17
|
desc %{ All mailer-related tags live inside this one. }
|
17
18
|
tag "mailer" do |tag|
|
18
|
-
if Mail.valid_config?(
|
19
|
+
if Mail.valid_config?(mailer_config(tag.locals.page))
|
19
20
|
tag.expand
|
20
21
|
else
|
21
|
-
"Mailer config is
|
22
|
+
"Mailer config is invalid: #{Mail.config_error_messages(mailer_config)}"
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
@@ -37,6 +38,7 @@ module MailerTags
|
|
37
38
|
end
|
38
39
|
else
|
39
40
|
unless mail.valid?
|
41
|
+
tag.locals.error_messages = mail.errors
|
40
42
|
tag.expand
|
41
43
|
end
|
42
44
|
end
|
@@ -64,6 +66,13 @@ module MailerTags
|
|
64
66
|
|
65
67
|
desc %{Outputs the error message.}
|
66
68
|
tag "mailer:if_error:message" do |tag|
|
69
|
+
if tag.locals.error_messages
|
70
|
+
result = []
|
71
|
+
tag.locals.error_messages.each do |on, err|
|
72
|
+
result << content_tag(:li, "#{on} #{err}")
|
73
|
+
end
|
74
|
+
return content_tag(:ul, result)
|
75
|
+
end
|
67
76
|
tag.locals.error_message
|
68
77
|
end
|
69
78
|
|
@@ -76,9 +85,20 @@ module MailerTags
|
|
76
85
|
tag.attr['id'] ||= 'mailer'
|
77
86
|
results = []
|
78
87
|
action = Radiant::Config['mailer.post_to_page?'] ? tag.locals.page.url : "/pages/#{tag.locals.page.id}/mail##{tag.attr['id']}"
|
79
|
-
results << %(<form action="#{action}" method="post" #{mailer_attrs(tag)}>)
|
88
|
+
results << %(<form action="#{action}" method="post" enctype="multipart/form-data" #{mailer_attrs(tag)}>)
|
80
89
|
results << tag.expand
|
81
90
|
results << %(</form>)
|
91
|
+
results << %(
|
92
|
+
<script type="text/javascript">
|
93
|
+
function showSubmitPlaceholder()
|
94
|
+
{
|
95
|
+
var submitplaceholder = document.getElementById("submit-placeholder-part");
|
96
|
+
if (submitplaceholder != null)
|
97
|
+
{
|
98
|
+
submitplaceholder.style.display="";
|
99
|
+
}
|
100
|
+
}
|
101
|
+
</script>)
|
82
102
|
end
|
83
103
|
|
84
104
|
desc %{
|
@@ -94,10 +114,36 @@ module MailerTags
|
|
94
114
|
tag "mailer:#{type}" do |tag|
|
95
115
|
raise_error_if_name_missing "mailer:#{type}", tag.attr
|
96
116
|
value = (prior_value(tag) || tag.attr['value'])
|
97
|
-
result = [%(<input type="#{type}" value="#{value}" #{mailer_attrs(tag)}
|
117
|
+
result = [%(<input type="#{type}" value="#{value}" #{mailer_attrs(tag)} />)]
|
98
118
|
add_required(result, tag)
|
99
119
|
end
|
100
120
|
end
|
121
|
+
|
122
|
+
desc %{
|
123
|
+
Renders a submit input tag for a mailer form. Specify a 'src' to
|
124
|
+
render as an image submit input tag.}
|
125
|
+
tag "mailer:submit" do |tag|
|
126
|
+
value = tag.attr['value'] || tag.attr['name']
|
127
|
+
tag.attr.merge!("name" => "mailer-form-button")
|
128
|
+
src = tag.attr['src'] || nil
|
129
|
+
if src
|
130
|
+
result = [%(<input onclick="showSubmitPlaceholder();" type="image" src="#{src}" value="#{value}" #{mailer_attrs(tag)} />)]
|
131
|
+
else
|
132
|
+
result = [%(<input onclick="showSubmitPlaceholder();" type="submit" value="#{value}" #{mailer_attrs(tag)} />)]
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
desc %{
|
137
|
+
Renders a hidden div containing the contents of the submit_placeholder page part. The
|
138
|
+
div will be shown when a user submits a mailer form.
|
139
|
+
}
|
140
|
+
tag "mailer:submit_placeholder" do |tag|
|
141
|
+
if part(:submit_placeholder)
|
142
|
+
results = %Q(<div id="submit-placeholder-part" style="display:none">)
|
143
|
+
results << render_part(:submit_placeholder)
|
144
|
+
results << %Q(</div>)
|
145
|
+
end
|
146
|
+
end
|
101
147
|
|
102
148
|
desc %{
|
103
149
|
Renders a @<select>...</select>@ tag for a mailer form. The 'name' attribute is required.
|
@@ -145,9 +191,9 @@ module MailerTags
|
|
145
191
|
selected = prev_value ? prev_value == value : checked
|
146
192
|
|
147
193
|
if tag.locals.parent_tag_type == 'select'
|
148
|
-
%(<option value="#{value}"#{%( selected="selected") if selected} #{mailer_attrs(tag)}>#{
|
194
|
+
%(<option value="#{value}"#{%( selected="selected") if selected} #{mailer_attrs(tag)}>#{value}</option>)
|
149
195
|
elsif tag.locals.parent_tag_type == 'radiogroup'
|
150
|
-
%(<input type="radio" value="#{value}"#{%( checked="checked") if selected} #{mailer_attrs(tag)}
|
196
|
+
%(<input type="radio" value="#{value}"#{%( checked="checked") if selected} #{mailer_attrs(tag, "id" => tag.attr['name'] + value)} />)
|
151
197
|
end
|
152
198
|
end
|
153
199
|
|
@@ -217,6 +263,7 @@ module MailerTags
|
|
217
263
|
When used within mailer:get_each it defaults to getting elements within
|
218
264
|
that array.
|
219
265
|
}
|
266
|
+
|
220
267
|
tag 'mailer:get' do |tag|
|
221
268
|
name = tag.attr['name']
|
222
269
|
mail = tag.locals.page.last_mail
|
@@ -226,12 +273,18 @@ module MailerTags
|
|
226
273
|
element = tag.locals.page.last_mail.data
|
227
274
|
end
|
228
275
|
if name
|
229
|
-
|
276
|
+
if mail.data[name].is_a?(Array)
|
277
|
+
mail.data[name].map{ |d| d.respond_to?(:original_filename) ? d.original_filename : d.to_s }.to_sentence
|
278
|
+
elsif mail.data[name].respond_to?(:original_filename)
|
279
|
+
mail.data[name].original_filename
|
280
|
+
else
|
281
|
+
format_mailer_data(element, name)
|
282
|
+
end
|
230
283
|
else
|
231
284
|
element.to_hash.to_yaml.to_s
|
232
285
|
end
|
233
286
|
end
|
234
|
-
|
287
|
+
|
235
288
|
desc %{
|
236
289
|
For use within a mailer:get_each to output the index/key for each element
|
237
290
|
of the hash.
|
@@ -251,7 +304,7 @@ module MailerTags
|
|
251
304
|
mail = tag.locals.page.last_mail || tag.globals.page.last_mail
|
252
305
|
tag.expand if name && mail.data[name] && (eq.blank? || eq == mail.data[name])
|
253
306
|
end
|
254
|
-
|
307
|
+
|
255
308
|
def format_mailer_data(element, name)
|
256
309
|
data = element[name]
|
257
310
|
if Array === data
|
@@ -276,7 +329,8 @@ module MailerTags
|
|
276
329
|
|
277
330
|
def prior_value(tag, tag_name=tag.attr['name'])
|
278
331
|
if mail = tag.locals.page.last_mail
|
279
|
-
mail.data[tag_name]
|
332
|
+
h(mail.data[tag_name]) unless StringIO === mail.data[tag_name] or
|
333
|
+
Tempfile === mail.data[tag_name]
|
280
334
|
else
|
281
335
|
nil
|
282
336
|
end
|
@@ -312,6 +366,9 @@ module MailerTags
|
|
312
366
|
'width' => nil}.merge(extras)
|
313
367
|
result = attrs.collect do |k,v|
|
314
368
|
v = (tag.attr[k] || v)
|
369
|
+
if k == 'class' && tag.attr['required'].present?
|
370
|
+
v = [v, 'required', tag.attr['required']].compact.join(' ')
|
371
|
+
end
|
315
372
|
next if v.blank?
|
316
373
|
%(#{k}="#{v}")
|
317
374
|
end.reject{|e| e.blank?}
|
@@ -320,7 +377,7 @@ module MailerTags
|
|
320
377
|
end
|
321
378
|
|
322
379
|
def add_required(result, tag)
|
323
|
-
result << %(<input type="hidden" name="mailer[required][#{tag.attr['name']}]" value="#{tag.attr['required']}"
|
380
|
+
result << %(<input type="hidden" name="mailer[required][#{tag.attr['name']}]" value="#{tag.attr['required']}" />) if tag.attr['required']
|
324
381
|
result
|
325
382
|
end
|
326
383
|
|