gitlab-mail_room 0.0.2 → 0.0.8
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.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +5 -0
- data/.gitlab/issue_templates/Release.md +7 -0
- data/.ruby-version +1 -1
- data/README.md +15 -1
- data/lib/mail_room/cli.rb +4 -2
- data/lib/mail_room/connection.rb +7 -5
- data/lib/mail_room/crash_handler.rb +5 -8
- data/lib/mail_room/mailbox.rb +3 -1
- data/lib/mail_room/mailbox_watcher.rb +6 -1
- data/lib/mail_room/version.rb +2 -2
- data/mail_room.gemspec +2 -3
- data/spec/lib/arbitration/redis_spec.rb +3 -2
- data/spec/lib/cli_spec.rb +30 -15
- data/spec/lib/configuration_spec.rb +1 -2
- data/spec/lib/connection_spec.rb +6 -14
- data/spec/lib/coordinator_spec.rb +11 -9
- data/spec/lib/crash_handler_spec.rb +10 -9
- data/spec/lib/delivery/letter_opener_spec.rb +9 -5
- data/spec/lib/delivery/logger_spec.rb +7 -9
- data/spec/lib/delivery/postback_spec.rb +11 -27
- data/spec/lib/delivery/que_spec.rb +5 -8
- data/spec/lib/mailbox_spec.rb +12 -15
- data/spec/lib/mailbox_watcher_spec.rb +5 -8
- data/spec/spec_helper.rb +0 -1
- metadata +12 -25
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 367b6c3327d94d056144113b001df4d6255ab16c6aedcfdb400b413eadd3e07e
         | 
| 4 | 
            +
              data.tar.gz: 31ca4ff3025b9fd3ee67b1bb72203d5da46c3367830623f991bcf7b064043857
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 55b4dce8b77c87a550e088344593490190975fffd13a7c6aed28316cd4524054fd209b476eae29d235413f33bbcc0b0abba1ff6eb3b1c2ba9c008dcc611ba20e
         | 
| 7 | 
            +
              data.tar.gz: d8245f80b571b7c9a6c42c9280fd5d99db4705b4b067d6baeef6cd9dd623de69b44a75d9504ddf0fab9eb5bd566e11e72caefe9674ffff33b6e673149ed8458c
         | 
    
        data/.gitlab-ci.yml
    CHANGED
    
    
| @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            # GitLab mail_room release checklist
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            - [ ] create tag in https://gitlab.com/gitlab-org/gitlab-mail_room/
         | 
| 4 | 
            +
            - [ ] publish gem from this tag to rubygems.org
         | 
| 5 | 
            +
            - [ ] update https://gitlab.com/gitlab-org/gitlab/-/blob/master/Gemfile to use the new gem version
         | 
| 6 | 
            +
            - [ ] update gitlab-org/build/CNG to build container images from the new gem (example: https://gitlab.com/gitlab-org/build/CNG/-/merge_requests/451/diffs)
         | 
| 7 | 
            +
            - [ ] to deploy the new version to gitlab.com, update gitlab-com/gl-infra/k8s-workloads/gitlab-com to pin the new mailroom container image version and assign it the [release managers](https://about.gitlab.com/community/release-managers/) (example: https://gitlab.com/gitlab-com/gl-infra/k8s-workloads/gitlab-com/-/merge_requests/236/diffs)
         | 
    
        data/.ruby-version
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            2. | 
| 1 | 
            +
            2.7.2
         | 
    
        data/README.md
    CHANGED
    
    | @@ -2,7 +2,21 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            ## Fork notice
         | 
| 4 4 |  | 
| 5 | 
            -
            mail_room contains some merged functionality that GitLab requires, so this mirror fork is to help us release custom functionality.
         | 
| 5 | 
            +
            `mail_room` contains some merged functionality that GitLab requires, so this mirror fork is to help us release custom functionality.
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            It needs to be more or less kept up to date with the original, so please feel free to incorporate changes to the upstream repo if you see them.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ### Rationale
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            This fork is required to reduce dependency on the upstream releases.
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The [original JSON structured logging PR](https://github.com/tpitale/mail_room/pull/88) was [released](https://github.com/tpitale/mail_room/commit/deb8fe63bab21c5c3003346961a815d137ff6d2d) and we [bumped the version](https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/3719) to incorporate it into [omnibus](https://gitlab.com/gitlab-org/omnibus-gitlab).
         | 
| 14 | 
            +
            It turned out that when Mailroom crashed out (which it's designed to do), the crash log [wasn't being pulled into elastic in a very useful way](https://github.com/tpitale/mail_room/commits/master) (that is, every line of the stack trace was a new event) so [another PR](https://github.com/tpitale/mail_room/pull/103) was raised.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            Rather than wait for the author (or bugging him more than once), we [opted for bias for action](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/19186#note_290758986) and made a fork of the gem.
         | 
| 17 | 
            +
            Here it is [in omnibus](https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/3960).
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            The fork is useful as we can post quick fixes to our own fork and release fixes quickly, and still contribute those fixes upstream to help others.
         | 
| 6 20 |  | 
| 7 21 | 
             
            ## README
         | 
| 8 22 |  | 
    
        data/lib/mail_room/cli.rb
    CHANGED
    
    | @@ -26,7 +26,9 @@ module MailRoom | |
| 26 26 | 
             
                    end
         | 
| 27 27 |  | 
| 28 28 | 
             
                    parser.on('--log-exit-as') do |format|
         | 
| 29 | 
            -
                       | 
| 29 | 
            +
                      # accepts 'json' and 'plain'
         | 
| 30 | 
            +
                      # 'plain' is equivalent to no format given
         | 
| 31 | 
            +
                      options[:exit_error_format] = format unless format.nil?
         | 
| 30 32 | 
             
                    end
         | 
| 31 33 |  | 
| 32 34 | 
             
                    # parser.on("-l", "--log FILE") do |path|
         | 
| @@ -55,7 +57,7 @@ module MailRoom | |
| 55 57 |  | 
| 56 58 | 
             
                  coordinator.run
         | 
| 57 59 | 
             
                rescue Exception => e # not just Errors, but includes lower-level Exceptions
         | 
| 58 | 
            -
                  CrashHandler.new( | 
| 60 | 
            +
                  CrashHandler.new.handle(e, @options[:exit_error_format])
         | 
| 59 61 | 
             
                  exit
         | 
| 60 62 | 
             
                end
         | 
| 61 63 | 
             
              end
         | 
    
        data/lib/mail_room/connection.rb
    CHANGED
    
    | @@ -27,7 +27,7 @@ module MailRoom | |
| 27 27 | 
             
                # is the imap connection closed?
         | 
| 28 28 | 
             
                # @return [Boolean]
         | 
| 29 29 | 
             
                def disconnected?
         | 
| 30 | 
            -
                   | 
| 30 | 
            +
                  imap.disconnected?
         | 
| 31 31 | 
             
                end
         | 
| 32 32 |  | 
| 33 33 | 
             
                # is the connection ready to idle?
         | 
| @@ -49,8 +49,8 @@ module MailRoom | |
| 49 49 | 
             
                    idle
         | 
| 50 50 |  | 
| 51 51 | 
             
                    process_mailbox
         | 
| 52 | 
            -
                  rescue Net::IMAP::Error, IOError
         | 
| 53 | 
            -
                    @mailbox.logger.warn({ context: @mailbox.context, action: "Disconnected. Resetting..." })
         | 
| 52 | 
            +
                  rescue Net::IMAP::Error, IOError => e
         | 
| 53 | 
            +
                    @mailbox.logger.warn({ context: @mailbox.context, action: "Disconnected. Resetting...", error: e.message })
         | 
| 54 54 | 
             
                    reset
         | 
| 55 55 | 
             
                    setup
         | 
| 56 56 | 
             
                  end
         | 
| @@ -174,10 +174,12 @@ module MailRoom | |
| 174 174 | 
             
                # @return [Array<Integer>] message ids
         | 
| 175 175 | 
             
                def new_message_ids
         | 
| 176 176 | 
             
                  # uid_search still leaves messages UNSEEN
         | 
| 177 | 
            -
                  all_unread =  | 
| 177 | 
            +
                  all_unread = imap.uid_search(@mailbox.search_command)
         | 
| 178 | 
            +
             | 
| 179 | 
            +
                  all_unread = all_unread.slice(0, @mailbox.limit_max_unread) unless @mailbox.limit_max_unread.nil? || @mailbox.limit_max_unread == 0
         | 
| 178 180 |  | 
| 179 181 | 
             
                  to_deliver = all_unread.select { |uid| @mailbox.deliver?(uid) }
         | 
| 180 | 
            -
                  @mailbox.logger.info({ context: @mailbox.context, action: "Getting new messages", unread: {count: all_unread.count, ids: all_unread}, to_be_delivered: { count: to_deliver.count, ids:  | 
| 182 | 
            +
                  @mailbox.logger.info({ context: @mailbox.context, action: "Getting new messages", unread: {count: all_unread.count, ids: all_unread}, to_be_delivered: { count: to_deliver.count, ids: to_deliver } })
         | 
| 181 183 | 
             
                  to_deliver
         | 
| 182 184 | 
             
                end
         | 
| 183 185 |  | 
| @@ -2,18 +2,15 @@ | |
| 2 2 | 
             
            module MailRoom
         | 
| 3 3 | 
             
              class CrashHandler
         | 
| 4 4 |  | 
| 5 | 
            -
                attr_reader :error, :format
         | 
| 6 | 
            -
             | 
| 7 5 | 
             
                SUPPORTED_FORMATS = %w[json none]
         | 
| 8 6 |  | 
| 9 | 
            -
                def initialize( | 
| 10 | 
            -
                  @ | 
| 11 | 
            -
                  @format = format
         | 
| 7 | 
            +
                def initialize(stream=STDOUT)
         | 
| 8 | 
            +
                  @stream = stream
         | 
| 12 9 | 
             
                end
         | 
| 13 10 |  | 
| 14 | 
            -
                def handle
         | 
| 11 | 
            +
                def handle(error, format)
         | 
| 15 12 | 
             
                  if format == 'json'
         | 
| 16 | 
            -
                    puts json
         | 
| 13 | 
            +
                    @stream.puts json(error)
         | 
| 17 14 | 
             
                    return
         | 
| 18 15 | 
             
                  end
         | 
| 19 16 |  | 
| @@ -22,7 +19,7 @@ module MailRoom | |
| 22 19 |  | 
| 23 20 | 
             
                private
         | 
| 24 21 |  | 
| 25 | 
            -
                def json
         | 
| 22 | 
            +
                def json(error)
         | 
| 26 23 | 
             
                  { time: Time.now, severity: :fatal, message: error.message, backtrace: error.backtrace }.to_json
         | 
| 27 24 | 
             
                end
         | 
| 28 25 | 
             
              end
         | 
    
        data/lib/mail_room/mailbox.rb
    CHANGED
    
    | @@ -10,6 +10,7 @@ module MailRoom | |
| 10 10 | 
             
                :port,
         | 
| 11 11 | 
             
                :ssl,
         | 
| 12 12 | 
             
                :start_tls,
         | 
| 13 | 
            +
                :limit_max_unread, #to avoid 'Error in IMAP command UID FETCH: Too long argument'
         | 
| 13 14 | 
             
                :idle_timeout,
         | 
| 14 15 | 
             
                :search_command,
         | 
| 15 16 | 
             
                :name,
         | 
| @@ -50,6 +51,7 @@ module MailRoom | |
| 50 51 | 
             
                  :port => 993,
         | 
| 51 52 | 
             
                  :ssl => true,
         | 
| 52 53 | 
             
                  :start_tls => false,
         | 
| 54 | 
            +
                  :limit_max_unread => 0,
         | 
| 53 55 | 
             
                  :idle_timeout => IMAP_IDLE_TIMEOUT,
         | 
| 54 56 | 
             
                  :delete_after_delivery => false,
         | 
| 55 57 | 
             
                  :expunge_deleted => false,
         | 
| @@ -106,7 +108,7 @@ module MailRoom | |
| 106 108 | 
             
                  body = message.attr['RFC822']
         | 
| 107 109 | 
             
                  return true unless body
         | 
| 108 110 |  | 
| 109 | 
            -
                  logger.info({context: context, uid: message.attr['UID'], action: "sending to deliverer", deliverer: delivery.class.name, byte_size:  | 
| 111 | 
            +
                  logger.info({context: context, uid: message.attr['UID'], action: "sending to deliverer", deliverer: delivery.class.name, byte_size: body.bytesize})
         | 
| 110 112 | 
             
                  delivery.deliver(body)
         | 
| 111 113 | 
             
                end
         | 
| 112 114 |  | 
| @@ -49,9 +49,14 @@ module MailRoom | |
| 49 49 | 
             
                    @connection = nil
         | 
| 50 50 | 
             
                  end
         | 
| 51 51 |  | 
| 52 | 
            +
                  @mailbox.logger.info({ context: @mailbox.context, action: "Terminating watching thread..." })
         | 
| 53 | 
            +
             | 
| 52 54 | 
             
                  if self.watching_thread
         | 
| 53 | 
            -
                    self.watching_thread.join
         | 
| 55 | 
            +
                    thr = self.watching_thread.join(60)
         | 
| 56 | 
            +
                    @mailbox.logger.info({ context: @mailbox.context, action: "Timeout waiting for watching thread" }) unless thr
         | 
| 54 57 | 
             
                  end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                  @mailbox.logger.info({ context: @mailbox.context, action: "Done with thread cleanup" })
         | 
| 55 60 | 
             
                end
         | 
| 56 61 |  | 
| 57 62 | 
             
                private
         | 
    
        data/lib/mail_room/version.rb
    CHANGED
    
    
    
        data/mail_room.gemspec
    CHANGED
    
    | @@ -18,9 +18,8 @@ Gem::Specification.new do |gem| | |
| 18 18 | 
             
              gem.require_paths = ["lib"]
         | 
| 19 19 |  | 
| 20 20 | 
             
              gem.add_development_dependency "rake"
         | 
| 21 | 
            -
              gem.add_development_dependency "rspec"
         | 
| 22 | 
            -
              gem.add_development_dependency "mocha"
         | 
| 23 | 
            -
              gem.add_development_dependency "bourne"
         | 
| 21 | 
            +
              gem.add_development_dependency "rspec", "~> 3.9"
         | 
| 22 | 
            +
              gem.add_development_dependency "mocha", "~> 1.11"
         | 
| 24 23 | 
             
              gem.add_development_dependency "simplecov"
         | 
| 25 24 |  | 
| 26 25 | 
             
              # for testing delivery methods
         | 
| @@ -5,7 +5,8 @@ describe MailRoom::Arbitration::Redis do | |
| 5 5 | 
             
              let(:mailbox) {
         | 
| 6 6 | 
             
                build_mailbox(
         | 
| 7 7 | 
             
                  arbitration_options: {
         | 
| 8 | 
            -
                    namespace: "mail_room"
         | 
| 8 | 
            +
                    namespace: "mail_room",
         | 
| 9 | 
            +
                    redis_url: ENV['REDIS_URL']
         | 
| 9 10 | 
             
                  }
         | 
| 10 11 | 
             
                )
         | 
| 11 12 | 
             
              }
         | 
| @@ -78,7 +79,7 @@ describe MailRoom::Arbitration::Redis do | |
| 78 79 |  | 
| 79 80 | 
             
              context 'redis client connection params' do
         | 
| 80 81 | 
             
                context 'when only url is present' do
         | 
| 81 | 
            -
                  let(:redis_url) {  | 
| 82 | 
            +
                  let(:redis_url) { ENV.fetch('REDIS_URL', 'redis://localhost:6379') }
         | 
| 82 83 | 
             
                  let(:mailbox) {
         | 
| 83 84 | 
             
                    build_mailbox(
         | 
| 84 85 | 
             
                      arbitration_options: {
         | 
    
        data/spec/lib/cli_spec.rb
    CHANGED
    
    | @@ -4,23 +4,35 @@ describe MailRoom::CLI do | |
| 4 4 | 
             
              let(:config_path) {File.expand_path('../fixtures/test_config.yml', File.dirname(__FILE__))}
         | 
| 5 5 | 
             
              let!(:configuration) {MailRoom::Configuration.new({:config_path => config_path})}
         | 
| 6 6 | 
             
              let(:coordinator) {stub(:run => true, :quit => true)}
         | 
| 7 | 
            +
              let(:configuration_args) { anything }
         | 
| 8 | 
            +
              let(:coordinator_args) { anything }
         | 
| 7 9 |  | 
| 8 10 | 
             
              describe '.new' do
         | 
| 9 11 | 
             
                let(:args) {["-c", "a path"]}
         | 
| 10 12 |  | 
| 11 13 | 
             
                before :each do
         | 
| 12 | 
            -
                  MailRoom::Configuration. | 
| 13 | 
            -
                  MailRoom::Coordinator.stubs(:new).returns(coordinator)
         | 
| 14 | 
            +
                  MailRoom::Configuration.expects(:new).with(configuration_args).returns(configuration)
         | 
| 15 | 
            +
                  MailRoom::Coordinator.stubs(:new).with(coordinator_args).returns(coordinator)
         | 
| 14 16 | 
             
                end
         | 
| 15 17 |  | 
| 16 | 
            -
                 | 
| 17 | 
            -
                   | 
| 18 | 
            -
             | 
| 18 | 
            +
                context 'with configuration args' do
         | 
| 19 | 
            +
                  let(:configuration_args) do
         | 
| 20 | 
            +
                    {:config_path => 'a path'}
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  it 'parses arguments into configuration' do
         | 
| 24 | 
            +
                    expect(MailRoom::CLI.new(args).configuration).to eq configuration
         | 
| 25 | 
            +
                  end
         | 
| 19 26 | 
             
                end
         | 
| 20 27 |  | 
| 21 | 
            -
                 | 
| 22 | 
            -
                   | 
| 23 | 
            -
             | 
| 28 | 
            +
                context 'with coordinator args' do
         | 
| 29 | 
            +
                  let(:coordinator_args) do
         | 
| 30 | 
            +
                    configuration.mailboxes
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                  it 'creates a new coordinator with configuration' do
         | 
| 34 | 
            +
                    expect(MailRoom::CLI.new(args).coordinator).to eq(coordinator)
         | 
| 35 | 
            +
                  end
         | 
| 24 36 | 
             
                end
         | 
| 25 37 | 
             
              end
         | 
| 26 38 |  | 
| @@ -30,30 +42,33 @@ describe MailRoom::CLI do | |
| 30 42 | 
             
                before :each do
         | 
| 31 43 | 
             
                  cli.configuration = configuration
         | 
| 32 44 | 
             
                  cli.coordinator = coordinator
         | 
| 45 | 
            +
                  cli.stubs(:exit)
         | 
| 33 46 | 
             
                end
         | 
| 34 47 |  | 
| 35 48 | 
             
                it 'starts running the coordinator' do
         | 
| 36 | 
            -
                   | 
| 49 | 
            +
                  coordinator.expects(:run)
         | 
| 37 50 |  | 
| 38 | 
            -
                   | 
| 51 | 
            +
                  cli.start
         | 
| 39 52 | 
             
                end
         | 
| 40 53 |  | 
| 41 54 | 
             
                context 'on error' do
         | 
| 42 | 
            -
                  let(: | 
| 43 | 
            -
                  let(:coordinator) {  | 
| 55 | 
            +
                  let(:error) { RuntimeError.new("oh noes!") }
         | 
| 56 | 
            +
                  let(:coordinator) { stub(run: true, quit: true) }
         | 
| 57 | 
            +
                  let(:crash_handler) { stub(handle: nil) }
         | 
| 44 58 |  | 
| 45 59 | 
             
                  before do
         | 
| 46 60 | 
             
                    cli.instance_variable_set(:@options, {exit_error_format: error_format})
         | 
| 47 | 
            -
                    coordinator.stubs(:run).raises( | 
| 61 | 
            +
                    coordinator.stubs(:run).raises(error)
         | 
| 62 | 
            +
                    MailRoom::CrashHandler.stubs(:new).returns(crash_handler)
         | 
| 48 63 | 
             
                  end
         | 
| 49 64 |  | 
| 50 65 | 
             
                  context 'json format provided' do
         | 
| 51 66 | 
             
                    let(:error_format) { 'json' }
         | 
| 52 67 |  | 
| 53 68 | 
             
                    it 'passes onto CrashHandler' do
         | 
| 54 | 
            -
                       | 
| 69 | 
            +
                      crash_handler.expects(:handle).with(error, error_format)
         | 
| 55 70 |  | 
| 56 | 
            -
                       | 
| 71 | 
            +
                      cli.start
         | 
| 57 72 | 
             
                    end
         | 
| 58 73 | 
             
                  end
         | 
| 59 74 | 
             
                end
         | 
| @@ -19,10 +19,9 @@ describe MailRoom::Configuration do | |
| 19 19 |  | 
| 20 20 | 
             
                  it 'sets mailboxes to an empty set' do
         | 
| 21 21 | 
             
                    MailRoom::Mailbox.stubs(:new)
         | 
| 22 | 
            +
                    MailRoom::Mailbox.expects(:new).never
         | 
| 22 23 |  | 
| 23 24 | 
             
                    expect(configuration.mailboxes).to eq([])
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                    expect(MailRoom::Mailbox).to have_received(:new).never
         | 
| 26 25 | 
             
                  end
         | 
| 27 26 | 
             
                end
         | 
| 28 27 | 
             
              end
         | 
    
        data/spec/lib/connection_spec.rb
    CHANGED
    
    | @@ -44,22 +44,14 @@ describe MailRoom::Connection do | |
| 44 44 | 
             
                    true
         | 
| 45 45 | 
             
                  end
         | 
| 46 46 |  | 
| 47 | 
            -
                   | 
| 48 | 
            -
             | 
| 49 | 
            -
                  imap. | 
| 50 | 
            -
                   | 
| 51 | 
            -
                  imap. | 
| 52 | 
            -
                  imap. | 
| 53 | 
            -
                  imap.stubs(:expunge)
         | 
| 47 | 
            +
                  imap.expects(:idle)
         | 
| 48 | 
            +
                  imap.stubs(:uid_search).with(mailbox.search_command).returns([], [1])
         | 
| 49 | 
            +
                  imap.expects(:uid_fetch).with([1], "RFC822").returns([new_message])
         | 
| 50 | 
            +
                  mailbox.expects(:deliver?).with(1).returns(true)
         | 
| 51 | 
            +
                  imap.expects(:store).with(8, "+FLAGS", [Net::IMAP::DELETED])
         | 
| 52 | 
            +
                  imap.expects(:expunge).once
         | 
| 54 53 |  | 
| 55 54 | 
             
                  connection.wait
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                  expect(imap).to have_received(:idle)
         | 
| 58 | 
            -
                  expect(imap).to have_received(:uid_search).with(mailbox.search_command).twice
         | 
| 59 | 
            -
                  expect(imap).to have_received(:uid_fetch).with([1], "RFC822")
         | 
| 60 | 
            -
                  expect(mailbox).to have_received(:deliver?).with(1)
         | 
| 61 | 
            -
                  expect(imap).to have_received(:store).with(8, "+FLAGS", [Net::IMAP::DELETED])
         | 
| 62 | 
            -
                  expect(imap).to have_received(:expunge).once
         | 
| 63 55 | 
             
                end
         | 
| 64 56 | 
             
              end
         | 
| 65 57 | 
             
            end
         | 
| @@ -3,14 +3,12 @@ require 'spec_helper' | |
| 3 3 | 
             
            describe MailRoom::Coordinator do
         | 
| 4 4 | 
             
              describe '#initialize' do
         | 
| 5 5 | 
             
                it 'builds a watcher for each mailbox' do
         | 
| 6 | 
            -
                  MailRoom::MailboxWatcher. | 
| 6 | 
            +
                  MailRoom::MailboxWatcher.expects(:new).with('mailbox1').returns('watcher1')
         | 
| 7 | 
            +
                  MailRoom::MailboxWatcher.expects(:new).with('mailbox2').returns('watcher2')
         | 
| 7 8 |  | 
| 8 9 | 
             
                  coordinator = MailRoom::Coordinator.new(['mailbox1', 'mailbox2'])
         | 
| 9 10 |  | 
| 10 11 | 
             
                  expect(coordinator.watchers).to eq(['watcher1', 'watcher2'])
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                  expect(MailRoom::MailboxWatcher).to have_received(:new).with('mailbox1')
         | 
| 13 | 
            -
                  expect(MailRoom::MailboxWatcher).to have_received(:new).with('mailbox2')
         | 
| 14 12 | 
             
                end
         | 
| 15 13 |  | 
| 16 14 | 
             
                it 'makes no watchers when mailboxes is empty' do
         | 
| @@ -27,24 +25,27 @@ describe MailRoom::Coordinator do | |
| 27 25 | 
             
                  MailRoom::MailboxWatcher.stubs(:new).returns(watcher)
         | 
| 28 26 | 
             
                  coordinator = MailRoom::Coordinator.new(['mailbox1'])
         | 
| 29 27 | 
             
                  coordinator.stubs(:sleep_while_running)
         | 
| 28 | 
            +
                  watcher.expects(:run)
         | 
| 29 | 
            +
                  watcher.expects(:quit)
         | 
| 30 | 
            +
             | 
| 30 31 | 
             
                  coordinator.run
         | 
| 31 | 
            -
                  expect(watcher).to have_received(:run)
         | 
| 32 | 
            -
                  expect(watcher).to have_received(:quit)
         | 
| 33 32 | 
             
                end
         | 
| 34 33 |  | 
| 35 34 | 
             
                it 'should go to sleep after running watchers' do
         | 
| 36 35 | 
             
                  coordinator = MailRoom::Coordinator.new([])
         | 
| 37 36 | 
             
                  coordinator.stubs(:running=)
         | 
| 38 37 | 
             
                  coordinator.stubs(:running?).returns(false)
         | 
| 38 | 
            +
                  coordinator.expects(:running=).with(true)
         | 
| 39 | 
            +
                  coordinator.expects(:running?)
         | 
| 40 | 
            +
             | 
| 39 41 | 
             
                  coordinator.run
         | 
| 40 | 
            -
                  expect(coordinator).to have_received(:running=).with(true)
         | 
| 41 | 
            -
                  expect(coordinator).to have_received(:running?)
         | 
| 42 42 | 
             
                end
         | 
| 43 43 |  | 
| 44 44 | 
             
                it 'should set attribute running to true' do
         | 
| 45 45 | 
             
                  coordinator = MailRoom::Coordinator.new([])
         | 
| 46 46 | 
             
                  coordinator.stubs(:sleep_while_running)
         | 
| 47 47 | 
             
                  coordinator.run
         | 
| 48 | 
            +
             | 
| 48 49 | 
             
                  expect(coordinator.running).to eq(true)
         | 
| 49 50 | 
             
                end
         | 
| 50 51 | 
             
              end
         | 
| @@ -54,8 +55,9 @@ describe MailRoom::Coordinator do | |
| 54 55 | 
             
                  watcher = stub(:quit)
         | 
| 55 56 | 
             
                  MailRoom::MailboxWatcher.stubs(:new).returns(watcher)
         | 
| 56 57 | 
             
                  coordinator = MailRoom::Coordinator.new(['mailbox1'])
         | 
| 58 | 
            +
                  watcher.expects(:quit)
         | 
| 59 | 
            +
             | 
| 57 60 | 
             
                  coordinator.quit
         | 
| 58 | 
            -
                  expect(watcher).to have_received(:quit)
         | 
| 59 61 | 
             
                end
         | 
| 60 62 | 
             
              end
         | 
| 61 63 | 
             
            end
         | 
| @@ -4,21 +4,22 @@ describe MailRoom::CrashHandler do | |
| 4 4 |  | 
| 5 5 | 
             
              let(:error_message) { "oh noes!" }
         | 
| 6 6 | 
             
              let(:error) { RuntimeError.new(error_message) }
         | 
| 7 | 
            +
              let(:stdout) { StringIO.new }
         | 
| 7 8 |  | 
| 8 9 | 
             
              describe '#handle' do
         | 
| 9 10 |  | 
| 10 | 
            -
                subject{ described_class.new(error | 
| 11 | 
            +
                subject{ described_class.new(stdout).handle(error, format) }
         | 
| 11 12 |  | 
| 12 13 | 
             
                context 'when given a json format' do
         | 
| 13 14 | 
             
                  let(:format) { 'json' }
         | 
| 14 | 
            -
                  let(:fake_json) do
         | 
| 15 | 
            -
                    { message: error_message }.to_json
         | 
| 16 | 
            -
                  end
         | 
| 17 15 |  | 
| 18 | 
            -
                  it ' | 
| 19 | 
            -
                    subject | 
| 16 | 
            +
                  it 'writes a json message to stdout' do
         | 
| 17 | 
            +
                    subject
         | 
| 18 | 
            +
                    stdout.rewind
         | 
| 19 | 
            +
                    output = stdout.read
         | 
| 20 20 |  | 
| 21 | 
            -
                    expect | 
| 21 | 
            +
                    expect(output).to end_with("\n")
         | 
| 22 | 
            +
                    expect(JSON.parse(output)['message']).to eq(error_message)
         | 
| 22 23 | 
             
                  end
         | 
| 23 24 | 
             
                end
         | 
| 24 25 |  | 
| @@ -26,7 +27,7 @@ describe MailRoom::CrashHandler do | |
| 26 27 | 
             
                  let(:format) { "" }
         | 
| 27 28 |  | 
| 28 29 | 
             
                  it 'raises an error as designed' do
         | 
| 29 | 
            -
                    expect{ subject | 
| 30 | 
            +
                    expect{ subject }.to raise_error(error.class, error_message)
         | 
| 30 31 | 
             
                  end
         | 
| 31 32 | 
             
                end
         | 
| 32 33 |  | 
| @@ -34,7 +35,7 @@ describe MailRoom::CrashHandler do | |
| 34 35 | 
             
                  let(:format) { "nonsense" }
         | 
| 35 36 |  | 
| 36 37 | 
             
                  it 'raises an error as designed' do
         | 
| 37 | 
            -
                    expect{ subject | 
| 38 | 
            +
                    expect{ subject }.to raise_error(error.class, error_message)
         | 
| 38 39 | 
             
                  end
         | 
| 39 40 | 
             
                end
         | 
| 40 41 | 
             
              end
         | 
| @@ -10,20 +10,24 @@ describe MailRoom::Delivery::LetterOpener do | |
| 10 10 | 
             
                before :each do
         | 
| 11 11 | 
             
                  Mail.stubs(:read_from_string).returns(mail)
         | 
| 12 12 | 
             
                  ::LetterOpener::DeliveryMethod.stubs(:new).returns(delivery_method)
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                  MailRoom::Delivery::LetterOpener.new(mailbox).deliver('a message')
         | 
| 15 13 | 
             
                end
         | 
| 16 14 |  | 
| 17 15 | 
             
                it 'creates a new LetterOpener::DeliveryMethod' do
         | 
| 18 | 
            -
                   | 
| 16 | 
            +
                  ::LetterOpener::DeliveryMethod.expects(:new).with(:location => '/tmp/somewhere').returns(delivery_method)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  MailRoom::Delivery::LetterOpener.new(mailbox).deliver('a message')
         | 
| 19 19 | 
             
                end
         | 
| 20 20 |  | 
| 21 21 | 
             
                it 'parses the message string with Mail' do
         | 
| 22 | 
            -
                   | 
| 22 | 
            +
                  ::Mail.expects(:read_from_string).with('a message')
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  MailRoom::Delivery::LetterOpener.new(mailbox).deliver('a message')
         | 
| 23 25 | 
             
                end
         | 
| 24 26 |  | 
| 25 27 | 
             
                it 'delivers the mail message' do
         | 
| 26 | 
            -
                   | 
| 28 | 
            +
                  delivery_method.expects(:deliver!).with(mail)
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  MailRoom::Delivery::LetterOpener.new(mailbox).deliver('a message')
         | 
| 27 31 | 
             
                end
         | 
| 28 32 | 
             
              end
         | 
| 29 33 | 
             
            end
         | 
| @@ -9,9 +9,9 @@ describe MailRoom::Delivery::Logger do | |
| 9 9 | 
             
                  it 'creates a new ruby logger' do
         | 
| 10 10 | 
             
                    ::Logger.stubs(:new)
         | 
| 11 11 |  | 
| 12 | 
            -
                     | 
| 12 | 
            +
                    ::Logger.expects(:new).with(STDOUT)
         | 
| 13 13 |  | 
| 14 | 
            -
                     | 
| 14 | 
            +
                    MailRoom::Delivery::Logger.new(mailbox)
         | 
| 15 15 | 
             
                  end
         | 
| 16 16 | 
             
                end
         | 
| 17 17 |  | 
| @@ -19,14 +19,12 @@ describe MailRoom::Delivery::Logger do | |
| 19 19 | 
             
                  let(:mailbox) {build_mailbox(:log_path => '/var/log/mail-room.log')}
         | 
| 20 20 |  | 
| 21 21 | 
             
                  it 'creates a new file to append to' do
         | 
| 22 | 
            -
                    ::Logger.stubs(:new)
         | 
| 23 22 | 
             
                    file = stub(:sync=)
         | 
| 24 | 
            -
                    ::File.stubs(:open).returns(file)
         | 
| 25 23 |  | 
| 26 | 
            -
                     | 
| 24 | 
            +
                    File.expects(:open).with('/var/log/mail-room.log', 'a').returns(file)
         | 
| 25 | 
            +
                    ::Logger.stubs(:new).with(file)
         | 
| 27 26 |  | 
| 28 | 
            -
                     | 
| 29 | 
            -
                    expect(::Logger).to have_received(:new).with(file)
         | 
| 27 | 
            +
                    MailRoom::Delivery::Logger.new(mailbox)
         | 
| 30 28 | 
             
                  end
         | 
| 31 29 | 
             
                end
         | 
| 32 30 | 
             
              end
         | 
| @@ -38,9 +36,9 @@ describe MailRoom::Delivery::Logger do | |
| 38 36 | 
             
                  logger = stub(:info)
         | 
| 39 37 | 
             
                  ::Logger.stubs(:new).returns(logger)
         | 
| 40 38 |  | 
| 41 | 
            -
                   | 
| 39 | 
            +
                  logger.expects(:info).with('a message')
         | 
| 42 40 |  | 
| 43 | 
            -
                   | 
| 41 | 
            +
                  MailRoom::Delivery::Logger.new(mailbox).deliver('a message')
         | 
| 44 42 | 
             
                end
         | 
| 45 43 | 
             
              end
         | 
| 46 44 | 
             
            end
         | 
| @@ -18,19 +18,13 @@ describe MailRoom::Delivery::Postback do | |
| 18 18 | 
             
                    request = stub
         | 
| 19 19 | 
             
                    Faraday.stubs(:new).returns(connection)
         | 
| 20 20 |  | 
| 21 | 
            -
                    connection. | 
| 22 | 
            -
                    connection. | 
| 21 | 
            +
                    connection.expects(:token_auth).with('abcdefg')
         | 
| 22 | 
            +
                    connection.expects(:post).yields(request)
         | 
| 23 23 |  | 
| 24 | 
            -
                    request. | 
| 25 | 
            -
                    request. | 
| 24 | 
            +
                    request.expects(:url).with('http://localhost/inbox')
         | 
| 25 | 
            +
                    request.expects(:body=).with('a message')
         | 
| 26 26 |  | 
| 27 27 | 
             
                    MailRoom::Delivery::Postback.new(delivery_options).deliver('a message')
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                    expect(connection).to have_received(:token_auth).with('abcdefg')
         | 
| 30 | 
            -
                    expect(connection).to have_received(:post)
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                    expect(request).to have_received(:url).with('http://localhost/inbox')
         | 
| 33 | 
            -
                    expect(request).to have_received(:body=).with('a message')
         | 
| 34 28 | 
             
                  end
         | 
| 35 29 | 
             
                end
         | 
| 36 30 |  | 
| @@ -52,19 +46,13 @@ describe MailRoom::Delivery::Postback do | |
| 52 46 | 
             
                    request = stub
         | 
| 53 47 | 
             
                    Faraday.stubs(:new).returns(connection)
         | 
| 54 48 |  | 
| 55 | 
            -
                    connection. | 
| 56 | 
            -
                    connection. | 
| 49 | 
            +
                    connection.expects(:basic_auth).with('user1', 'password123abc')
         | 
| 50 | 
            +
                    connection.expects(:post).yields(request)
         | 
| 57 51 |  | 
| 58 | 
            -
                    request. | 
| 59 | 
            -
                    request. | 
| 52 | 
            +
                    request.expects(:url).with('http://localhost/inbox')
         | 
| 53 | 
            +
                    request.expects(:body=).with('a message')
         | 
| 60 54 |  | 
| 61 55 | 
             
                    MailRoom::Delivery::Postback.new(delivery_options).deliver('a message')
         | 
| 62 | 
            -
             | 
| 63 | 
            -
                    expect(connection).to have_received(:basic_auth).with('user1', 'password123abc')
         | 
| 64 | 
            -
                    expect(connection).to have_received(:post)
         | 
| 65 | 
            -
             | 
| 66 | 
            -
                    expect(request).to have_received(:url).with('http://localhost/inbox')
         | 
| 67 | 
            -
                    expect(request).to have_received(:body=).with('a message')
         | 
| 68 56 | 
             
                  end
         | 
| 69 57 |  | 
| 70 58 | 
             
                  context 'with content type in the delivery options' do
         | 
| @@ -86,18 +74,14 @@ describe MailRoom::Delivery::Postback do | |
| 86 74 | 
             
                      connection = stub
         | 
| 87 75 | 
             
                      request = stub
         | 
| 88 76 | 
             
                      Faraday.stubs(:new).returns(connection)
         | 
| 89 | 
            -
             | 
| 90 | 
            -
                      connection. | 
| 91 | 
            -
                      connection.stubs(:post).yields(request)
         | 
| 92 | 
            -
              
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                      connection.expects(:post).yields(request)
         | 
| 93 79 | 
             
                      request.stubs(:url)
         | 
| 94 80 | 
             
                      request.stubs(:body=)
         | 
| 95 81 | 
             
                      request.stubs(:headers).returns({})
         | 
| 82 | 
            +
                      connection.expects(:basic_auth).with('user1', 'password123abc')
         | 
| 96 83 |  | 
| 97 84 | 
             
                      MailRoom::Delivery::Postback.new(delivery_options).deliver('a message')
         | 
| 98 | 
            -
              
         | 
| 99 | 
            -
                      expect(connection).to have_received(:basic_auth).with('user1', 'password123abc')
         | 
| 100 | 
            -
                      expect(connection).to have_received(:post)
         | 
| 101 85 |  | 
| 102 86 | 
             
                      expect(request.headers['Content-Type']).to eq('text/plain')
         | 
| 103 87 | 
             
                    end
         | 
| @@ -18,20 +18,15 @@ describe MailRoom::Delivery::Que do | |
| 18 18 | 
             
                let(:options) {MailRoom::Delivery::Que::Options.new(mailbox)}
         | 
| 19 19 |  | 
| 20 20 | 
             
                it 'stores the message in que_jobs table' do
         | 
| 21 | 
            -
                  PG. | 
| 22 | 
            -
                  connection.stubs(:exec)
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                  MailRoom::Delivery::Que.new(options).deliver('email')
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                  expect(PG).to have_received(:connect).with({
         | 
| 21 | 
            +
                  PG.expects(:connect).with({
         | 
| 27 22 | 
             
                    host: 'localhost',
         | 
| 28 23 | 
             
                    port: 5432,
         | 
| 29 24 | 
             
                    dbname: 'delivery_test',
         | 
| 30 25 | 
             
                    user: 'postgres',
         | 
| 31 26 | 
             
                    password: ''
         | 
| 32 | 
            -
                  })
         | 
| 27 | 
            +
                  }).returns(connection)
         | 
| 33 28 |  | 
| 34 | 
            -
                   | 
| 29 | 
            +
                  connection.expects(:exec).with(
         | 
| 35 30 | 
             
                    "INSERT INTO que_jobs (priority, job_class, queue, args) VALUES ($1, $2, $3, $4)",
         | 
| 36 31 | 
             
                    [
         | 
| 37 32 | 
             
                      5,
         | 
| @@ -40,6 +35,8 @@ describe MailRoom::Delivery::Que do | |
| 40 35 | 
             
                      JSON.dump(['email'])
         | 
| 41 36 | 
             
                    ]
         | 
| 42 37 | 
             
                  )
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  MailRoom::Delivery::Que.new(options).deliver('email')
         | 
| 43 40 | 
             
                end
         | 
| 44 41 | 
             
              end
         | 
| 45 42 | 
             
            end
         | 
    
        data/spec/lib/mailbox_spec.rb
    CHANGED
    
    | @@ -12,9 +12,9 @@ describe MailRoom::Mailbox do | |
| 12 12 |  | 
| 13 13 | 
             
                    uid = 123
         | 
| 14 14 |  | 
| 15 | 
            -
                     | 
| 15 | 
            +
                    noop.expects(:deliver?).with(uid)
         | 
| 16 16 |  | 
| 17 | 
            -
                     | 
| 17 | 
            +
                    mailbox.deliver?(uid)
         | 
| 18 18 | 
             
                  end
         | 
| 19 19 | 
             
                end
         | 
| 20 20 |  | 
| @@ -23,12 +23,10 @@ describe MailRoom::Mailbox do | |
| 23 23 | 
             
                    mailbox = build_mailbox({:arbitration_method => 'redis'})
         | 
| 24 24 | 
             
                    redis = stub(:deliver?)
         | 
| 25 25 | 
             
                    MailRoom::Arbitration['redis'].stubs(:new => redis)
         | 
| 26 | 
            -
             | 
| 27 26 | 
             
                    uid = 123
         | 
| 27 | 
            +
                    redis.expects(:deliver?).with(uid)
         | 
| 28 28 |  | 
| 29 29 | 
             
                    mailbox.deliver?(uid)
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                    expect(redis).to have_received(:deliver?).with(uid)
         | 
| 32 30 | 
             
                  end
         | 
| 33 31 | 
             
                end
         | 
| 34 32 |  | 
| @@ -38,9 +36,9 @@ describe MailRoom::Mailbox do | |
| 38 36 | 
             
                    noop = stub(:deliver)
         | 
| 39 37 | 
             
                    MailRoom::Delivery['noop'].stubs(:new => noop)
         | 
| 40 38 |  | 
| 41 | 
            -
                     | 
| 39 | 
            +
                    noop.expects(:deliver).with('a message')
         | 
| 42 40 |  | 
| 43 | 
            -
                     | 
| 41 | 
            +
                    mailbox.deliver(stub(:attr => sample_message))
         | 
| 44 42 | 
             
                  end
         | 
| 45 43 | 
             
                end
         | 
| 46 44 |  | 
| @@ -50,9 +48,9 @@ describe MailRoom::Mailbox do | |
| 50 48 | 
             
                    logger = stub(:deliver)
         | 
| 51 49 | 
             
                    MailRoom::Delivery['logger'].stubs(:new => logger)
         | 
| 52 50 |  | 
| 53 | 
            -
                     | 
| 51 | 
            +
                    logger.expects(:deliver).with('a message')
         | 
| 54 52 |  | 
| 55 | 
            -
                     | 
| 53 | 
            +
                    mailbox.deliver(stub(:attr => sample_message))
         | 
| 56 54 | 
             
                  end
         | 
| 57 55 | 
             
                end
         | 
| 58 56 |  | 
| @@ -62,9 +60,9 @@ describe MailRoom::Mailbox do | |
| 62 60 | 
             
                    postback = stub(:deliver)
         | 
| 63 61 | 
             
                    MailRoom::Delivery['postback'].stubs(:new => postback)
         | 
| 64 62 |  | 
| 65 | 
            -
                     | 
| 63 | 
            +
                    postback.expects(:deliver).with('a message')
         | 
| 66 64 |  | 
| 67 | 
            -
                     | 
| 65 | 
            +
                    mailbox.deliver(stub(:attr => sample_message))
         | 
| 68 66 | 
             
                  end
         | 
| 69 67 | 
             
                end
         | 
| 70 68 |  | 
| @@ -74,9 +72,9 @@ describe MailRoom::Mailbox do | |
| 74 72 | 
             
                    letter_opener = stub(:deliver)
         | 
| 75 73 | 
             
                    MailRoom::Delivery['letter_opener'].stubs(:new => letter_opener)
         | 
| 76 74 |  | 
| 77 | 
            -
                     | 
| 75 | 
            +
                    letter_opener.expects(:deliver).with('a message')
         | 
| 78 76 |  | 
| 79 | 
            -
                     | 
| 77 | 
            +
                    mailbox.deliver(stub(:attr => sample_message))
         | 
| 80 78 | 
             
                  end
         | 
| 81 79 | 
             
                end
         | 
| 82 80 |  | 
| @@ -85,10 +83,9 @@ describe MailRoom::Mailbox do | |
| 85 83 | 
             
                    mailbox = build_mailbox({ name: "magic mailbox", delivery_method: 'noop' })
         | 
| 86 84 | 
             
                    noop = stub(:deliver)
         | 
| 87 85 | 
             
                    MailRoom::Delivery['noop'].stubs(:new => noop)
         | 
| 86 | 
            +
                    noop.expects(:deliver).never
         | 
| 88 87 |  | 
| 89 88 | 
             
                    mailbox.deliver(stub(:attr => {'FLAGS' => [:Seen, :Recent]}))
         | 
| 90 | 
            -
             | 
| 91 | 
            -
                    expect(noop).to have_received(:deliver).never
         | 
| 92 89 | 
             
                  end
         | 
| 93 90 | 
             
                end
         | 
| 94 91 |  | 
| @@ -20,19 +20,15 @@ describe MailRoom::MailboxWatcher do | |
| 20 20 |  | 
| 21 21 | 
             
                it 'loops over wait while running' do
         | 
| 22 22 | 
             
                  connection = MailRoom::Connection.new(mailbox)
         | 
| 23 | 
            -
                  connection.stubs(:on_new_message)
         | 
| 24 | 
            -
                  connection.stubs(:wait)
         | 
| 25 23 |  | 
| 26 24 | 
             
                  MailRoom::Connection.stubs(:new).returns(connection)
         | 
| 27 25 |  | 
| 28 | 
            -
                  watcher. | 
| 26 | 
            +
                  watcher.expects(:running?).twice.returns(true, false)
         | 
| 27 | 
            +
                  connection.expects(:wait).once
         | 
| 28 | 
            +
                  connection.expects(:on_new_message).once
         | 
| 29 29 |  | 
| 30 30 | 
             
                  watcher.run
         | 
| 31 31 | 
             
                  watcher.watching_thread.join # wait for finishing run
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                  expect(watcher).to have_received(:running?).times(2)
         | 
| 34 | 
            -
                  expect(connection).to have_received(:wait).once
         | 
| 35 | 
            -
                  expect(connection).to have_received(:on_new_message).once
         | 
| 36 32 | 
             
                end
         | 
| 37 33 | 
             
              end
         | 
| 38 34 |  | 
| @@ -55,9 +51,10 @@ describe MailRoom::MailboxWatcher do | |
| 55 51 |  | 
| 56 52 | 
             
                  expect(watcher.running?).to eq(true)
         | 
| 57 53 |  | 
| 54 | 
            +
                  connection.expects(:quit)
         | 
| 55 | 
            +
             | 
| 58 56 | 
             
                  watcher.quit
         | 
| 59 57 |  | 
| 60 | 
            -
                  expect(connection).to have_received(:quit)
         | 
| 61 58 | 
             
                  expect(watcher.running?).to eq(false)
         | 
| 62 59 | 
             
                end
         | 
| 63 60 | 
             
              end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: gitlab-mail_room
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.8
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Tony Pitale
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020- | 
| 11 | 
            +
            date: 2020-12-11 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rake
         | 
| @@ -28,44 +28,30 @@ dependencies: | |
| 28 28 | 
             
              name: rspec
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 30 | 
             
                requirements:
         | 
| 31 | 
            -
                - - " | 
| 31 | 
            +
                - - "~>"
         | 
| 32 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            -
                    version: ' | 
| 33 | 
            +
                    version: '3.9'
         | 
| 34 34 | 
             
              type: :development
         | 
| 35 35 | 
             
              prerelease: false
         | 
| 36 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 37 | 
             
                requirements:
         | 
| 38 | 
            -
                - - " | 
| 38 | 
            +
                - - "~>"
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            -
                    version: ' | 
| 40 | 
            +
                    version: '3.9'
         | 
| 41 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 42 | 
             
              name: mocha
         | 
| 43 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 44 | 
             
                requirements:
         | 
| 45 | 
            -
                - - " | 
| 46 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            -
                    version: '0'
         | 
| 48 | 
            -
              type: :development
         | 
| 49 | 
            -
              prerelease: false
         | 
| 50 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            -
                requirements:
         | 
| 52 | 
            -
                - - ">="
         | 
| 53 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            -
                    version: '0'
         | 
| 55 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            -
              name: bourne
         | 
| 57 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            -
                requirements:
         | 
| 59 | 
            -
                - - ">="
         | 
| 45 | 
            +
                - - "~>"
         | 
| 60 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version: ' | 
| 47 | 
            +
                    version: '1.11'
         | 
| 62 48 | 
             
              type: :development
         | 
| 63 49 | 
             
              prerelease: false
         | 
| 64 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 51 | 
             
                requirements:
         | 
| 66 | 
            -
                - - " | 
| 52 | 
            +
                - - "~>"
         | 
| 67 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            -
                    version: ' | 
| 54 | 
            +
                    version: '1.11'
         | 
| 69 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 56 | 
             
              name: simplecov
         | 
| 71 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -188,6 +174,7 @@ extra_rdoc_files: [] | |
| 188 174 | 
             
            files:
         | 
| 189 175 | 
             
            - ".gitignore"
         | 
| 190 176 | 
             
            - ".gitlab-ci.yml"
         | 
| 177 | 
            +
            - ".gitlab/issue_templates/Release.md"
         | 
| 191 178 | 
             
            - ".ruby-version"
         | 
| 192 179 | 
             
            - ".travis.yml"
         | 
| 193 180 | 
             
            - CHANGELOG.md
         | 
| @@ -253,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 253 240 | 
             
                - !ruby/object:Gem::Version
         | 
| 254 241 | 
             
                  version: '0'
         | 
| 255 242 | 
             
            requirements: []
         | 
| 256 | 
            -
            rubygems_version: 3.1. | 
| 243 | 
            +
            rubygems_version: 3.1.4
         | 
| 257 244 | 
             
            signing_key: 
         | 
| 258 245 | 
             
            specification_version: 4
         | 
| 259 246 | 
             
            summary: mail_room will proxy email (gmail) from IMAP to a callback URL, logger, or
         |