mail_conf_test.rb
1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require File.dirname(__FILE__) + '/../test_helper'
class MailConfTest < ActiveSupport::TestCase
CONFIG_FILE = '/not/existing.yml'
should 'use config/mail.yml as config' do
assert_equal RAILS_ROOT + '/config/mail.yml', MailConf.config_file
end
should 'enable if told to' do
MailConf.stubs(:config_file).returns(CONFIG_FILE)
File.expects(:exists?).with(CONFIG_FILE).returns(true)
YAML.expects(:load_file).with(CONFIG_FILE).returns({ 'enabled' => true})
assert_equal true, MailConf.enabled?
end
should 'disable if told to' do
MailConf.stubs(:config_file).returns(CONFIG_FILE)
File.expects(:exists?).with(CONFIG_FILE).returns(true)
YAML.expects(:load_file).with(CONFIG_FILE).returns({ 'enabled' => false })
assert_equal false, MailConf.enabled?
end
should 'disable if config file not present' do
MailConf.stubs(:config_file).returns(CONFIG_FILE)
File.expects(:exists?).with(CONFIG_FILE).returns(false)
assert_equal false, MailConf.enabled?
end
should 'provide webmail url preference' do
MailConf.stubs(:config_file).returns(CONFIG_FILE)
File.expects(:exists?).with(CONFIG_FILE).returns(true)
YAML.expects(:load_file).with(CONFIG_FILE).returns({ 'enabled' => false, 'webmail_url' => 'http://some.url/webmail/%s/%s' })
assert_equal 'http://some.url/webmail/login/example.com', MailConf.webmail_url('login', 'example.com')
end
end