From 50baa1fdd1be1090c0d8ae6f7346d82f07369657 Mon Sep 17 00:00:00 2001
From: Douwe Maan <douwe@gitlab.com>
Date: Fri, 21 Aug 2015 15:03:16 -0700
Subject: [PATCH] Add development section to doc.

---
 doc/reply_by_email/README.md |  4 ++--
 lib/tasks/gitlab/check.rake  | 28 ++++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/doc/reply_by_email/README.md b/doc/reply_by_email/README.md
index 1a0ce79bc5b..358e48abccc 100644
--- a/doc/reply_by_email/README.md
+++ b/doc/reply_by_email/README.md
@@ -87,13 +87,13 @@ In this example, we'll use the Gmail address `gitlab-replies@gmail.com`. If you'
     mail_room_enabled=true
     ```
 
-6. Restart GitLab
+6. Restart GitLab:
     
     ```sh
     sudo service gitlab restart
     ```
 
-7. Check if everything is configured correctly
+7. Check if everything is configured correctly:
 
     ```sh
     sudo bundle exec rake gitlab:reply_by_email:check RAILS_ENV=production
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index 3fbd429ef8d..a48e23e63a8 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -589,8 +589,13 @@ namespace :gitlab do
         check_address_formatted_correctly
         check_mail_room_config_exists
         check_imap_authentication
-        check_initd_configured_correctly
-        check_mail_room_running
+        
+        if Rails.env.production?
+          check_initd_configured_correctly
+          check_mail_room_running
+        else
+          check_foreman_configured_correctly
+        end
       else
         puts 'Reply by email is disabled in config/gitlab.yml'
       end
@@ -635,6 +640,25 @@ namespace :gitlab do
       end
     end
 
+    def check_foreman_configured_correctly
+      print "Foreman configured correctly? ... "
+
+      path = Rails.root.join("Procfile")
+
+      if File.exist?(path) && File.read(path) =~ /mail_room:/
+        puts "yes".green
+      else
+        puts "no".red
+        try_fixing_it(
+          "Enable mail_room in your Procfile."
+        )
+        for_more_information(
+          "doc/reply_by_email/README.md"
+        )
+        fix_and_rerun
+      end
+    end
+
     def check_mail_room_running
       print "MailRoom running? ... "
 
-- 
GitLab