diff options
author | Riccardo Padovani <riccardo@rpadovani.com> | 2018-04-09 09:39:03 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-04-09 09:39:03 +0000 |
commit | f68aab1945679f76a0e9a51069cdc4f41e11821d (patch) | |
tree | 6d3528666b98e5b9cea3773fb951663adbb2d09b /spec | |
parent | a2a6a5cab66c2cfec6b770d070187badfd505b62 (diff) | |
download | gitlab-ce-f68aab1945679f76a0e9a51069cdc4f41e11821d.tar.gz |
Make email handler clearer
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/email/handler_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/lib/gitlab/email/handler_spec.rb b/spec/lib/gitlab/email/handler_spec.rb index 650b01c4df4..386d73e6115 100644 --- a/spec/lib/gitlab/email/handler_spec.rb +++ b/spec/lib/gitlab/email/handler_spec.rb @@ -14,4 +14,28 @@ describe Gitlab::Email::Handler do expect(described_class.for('email', '')).to be_nil end end + + describe 'regexps are set properly' do + let(:addresses) do + %W(sent_notification_key#{Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX} sent_notification_key path/to/project+merge-request+user_email_token path/to/project+user_email_token) + end + + it 'picks each handler at least once' do + matched_handlers = addresses.map do |address| + described_class.for('email', address).class + end + + expect(matched_handlers.uniq).to match_array(Gitlab::Email::Handler::HANDLERS) + end + + it 'can pick exactly one handler for each address' do + addresses.each do |address| + matched_handlers = Gitlab::Email::Handler::HANDLERS.select do |handler| + handler.new('email', address).can_handle? + end + + expect(matched_handlers.count).to eq(1), "#{address} matches #{matched_handlers.count} handlers: #{matched_handlers}" + end + end + end end |