Commit 7e25eaaaac3bee98e6376ff3031f679d7d43b085
1 parent
a837f96c
Exists in
master
and in
28 other branches
New plugin SendEmailPlugin
A plugin that allows sending e-mails via HTML forms (ActionItem2056)
Showing
22 changed files
with
541 additions
and
0 deletions
Show diff stats
plugins/send_email/controllers/send_email_plugin_admin_controller.rb
0 → 100644
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +class SendEmailPluginAdminController < PluginsController | ||
2 | + append_view_path File.join(File.dirname(__FILE__) + '/../views') | ||
3 | + | ||
4 | + def index | ||
5 | + @environment = environment | ||
6 | + if request.post? | ||
7 | + if environment.update_attributes(params[:environment]) | ||
8 | + session[:notice] = _('Configurations was saved') | ||
9 | + redirect_to :controller => 'plugins' | ||
10 | + else | ||
11 | + session[:notice] = _('Configurations could not be saved') | ||
12 | + end | ||
13 | + end | ||
14 | + end | ||
15 | + | ||
16 | +end |
plugins/send_email/controllers/send_email_plugin_base_controller.rb
0 → 100644
@@ -0,0 +1,31 @@ | @@ -0,0 +1,31 @@ | ||
1 | +module SendEmailPluginBaseController | ||
2 | + def deliver | ||
3 | + if request.post? | ||
4 | + @context_url = profile ? profile.url : {:host => environment.default_hostname, :controller => 'home'} | ||
5 | + @mail = SendEmailPlugin::Mail.new( | ||
6 | + :from => environment.contact_email, | ||
7 | + :to => params[:to], | ||
8 | + :message => params[:message], | ||
9 | + :environment => environment, | ||
10 | + :params => params.dup | ||
11 | + ) | ||
12 | + @mail.subject = params[:subject] unless params[:subject].blank? | ||
13 | + if @mail.valid? | ||
14 | + SendEmailPlugin::Sender.deliver_mail(request.referer, @context_url, @mail) | ||
15 | + if request.xhr? | ||
16 | + render :text => _('Message sent') | ||
17 | + else | ||
18 | + render :action => 'success' | ||
19 | + end | ||
20 | + else | ||
21 | + if request.xhr? | ||
22 | + render_dialog_error_messages :mail | ||
23 | + else | ||
24 | + render :action => 'fail' | ||
25 | + end | ||
26 | + end | ||
27 | + else | ||
28 | + render_access_denied | ||
29 | + end | ||
30 | + end | ||
31 | +end |
plugins/send_email/controllers/send_email_plugin_environment_controller.rb
0 → 100644
plugins/send_email/controllers/send_email_plugin_profile_controller.rb
0 → 100644
plugins/send_email/db/migrate/20110804180047_add_send_email_plugin_config_to_environment.rb
0 → 100644
@@ -0,0 +1,61 @@ | @@ -0,0 +1,61 @@ | ||
1 | +h1. SendEmailPlugin | ||
2 | + | ||
3 | +Allows to send e-mails through an e-mail form. | ||
4 | + | ||
5 | +h2. Usage | ||
6 | + | ||
7 | +* Create a HTML form using RawHTMLBlock or RawHTMLArticle that invokes the {sendemail} action | ||
8 | +* Add a "to" and "message" field and a submit button | ||
9 | +* Make sure to fill in allowed 'to' addresses in plugin settings | ||
10 | + | ||
11 | +h2. HTML form | ||
12 | + | ||
13 | +h3. Form action | ||
14 | + | ||
15 | +You should use {sendemail} macro as form action, it will be expanded as: | ||
16 | + | ||
17 | +* */profile/<identifier>/plugins/send_email/deliver* in profile context | ||
18 | +* */plugin/send_email/deliver* in environment context | ||
19 | + | ||
20 | +h3. 'Subject' field | ||
21 | + | ||
22 | +Subject of message. | ||
23 | + | ||
24 | +(default: 'New mail') | ||
25 | + | ||
26 | +h3. 'Message' field | ||
27 | + | ||
28 | +Body of message. | ||
29 | + | ||
30 | +(required) | ||
31 | + | ||
32 | +h3. 'To' field | ||
33 | + | ||
34 | +Target address. Accepts multiple addresses separated by comma. | ||
35 | + | ||
36 | +(required) | ||
37 | + | ||
38 | +h3. extra fields | ||
39 | + | ||
40 | +Each other params in HTML form will compose message body in a format "key: value" | ||
41 | + | ||
42 | +h2. Options | ||
43 | + | ||
44 | +h3. Using ajax | ||
45 | + | ||
46 | +Ajax is supported using #ajax-form as id of HTML form. | ||
47 | + | ||
48 | +Example: | ||
49 | + | ||
50 | +<pre> | ||
51 | +<form action='{sendemail}' id='ajax-form'> | ||
52 | + <input type='text' name='to'/> | ||
53 | + <input type='text' name='subject'/> | ||
54 | + <input type='text' name='message'/> | ||
55 | + <input type='subject'/> | ||
56 | +</form> | ||
57 | +</pre> | ||
58 | + | ||
59 | +h2. Info | ||
60 | + | ||
61 | +This plugin was inspired by "Foswiki SendEmailPlugin":http://foswiki.org/Extensions/SendEmailPlugin |
@@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
1 | +class SendEmailPlugin < Noosfero::Plugin | ||
2 | + | ||
3 | + def self.plugin_name | ||
4 | + "SendEmailPlugin" | ||
5 | + end | ||
6 | + | ||
7 | + def self.plugin_description | ||
8 | + _("A plugin that allows sending e-mails via HTML forms.") | ||
9 | + end | ||
10 | + | ||
11 | + def stylesheet? | ||
12 | + true | ||
13 | + end | ||
14 | + | ||
15 | + def parse_content(raw_content) | ||
16 | + if context.profile | ||
17 | + raw_content.gsub(/\{sendemail\}/, "/profile/#{context.profile.identifier}/plugins/send_email/deliver") | ||
18 | + else | ||
19 | + raw_content.gsub(/\{sendemail\}/, '/plugin/send_email/deliver') | ||
20 | + end | ||
21 | + end | ||
22 | + | ||
23 | +end |
@@ -0,0 +1,42 @@ | @@ -0,0 +1,42 @@ | ||
1 | +class SendEmailPlugin::Mail < ActiveRecord::Base #WithoutTable | ||
2 | + | ||
3 | + N_('Subject'); N_('Message'); N_('To'); N_('From') | ||
4 | + tableless :columns => [ | ||
5 | + [:from, :string], | ||
6 | + [:to, :string], | ||
7 | + [:subject, :string, _('New mail')], | ||
8 | + [:message, :string], | ||
9 | + [:params, :hash, {}], | ||
10 | + ] | ||
11 | + attr_accessor :environment | ||
12 | + | ||
13 | + validates_presence_of :environment | ||
14 | + validates_presence_of :to, :message | ||
15 | + | ||
16 | + def validate | ||
17 | + if to_as_list.any? do |value| | ||
18 | + if value !~ Noosfero::Constants::EMAIL_FORMAT | ||
19 | + self.errors.add(:to, _("%{fn} '%s' isn't a valid e-mail address") % value) | ||
20 | + end | ||
21 | + end | ||
22 | + else | ||
23 | + allowed_emails = environment ? environment.send_email_plugin_allow_to.to_s.gsub(/\s+/, '').split(/,/) : [] | ||
24 | + if to_as_list.any? do |value| | ||
25 | + if !allowed_emails.include?(value) | ||
26 | + self.errors.add(:to, _("%{fn} '%s' address is not allowed (see SendEmailPlugin config)") % value) | ||
27 | + end | ||
28 | + end | ||
29 | + end | ||
30 | + end | ||
31 | + end | ||
32 | + | ||
33 | + def params=(value = {}) | ||
34 | + [:action, :controller, :to, :message, :subject, :from].each{|k| value.delete(k)} | ||
35 | + self[:params] = value | ||
36 | + end | ||
37 | + | ||
38 | + def to_as_list | ||
39 | + to && to.split(/,/) || [] | ||
40 | + end | ||
41 | + | ||
42 | +end |
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +class SendEmailPlugin::Sender < Noosfero::Plugin::MailerBase | ||
2 | + prepend_view_path(SendEmailPlugin.root_path+'/views') | ||
3 | + | ||
4 | + def mail(referer, url, mail) | ||
5 | + recipients mail.to | ||
6 | + from mail.from | ||
7 | + subject "[#{mail.environment.name}] #{mail.subject}" | ||
8 | + body :message => mail.message, | ||
9 | + :referer => referer, | ||
10 | + :context_url => url, | ||
11 | + :params => mail.params | ||
12 | + end | ||
13 | +end |
@@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
1 | +.sendemail-plugin-message-sent { | ||
2 | + width: 100%; | ||
3 | + background-color: #F0F0F0; | ||
4 | + border: 1px solid #CFCFCF; | ||
5 | +} | ||
6 | +.sendemail-plugin-message-sent td { | ||
7 | + border: 0; | ||
8 | +} | ||
9 | +.sendemail-plugin-message-sent tr:hover, | ||
10 | +.sendemail-plugin-message-sent td:hover, | ||
11 | +.sendemail-plugin-message-sent tr:hover td { | ||
12 | + background-color: auto; | ||
13 | +} | ||
14 | +.sendemail-plugin-message-sent pre { | ||
15 | + margin: 0 auto; | ||
16 | +} | ||
17 | +.sendemail-plugin-message-sent td { | ||
18 | + vertical-align: top; | ||
19 | +} | ||
20 | +.sendemail-plugin-message-sent .value { | ||
21 | + width: 100%; | ||
22 | +} |
plugins/send_email/test/features/send_email_plugin.feature
0 → 100644
@@ -0,0 +1,41 @@ | @@ -0,0 +1,41 @@ | ||
1 | +Feature: send_email_plugin | ||
2 | + | ||
3 | + Background: | ||
4 | + Given the following users | ||
5 | + | login | name | | ||
6 | + | joaosilva | Joao Silva | | ||
7 | + And I am logged in as "joaosilva" | ||
8 | + | ||
9 | + Scenario: expand macro in article content | ||
10 | + Given plugin SendEmailPlugin is enabled on environment | ||
11 | + And the following articles | ||
12 | + | owner | name | body | | ||
13 | + | joaosilva | sample-article | URL path to {sendemail} action | | ||
14 | + When I go to /joaosilva/sample-article | ||
15 | + Then I should see "URL path to /profile/joaosilva/plugins/send_email/deliver action" | ||
16 | + | ||
17 | + Scenario: expand macro in block content | ||
18 | + Given plugin SendEmailPlugin is enabled on environment | ||
19 | + And the following blocks | ||
20 | + | owner | type | html | | ||
21 | + | joaosilva | RawHTMLBlock | URL path to {sendemail} action | | ||
22 | + When I go to Joao Silva's homepage | ||
23 | + Then I should see "URL path to /profile/joaosilva/plugins/send_email/deliver action" | ||
24 | + | ||
25 | + Scenario: as admin I can configure plugin | ||
26 | + Given I am logged in as admin | ||
27 | + When I go to the environment control panel | ||
28 | + And I follow "Enable/disable plugins" | ||
29 | + Then I should see "SendEmailPlugin" linking to "/admin/plugin/send_email" | ||
30 | + | ||
31 | + Scenario: configure plugin to allow emails to john@example.com | ||
32 | + Given I am logged in as admin | ||
33 | + And I go to the environment control panel | ||
34 | + And I follow "Enable/disable plugins" | ||
35 | + When I follow "SendEmailPlugin" | ||
36 | + Then I should not see "john@example.com" | ||
37 | + When I fill in "E-Mail addresses you want to allow to send" with "john@example.com" | ||
38 | + And I press "Save" | ||
39 | + Then I should be on /admin/plugins | ||
40 | + When I follow "SendEmailPlugin" | ||
41 | + Then I should see "john@example.com" |
plugins/send_email/test/functional/send_email_plugin_admin_controller_test.rb
0 → 100644
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | +require File.dirname(__FILE__) + '/../../controllers/send_email_plugin_admin_controller' | ||
3 | + | ||
4 | +# Re-raise errors caught by the controller. | ||
5 | +class SendEmailPluginAdminController; def rescue_action(e) raise e end; end | ||
6 | + | ||
7 | +class SendEmailPluginAdminControllerTest < Test::Unit::TestCase | ||
8 | + | ||
9 | + def setup | ||
10 | + @controller = SendEmailPluginAdminController.new | ||
11 | + @request = ActionController::TestRequest.new | ||
12 | + @response = ActionController::TestResponse.new | ||
13 | + @admin = create_user('adminplug').person | ||
14 | + @environment = @admin.environment | ||
15 | + @environment.add_admin(@admin) | ||
16 | + end | ||
17 | + | ||
18 | + should 'deny access to guests and redirect to login' do | ||
19 | + get :index | ||
20 | + assert_response :redirect | ||
21 | + assert_redirected_to :controller => 'account', :action => 'login' | ||
22 | + end | ||
23 | + | ||
24 | + should 'allow access to admin' do | ||
25 | + login_as @admin.identifier | ||
26 | + get :index | ||
27 | + assert_response :success | ||
28 | + end | ||
29 | + | ||
30 | + should 'deny access to ordinary users' do | ||
31 | + @user = create_user('normaluser').person | ||
32 | + login_as @user.identifier | ||
33 | + get :index | ||
34 | + assert_response 403 | ||
35 | + end | ||
36 | + | ||
37 | +end |
plugins/send_email/test/functional/send_email_plugin_base_controller_test.rb
0 → 100644
@@ -0,0 +1,81 @@ | @@ -0,0 +1,81 @@ | ||
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | +require File.dirname(__FILE__) + '/../../controllers/send_email_plugin_profile_controller' | ||
3 | + | ||
4 | +# Re-raise errors caught by the controller. | ||
5 | +class SendEmailPluginProfileController; def rescue_action(e) raise e end; end | ||
6 | + | ||
7 | +def run_common_tests | ||
8 | + should 'not deliver emails via GET requests' do | ||
9 | + get :deliver, @extra_args | ||
10 | + assert_response 403 # forbidden | ||
11 | + end | ||
12 | + | ||
13 | + should 'deliver emails only via POST requests' do | ||
14 | + post :deliver, @extra_args | ||
15 | + assert_response :success | ||
16 | + end | ||
17 | + | ||
18 | + should 'render fail template if could not deliver mail' do | ||
19 | + post :deliver, @extra_args | ||
20 | + assert_template 'fail' | ||
21 | + end | ||
22 | + | ||
23 | + should 'render success template after deliver mail' do | ||
24 | + SendEmailPlugin::Mail.any_instance.stubs(:valid?).returns(true) | ||
25 | + post :deliver, @extra_args.merge(:to => 'john@example.com', :message => 'Hi john') | ||
26 | + assert_template 'success' | ||
27 | + end | ||
28 | + | ||
29 | + should 'render dialog error if could not deliver mail by ajax request' do | ||
30 | + xhr :post, :deliver, @extra_args | ||
31 | + assert_template '_dialog_error_messages' | ||
32 | + end | ||
33 | + | ||
34 | + should 'render success message after deliver mail by ajax request' do | ||
35 | + SendEmailPlugin::Mail.any_instance.stubs(:valid?).returns(true) | ||
36 | + xhr :post, :deliver, @extra_args.merge(:to => 'john@example.com', :message => 'Hi john') | ||
37 | + assert_equal 'Message sent', @response.body | ||
38 | + end | ||
39 | + | ||
40 | + should 'deliver mail' do | ||
41 | + Environment.any_instance.stubs(:send_email_plugin_allow_to).returns('john@example.com') | ||
42 | + assert_difference ActionMailer::Base.deliveries, :size do | ||
43 | + post :deliver, @extra_args.merge(:to => 'john@example.com', :message => 'Hi john') | ||
44 | + end | ||
45 | + end | ||
46 | + | ||
47 | + should 'deliver mail with nondefault subject' do | ||
48 | + Environment.any_instance.stubs(:send_email_plugin_allow_to).returns('john@example.com') | ||
49 | + post :deliver, @extra_args.merge(:to => 'john@example.com', :message => 'Hi john', :subject => 'Hello john') | ||
50 | + assert_equal '[Colivre.net] Hello john', ActionMailer::Base.deliveries.first.subject | ||
51 | + end | ||
52 | +end | ||
53 | + | ||
54 | +class SendEmailPluginProfileControllerTest < Test::Unit::TestCase | ||
55 | + def setup | ||
56 | + @controller = SendEmailPluginProfileController.new | ||
57 | + @request = ActionController::TestRequest.new | ||
58 | + @response = ActionController::TestResponse.new | ||
59 | + ActionMailer::Base.delivery_method = :test | ||
60 | + ActionMailer::Base.perform_deliveries = true | ||
61 | + ActionMailer::Base.deliveries = [] | ||
62 | + community = fast_create(Community) | ||
63 | + @extra_args = {:profile => community.identifier} | ||
64 | + end | ||
65 | + | ||
66 | + run_common_tests() | ||
67 | +end | ||
68 | + | ||
69 | +class SendEmailPluginEnvironmentControllerTest < Test::Unit::TestCase | ||
70 | + def setup | ||
71 | + @controller = SendEmailPluginEnvironmentController.new | ||
72 | + @request = ActionController::TestRequest.new | ||
73 | + @response = ActionController::TestResponse.new | ||
74 | + ActionMailer::Base.delivery_method = :test | ||
75 | + ActionMailer::Base.perform_deliveries = true | ||
76 | + ActionMailer::Base.deliveries = [] | ||
77 | + @extra_args = {} | ||
78 | + end | ||
79 | + | ||
80 | + run_common_tests() | ||
81 | +end |
plugins/send_email/test/unit/send_email_plugin_mail_test.rb
0 → 100644
@@ -0,0 +1,63 @@ | @@ -0,0 +1,63 @@ | ||
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | + | ||
3 | +class SendEmailPluginMailTest < Test::Unit::TestCase | ||
4 | + | ||
5 | + def setup | ||
6 | + @environment = mock() | ||
7 | + @environment.stubs(:send_email_plugin_allow_to).returns('john@example.com, someone@example.com, someother@example.com') | ||
8 | + end | ||
9 | + | ||
10 | + should 'instance a valid object with fields to be fired in mail' do | ||
11 | + mail = SendEmailPlugin::Mail.new(:subject => 'Hi', :message => 'Hi john', :to => 'john@example.com', :environment => @environment) | ||
12 | + assert mail.valid? | ||
13 | + end | ||
14 | + | ||
15 | + should 'requires to field' do | ||
16 | + mail = SendEmailPlugin::Mail.new(:subject => 'Hi', :message => 'Hi john', :environment => @environment) | ||
17 | + assert !mail.valid? | ||
18 | + end | ||
19 | + | ||
20 | + should 'require message field' do | ||
21 | + mail = SendEmailPlugin::Mail.new(:subject => 'Hi', :to => 'john@example.com', :environment => @environment) | ||
22 | + assert !mail.valid? | ||
23 | + end | ||
24 | + | ||
25 | + should 'require environment field' do | ||
26 | + mail = SendEmailPlugin::Mail.new(:subject => 'Hi', :to => 'john@example.com', :message => 'Hi john') | ||
27 | + assert !mail.valid? | ||
28 | + end | ||
29 | + | ||
30 | + should 'have a default subject' do | ||
31 | + mail = SendEmailPlugin::Mail.new | ||
32 | + assert_equal 'New mail', mail.subject | ||
33 | + end | ||
34 | + | ||
35 | + should 'not accept invalid email address' do | ||
36 | + mail = SendEmailPlugin::Mail.new(:subject => 'Hi', :message => 'Hi john', :to => 'invalid-mail-address', :environment => @environment) | ||
37 | + assert !mail.valid? | ||
38 | + end | ||
39 | + | ||
40 | + should 'not accept email that is not in allowed address list' do | ||
41 | + mail = SendEmailPlugin::Mail.new(:subject => 'Hi', :message => 'Hi john', :to => 'unknow@example.com', :environment => @environment) | ||
42 | + assert !mail.valid? | ||
43 | + end | ||
44 | + | ||
45 | + should 'discard some keys on set params hash' do | ||
46 | + mail = SendEmailPlugin::Mail.new(:params => {:action => 1, :controller => 2, :to => 3, :message => 4, :subject => 5, :age => 6}) | ||
47 | + [:action, :controller, :to, :message, :subject].each do |k| | ||
48 | + assert !mail.params.include?(k) | ||
49 | + end | ||
50 | + assert mail.params.include?(:age) | ||
51 | + end | ||
52 | + | ||
53 | + should "accept multiple 'to' emails" do | ||
54 | + mail = SendEmailPlugin::Mail.new(:subject => 'Hi', :message => 'Hi john', :to => 'john@example.com,someother@example.com', :environment => @environment) | ||
55 | + assert mail.valid? | ||
56 | + end | ||
57 | + | ||
58 | + should "invalid if just one listed in 'to' list was not allowed" do | ||
59 | + mail = SendEmailPlugin::Mail.new(:subject => 'Hi', :message => 'Hi john', :to => 'john@example.com,notallowed@example.com,someother@example.com', :environment => @environment) | ||
60 | + assert !mail.valid? | ||
61 | + end | ||
62 | + | ||
63 | +end |
plugins/send_email/test/unit/send_email_plugin_sender_test.rb
0 → 100644
@@ -0,0 +1,35 @@ | @@ -0,0 +1,35 @@ | ||
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | + | ||
3 | +class SendEmailPluginSenderTest < Test::Unit::TestCase | ||
4 | + | ||
5 | + def setup | ||
6 | + ActionMailer::Base.delivery_method = :test | ||
7 | + ActionMailer::Base.perform_deliveries = true | ||
8 | + ActionMailer::Base.deliveries = [] | ||
9 | + @environment = mock() | ||
10 | + @environment.stubs(:contact_email).returns('noreply@localhost') | ||
11 | + @environment.stubs(:default_hostname).returns('localhost') | ||
12 | + @environment.stubs(:name).returns('Noosfero') | ||
13 | + @environment.stubs(:send_email_plugin_allow_to).returns('john@example.com, someone@example.com, someother@example.com') | ||
14 | + @mail = SendEmailPlugin::Mail.new(:subject => 'Hi', :message => 'Hi john', :to => 'john@example.com', :from => 'noreply@localhost', :environment => @environment) | ||
15 | + end | ||
16 | + | ||
17 | + should 'be able to deliver mail' do | ||
18 | + response = SendEmailPlugin::Sender.deliver_mail("http://localhost/contact", 'http//profile', @mail) | ||
19 | + assert_equal 'noreply@localhost', response.from.to_s | ||
20 | + assert_equal "[Noosfero] #{@mail.subject}", response.subject | ||
21 | + end | ||
22 | + | ||
23 | + should 'deliver mail to john@example.com' do | ||
24 | + response = SendEmailPlugin::Sender.deliver_mail("http://localhost/contact", 'http//profile', @mail) | ||
25 | + assert_equal ['john@example.com'], response.to | ||
26 | + end | ||
27 | + | ||
28 | + should 'add each key value pair to message body' do | ||
29 | + @mail.params = {:param1 => 'value1', :param2 => 'value2'} | ||
30 | + response = SendEmailPlugin::Sender.deliver_mail("http://localhost/contact", 'http//profile', @mail) | ||
31 | + assert_match /param1.+value1/m, response.body | ||
32 | + assert_match /param2.+value2/m, response.body | ||
33 | + end | ||
34 | + | ||
35 | +end |
@@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | + | ||
3 | +class SendEmailPluginTest < Test::Unit::TestCase | ||
4 | + | ||
5 | + def setup | ||
6 | + @plugin = SendEmailPlugin.new | ||
7 | + @context = mock() | ||
8 | + @plugin.context = @context | ||
9 | + end | ||
10 | + | ||
11 | + should 'return true to stylesheet?' do | ||
12 | + assert @plugin.stylesheet? | ||
13 | + end | ||
14 | + | ||
15 | + should 'have admin controller' do | ||
16 | + assert SendEmailPlugin.has_admin_url? | ||
17 | + end | ||
18 | + | ||
19 | + should 'expand macro in parse_content event' do | ||
20 | + @plugin.context.stubs(:profile).returns(nil) | ||
21 | + assert_match /plugin\/send_email\/deliver/, @plugin.parse_content("expand this macro {sendemail}") | ||
22 | + end | ||
23 | + | ||
24 | + should 'expand macro in parse_content event on profile context' do | ||
25 | + @plugin.context.stubs(:profile).returns(fast_create(Community)) | ||
26 | + assert_match /profile\/#{@plugin.context.profile.identifier}\/plugins\/send_email\/deliver/, @plugin.parse_content("expand this macro {sendemail}") | ||
27 | + end | ||
28 | + | ||
29 | +end |
plugins/send_email/views/send_email_plugin/sender/mail.rhtml
0 → 100644
plugins/send_email/views/send_email_plugin_admin/index.rhtml
0 → 100644
@@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
1 | +<h1><%= _("SendEmailPlugin's config") %></h1> | ||
2 | + | ||
3 | +<% form_for :environment, :url => {:action => 'index'}, :html => {:method => 'post'} do |f| %> | ||
4 | + <%= labelled_form_field(_("E-Mail addresses you want to allow to send"), f.text_area(:send_email_plugin_allow_to, :rows => 8)) %> | ||
5 | + <small><%= _('(list of email addresses separated by comma)') %></small> | ||
6 | + <% button_bar do %> | ||
7 | + <%= submit_button 'save', _('Save'), :cancel => {:controller => 'plugins'} %> | ||
8 | + <% end %> | ||
9 | +<% end %> |
plugins/send_email/views/send_email_plugin_base/fail.rhtml
0 → 100644
plugins/send_email/views/send_email_plugin_base/success.rhtml
0 → 100644
@@ -0,0 +1,8 @@ | @@ -0,0 +1,8 @@ | ||
1 | +<h2><%= _('Message sent') %></h2> | ||
2 | + | ||
3 | +<table class='sendemail-plugin-message-sent'> | ||
4 | + <tr><td class='label'><strong><%= _('Subject') %>:</strong></td><td class='value'><em><%=h @mail.subject %></em></td></tr> | ||
5 | + <tr><td class='label'><strong><%= _('Message') %>:</strong></td><td class='value'><pre><%=h render :file => 'send_email_plugin/sender/mail' %></pre></td></tr> | ||
6 | +</table> | ||
7 | + | ||
8 | +<p><%= button :back, _('Back'), :back %></p> |