diff --git a/app/controllers/mail_handler_controller.rb b/app/controllers/mail_handler_controller.rb index 11cf400..53d37ae 100644 --- a/app/controllers/mail_handler_controller.rb +++ b/app/controllers/mail_handler_controller.rb @@ -18,6 +18,10 @@ class MailHandlerController < ActionController::Base before_filter :check_credential + # Displays the email submission form + def new + end + # Submits an incoming email to MailHandler def index options = params.dup diff --git a/app/views/mail_handler/new.html.erb b/app/views/mail_handler/new.html.erb new file mode 100644 index 0000000..a9d0696 --- /dev/null +++ b/app/views/mail_handler/new.html.erb @@ -0,0 +1,43 @@ + + + + + + + +

Redmine Mail Handler

+ +<%= form_tag({}, :multipart => true, :action => 'post') do %> + <%= hidden_field_tag 'key', params[:key] %> + +
+ Raw Email + <%= text_area_tag 'email', '', :style => 'width:95%; height:400px;' %> +
+ +
+ Options + + + + + +
+ +
+ Issue attributes options + + + + + + + +
+ +

<%= submit_tag 'Submit Email' %>

+<% end %> + + diff --git a/config/routes.rb b/config/routes.rb index 30cb694..14321dc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -315,7 +315,9 @@ Rails.application.routes.draw do get 'projects/:id/search', :controller => 'search', :action => 'index' get 'search', :controller => 'search', :action => 'index' - match 'mail_handler', :controller => 'mail_handler', :action => 'index', :via => :post + + get 'mail_handler', :to => 'mail_handler#new' + post 'mail_handler', :to => 'mail_handler#index' match 'admin', :controller => 'admin', :action => 'index', :via => :get match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get diff --git a/test/functional/mail_handler_controller_test.rb b/test/functional/mail_handler_controller_test.rb index a966b77..465b29c 100644 --- a/test/functional/mail_handler_controller_test.rb +++ b/test/functional/mail_handler_controller_test.rb @@ -77,7 +77,6 @@ class MailHandlerControllerTest < ActionController::TestCase end def test_should_not_allow_with_wrong_key - # Disable API Setting.mail_handler_api_enabled = 1 Setting.mail_handler_api_key = 'secret' @@ -86,4 +85,12 @@ class MailHandlerControllerTest < ActionController::TestCase end assert_response 403 end + + def test_new + Setting.mail_handler_api_enabled = 1 + Setting.mail_handler_api_key = 'secret' + + get :new, :key => 'secret' + assert_response :success + end end diff --git a/test/integration/routing/mail_handler_test.rb b/test/integration/routing/mail_handler_test.rb index 13505c4..d4b3e4b 100644 --- a/test/integration/routing/mail_handler_test.rb +++ b/test/integration/routing/mail_handler_test.rb @@ -19,6 +19,7 @@ require File.expand_path('../../../test_helper', __FILE__) class RoutingMailHandlerTest < Redmine::RoutingTest def test_mail_handler + should_route 'GET /mail_handler' => 'mail_handler#new' should_route 'POST /mail_handler' => 'mail_handler#index' end end