Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/email/handler_spec.rb')
-rw-r--r--spec/lib/gitlab/email/handler_spec.rb24
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