sugoi-mail 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/sugoi_admin_controller.rb +33 -31
- data/app/models/mailinglist.rb +26 -7
- data/app/models/message.rb +12 -4
- data/app/models/sys_config.rb +51 -0
- data/app/models/user.rb +2 -2
- data/app/views/sugoi_admin/{create_mailing_list.rhtml → create_list.rhtml} +0 -0
- data/bin/sugoi-mail +5 -0
- data/db/migrate/026_create_sys_configs.rb +14 -0
- data/db/schema.rb +8 -1
- data/test/fixtures/sys_configs.yml +61 -0
- data/test/functional/mailservice_controller_test.rb +1 -1
- data/test/functional/sugoi_admin_controller_test.rb +19 -15
- data/test/unit/address_test.rb +1 -1
- data/test/unit/mailinglist_test.rb +2 -1
- data/test/unit/sys_config_test.rb +41 -0
- metadata +7 -3
@@ -19,6 +19,7 @@ class SugoiAdminController < CommandlineController
|
|
19
19
|
def error(error_text)
|
20
20
|
callername = caller[0].gsub(/.*\`(\w+)\'.*/, '\1')
|
21
21
|
@error = "#{callername}: #{error_text}"
|
22
|
+
nil
|
22
23
|
end
|
23
24
|
|
24
25
|
def message(message_text)
|
@@ -99,6 +100,8 @@ class SugoiAdminController < CommandlineController
|
|
99
100
|
user.password = password
|
100
101
|
user.password_confirmation = password_confirmation
|
101
102
|
user.description = description
|
103
|
+
user.domainadmin = false
|
104
|
+
|
102
105
|
if user.save then
|
103
106
|
message "User \"#{username}@#{domain_name}\" created successfully"
|
104
107
|
if email_address then
|
@@ -139,35 +142,37 @@ class SugoiAdminController < CommandlineController
|
|
139
142
|
|
140
143
|
alias help_list_mlclasses help_list_mailinglist_classes
|
141
144
|
|
142
|
-
def
|
143
|
-
domain_name, user_name, description = nil
|
145
|
+
def create_list mailinglist_name,
|
146
|
+
domain_name, user_name, description = nil, mailinglist_class_id = 2
|
144
147
|
|
145
148
|
mlclass = begin
|
146
149
|
MailinglistClass.find mailinglist_class_id.to_i
|
147
150
|
rescue ActiveRecord::RecordNotFound
|
148
151
|
nil
|
149
152
|
end
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
153
|
+
unless mlclass
|
154
|
+
return error("Invalid mailing list class: #{mailinglist_class_id}")
|
155
|
+
end
|
156
|
+
|
157
|
+
domain = Domain.find_by_name domain_name
|
158
|
+
unless domain
|
159
|
+
return error("Domain \"#{domain_name}\" not found.")
|
160
|
+
end
|
161
|
+
|
162
|
+
user = User.find_by_login_and_domain_id user_name, domain.id
|
163
|
+
unless user
|
164
|
+
return error("User \"#{user_name}\" not found "+
|
165
|
+
"in domain \"#{domain_name}\".")
|
166
|
+
end
|
167
|
+
|
168
|
+
ml=Mailinglist.new
|
169
|
+
ml.user = user
|
170
|
+
ml.description = description
|
171
|
+
ml.mailinglist_class = mlclass
|
172
|
+
ml.name = mailinglist_name
|
173
|
+
|
174
|
+
if ml.save then
|
175
|
+
message "Mailing list \"#{ml.address}\" created successfully."
|
171
176
|
end
|
172
177
|
end
|
173
178
|
|
@@ -175,8 +180,7 @@ class SugoiAdminController < CommandlineController
|
|
175
180
|
address=Address.find_or_create_by_address new_address
|
176
181
|
ml=Mailinglist.find_by_address(mailinglist_address)
|
177
182
|
unless ml
|
178
|
-
error
|
179
|
-
return
|
183
|
+
return error("Mailing list \"#{mailinglist_address}\" not found.")
|
180
184
|
end
|
181
185
|
ml=ml[0]
|
182
186
|
ml.addresses << address
|
@@ -195,21 +199,19 @@ class SugoiAdminController < CommandlineController
|
|
195
199
|
def unsubscribe(mailinglist_address, address_to_remove)
|
196
200
|
address = Address.find_by_address address_to_remove
|
197
201
|
unless address
|
198
|
-
error
|
199
|
-
return
|
202
|
+
return error("Address \"#{address_to_remove}\" unknown.")
|
200
203
|
end
|
201
204
|
|
202
205
|
mailinglist = Mailinglist.find_by_address mailinglist_address
|
203
206
|
unless mailinglist
|
204
|
-
error
|
205
|
-
return
|
207
|
+
return error("Mailing list \"#{mailinglist_address}\" unknown.")
|
206
208
|
end
|
207
209
|
|
208
210
|
@mailinglist = mailinglist[0]
|
209
211
|
|
210
212
|
unless @mailinglist.addresses.member? address
|
211
|
-
error
|
212
|
-
|
213
|
+
return error("Address \"#{address}\" not in " + "
|
214
|
+
mailing list \"#{mailinglist_address}\"")
|
213
215
|
end
|
214
216
|
|
215
217
|
@removed_addresses=@mailinglist.remove_addresses address
|
data/app/models/mailinglist.rb
CHANGED
@@ -86,9 +86,15 @@ class Mailinglist < ActiveRecord::Base
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def before_save
|
89
|
-
welcome_admin_message ||=
|
90
|
-
|
91
|
-
|
89
|
+
welcome_admin_message ||=
|
90
|
+
AdminMessage.find SysConfig.default_welcome_admin_message_id
|
91
|
+
confirmed_admin_message ||=
|
92
|
+
AdminMessage.find SysConfig.default_confirmed_admin_message_id
|
93
|
+
sayonara_admin_message ||=
|
94
|
+
AdminMessage.find SysConfig.default_farewell_admin_message_id
|
95
|
+
# welcome_admin_message ||= AdminMessage.find 1 # XXX MAGIC CONSTANT
|
96
|
+
# confirmed_admin_message ||= AdminMessage.find 2 # XXX MAGIC CONSTANT
|
97
|
+
# sayonara_admin_message ||= AdminMessage.find 3 # XXX MAGIC CONSTANT
|
92
98
|
end
|
93
99
|
|
94
100
|
#------------------------------------------------------------------------
|
@@ -106,9 +112,22 @@ class Mailinglist < ActiveRecord::Base
|
|
106
112
|
# rumble's mailing-list class).
|
107
113
|
#------------------------------------------------------------------------
|
108
114
|
|
109
|
-
def address
|
110
|
-
|
111
|
-
|
115
|
+
def address
|
116
|
+
name + "@" + user.domain.name
|
117
|
+
# "#{name}@#{user.domain.name}"
|
118
|
+
end
|
119
|
+
|
120
|
+
def bounceaddress
|
121
|
+
name + SysConfig.address_separator + SysConfig.bounce_suffix + "@" +
|
122
|
+
user.domain.name
|
123
|
+
# "#{name}-bounce@#{user.domain.name}" # XXX MAGIC CONSTANT XXX
|
124
|
+
end
|
125
|
+
|
126
|
+
def requestaddress
|
127
|
+
name + SysConfig.address_separator + SysConfig.request_suffix + "@" +
|
128
|
+
user.domain.name
|
129
|
+
# "#{name}-request@#{user.domain.name}" # XXX MAGIC CONSTANT XXX
|
130
|
+
end
|
112
131
|
|
113
132
|
def self.find_by_address addr
|
114
133
|
if ml = find_by_basic_address(addr) then
|
@@ -134,7 +153,7 @@ class Mailinglist < ActiveRecord::Base
|
|
134
153
|
end
|
135
154
|
|
136
155
|
def self.find_by_proxy_address addr
|
137
|
-
if matchdata=addr.match(
|
156
|
+
if matchdata=addr.match(/#{Regexp.escape(SysConfig.address_separator)}([0-9]+)\@/) then
|
138
157
|
proxy_id=matchdata[1].to_i
|
139
158
|
if ml=find_by_basic_address(addr.sub(/-[0-9]+\@/,"@")) then
|
140
159
|
begin
|
data/app/models/message.rb
CHANGED
@@ -261,8 +261,13 @@ class Message < ActiveRecord::Base
|
|
261
261
|
# else. Fix later.
|
262
262
|
#
|
263
263
|
# (This should actually be in the database somewhere, I'm thinking.)
|
264
|
-
smtpserver
|
265
|
-
smtpport
|
264
|
+
smtpserver = SysConfig.smtpserver
|
265
|
+
smtpport = SysConfig.smtpport
|
266
|
+
mysmtpname = SysConfig.mysmtpname
|
267
|
+
|
268
|
+
# smtpserver = "localhost" # XXX MAGIC CONSTANT XXX
|
269
|
+
# smtpport = 25 # XXX MAGIC CONSTANT XXX
|
270
|
+
# mysmtpname = "localhost" # XXX MAGIC CONSTNAT XXX
|
266
271
|
|
267
272
|
if smtpdetails.has_key? :smtpserver then
|
268
273
|
smtpserver = smtpdetails[:smtpserver]
|
@@ -271,8 +276,11 @@ class Message < ActiveRecord::Base
|
|
271
276
|
smtpport = smtpdetails[:smtpport] || 25
|
272
277
|
end
|
273
278
|
|
274
|
-
fromaddress =
|
275
|
-
|
279
|
+
fromaddress = mailinglist.name + SysConfig.address_separator +
|
280
|
+
SysConfig.bounce_suffix + "@" + mailinglist.user.domain.name
|
281
|
+
# XXX MAGIC CONSTANT XXX
|
282
|
+
# fromaddress = "#{mailinglist.name}-bounces@#{mailinglist.user.domain.name}"
|
283
|
+
Net::SMTP.start(smtpserver, smtpport, mysmtpname) do |smtp|
|
276
284
|
# puts "Will send email to #{addresses.inspect}"
|
277
285
|
# puts "Message id is #{id}"
|
278
286
|
smtp.send_message messagetext, fromaddress, addresses
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# The sys_config table stores the system configuration for a Sugoi-Mail
|
2
|
+
# This includes things like the mail server and the default mailing list
|
3
|
+
# class for new users.
|
4
|
+
#
|
5
|
+
# sys_config has the following data members, although you probably won't
|
6
|
+
# need to know them due to the fact that you access configuration parameters
|
7
|
+
# directly rather than by searching for them:
|
8
|
+
# +name+:: The name of the configuration parameter.
|
9
|
+
# +value+:: The value of the configuration parameter. This is
|
10
|
+
# serialized as YAML for the moment, until the YAML
|
11
|
+
# storage format starts presenting problems.
|
12
|
+
#
|
13
|
+
# To use this library, simply refer to SysConfig.parameter_name. For example,
|
14
|
+
# if the SMTP host were stored in the parameter "smtphost", you'd retrieve
|
15
|
+
# it with a simple
|
16
|
+
#
|
17
|
+
# SysConfig.smtphost
|
18
|
+
#
|
19
|
+
# and you'd set it with:
|
20
|
+
#
|
21
|
+
# SysConfig.smtphost = "localhost"
|
22
|
+
|
23
|
+
class SysConfig < ActiveRecord::Base
|
24
|
+
serialize :value
|
25
|
+
|
26
|
+
def self.method_missing meth, *args
|
27
|
+
begin
|
28
|
+
super(meth, *args)
|
29
|
+
rescue NoMethodError
|
30
|
+
config_param = meth.to_s
|
31
|
+
if config_param =~ /\=$/ then
|
32
|
+
if args.length > 1 then
|
33
|
+
raise ArgumentError, "How did you manage that?"
|
34
|
+
end
|
35
|
+
config_param.sub! /\=$/,''
|
36
|
+
conf = self.find_or_create_by_name config_param
|
37
|
+
conf.value = args[0]
|
38
|
+
if conf.save
|
39
|
+
return conf
|
40
|
+
end
|
41
|
+
else
|
42
|
+
conf = self.find_by_name config_param
|
43
|
+
unless conf
|
44
|
+
raise ActiveRecord::RecordNotFound,
|
45
|
+
"config param #{config_param} does not exist"
|
46
|
+
end
|
47
|
+
conf.value
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/app/models/user.rb
CHANGED
@@ -82,7 +82,7 @@ class User < ActiveRecord::Base
|
|
82
82
|
# @user = User.authenticate('bob', 'bobpass')
|
83
83
|
#
|
84
84
|
def self.authenticate(login, pass)
|
85
|
-
|
85
|
+
find_by_login_and_password login, sha1(pass)
|
86
86
|
end
|
87
87
|
|
88
88
|
|
@@ -109,7 +109,7 @@ class User < ActiveRecord::Base
|
|
109
109
|
ml=Mailinglist.new
|
110
110
|
ml.name=self.login
|
111
111
|
ml.user_id=self.id
|
112
|
-
ml.mailinglist_class=MailinglistClass.find 1
|
112
|
+
ml.mailinglist_class=MailinglistClass.find 1 # XXX MAGIC CONSTANT XXX
|
113
113
|
if @description then
|
114
114
|
ml.description = @description
|
115
115
|
end
|
File without changes
|
data/bin/sugoi-mail
CHANGED
@@ -6,6 +6,11 @@ class AppInstaller < RailsInstaller
|
|
6
6
|
application_name 'sugoi-mail'
|
7
7
|
support_location 'http://invio.co.jp/'
|
8
8
|
rails_version '1.1.6'
|
9
|
+
|
10
|
+
def post_install_hook
|
11
|
+
system("rake db:fixtures:load FIXTURES=mailinglist_classes,admin_messages,sys_configs RAILS_ENV=production")
|
12
|
+
system("rake db:fixtures:load FIXTURES=mailinglist_classes,admin_messages,sys_configs RAILS_ENV=development") # for the hackers
|
13
|
+
end
|
9
14
|
end
|
10
15
|
|
11
16
|
# Installer program
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateSysConfigs < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :sys_configs do |t|
|
4
|
+
t.column :name, :string
|
5
|
+
t.column :value, :string
|
6
|
+
t.column :description, :string
|
7
|
+
t.column :priority, :integer
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
drop_table :sys_configs
|
13
|
+
end
|
14
|
+
end
|
data/db/schema.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# migrations feature of ActiveRecord to incrementally modify your database, and
|
3
3
|
# then regenerate this schema definition.
|
4
4
|
|
5
|
-
ActiveRecord::Schema.define(:version =>
|
5
|
+
ActiveRecord::Schema.define(:version => 26) do
|
6
6
|
|
7
7
|
create_table "addresses", :force => true do |t|
|
8
8
|
t.column "address", :text
|
@@ -72,6 +72,13 @@ ActiveRecord::Schema.define(:version => 25) do
|
|
72
72
|
t.column "address_id", :integer, :null => false
|
73
73
|
end
|
74
74
|
|
75
|
+
create_table "sys_configs", :force => true do |t|
|
76
|
+
t.column "name", :string
|
77
|
+
t.column "value", :string
|
78
|
+
t.column "description", :string
|
79
|
+
t.column "priority", :integer
|
80
|
+
end
|
81
|
+
|
75
82
|
create_table "users", :force => true do |t|
|
76
83
|
t.column "login", :text, :null => false
|
77
84
|
t.column "password", :text, :null => false
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
+
smtpserver:
|
3
|
+
id: 1
|
4
|
+
name: smtpserver
|
5
|
+
value: localhost
|
6
|
+
description: The SMTP server to deliver mail through.
|
7
|
+
priority: 1
|
8
|
+
smtpport:
|
9
|
+
id: 2
|
10
|
+
name: smtpport
|
11
|
+
value: 25
|
12
|
+
description: The port to connect to on the SMTP server.
|
13
|
+
priority: 1
|
14
|
+
mysmtpname:
|
15
|
+
id: 3
|
16
|
+
name: mysmtpname
|
17
|
+
value: localhost
|
18
|
+
description: The value to give to the SMTP server upon connecting (with the SMTP HELO command)
|
19
|
+
priority: 2
|
20
|
+
default_welcome_admin_message_id:
|
21
|
+
id: 4
|
22
|
+
name: default_welcome_admin_message_id
|
23
|
+
value: 1
|
24
|
+
description: The ID of the default message to use to welcome a new subscriber to the mailing list.
|
25
|
+
priority: 3
|
26
|
+
default_confirmed_admin_message_id:
|
27
|
+
id: 5
|
28
|
+
name: default_confirmed_admin_message_id
|
29
|
+
value: 2
|
30
|
+
description: The ID of the default message to use to let a new subscriber know that his subscription has been confirmed.
|
31
|
+
priority: 3
|
32
|
+
default_farewell_admin_message_id:
|
33
|
+
id: 6
|
34
|
+
name: default_farewell_admin_message_id
|
35
|
+
value: 3
|
36
|
+
description: The ID of the default message to use to say farewell to a departing subscriber.
|
37
|
+
priority: 3
|
38
|
+
address_separator:
|
39
|
+
id: 7
|
40
|
+
name: address_separator
|
41
|
+
value: "-"
|
42
|
+
description: The character used to separate the bounces and request suffix from the list email address.
|
43
|
+
priority: 5
|
44
|
+
bounce_suffix:
|
45
|
+
id: 8
|
46
|
+
name: bounce_suffix
|
47
|
+
value: "bounces"
|
48
|
+
description: What suffix to append to a mailing list address to catch bounces with
|
49
|
+
priority: 4
|
50
|
+
request_suffix:
|
51
|
+
id: 9
|
52
|
+
name: request_suffix
|
53
|
+
value: "request"
|
54
|
+
description: The suffix to append to a mailing list address to send messages to with subscription and unsubscription requests
|
55
|
+
priority: 4
|
56
|
+
new_user_mailinglist_class:
|
57
|
+
id: 10
|
58
|
+
name: new_user_mailinglist_class
|
59
|
+
value: 1
|
60
|
+
description: The mailing list class of the "forwarded mail" mailing list created when a new user is created.
|
61
|
+
priority: 3
|
@@ -8,7 +8,7 @@ class MailserviceController; def rescue_action(e) raise e end; end
|
|
8
8
|
class MailserviceControllerTest < Test::Unit::TestCase
|
9
9
|
fixtures :domains, :users, :mailinglists, :admin_messages,
|
10
10
|
:mailinglist_classes, :confirmationcodes, :addresses,
|
11
|
-
:addresses_mailinglists
|
11
|
+
:addresses_mailinglists, :sys_configs
|
12
12
|
|
13
13
|
def setup
|
14
14
|
@controller = MailserviceController.new
|
@@ -22,6 +22,10 @@ def stuff_ask(*responses)
|
|
22
22
|
end
|
23
23
|
|
24
24
|
class SugoiAdminControllerTest < Test::Unit::TestCase
|
25
|
+
fixtures :domains, :users, :mailinglists, :admin_messages,
|
26
|
+
:mailinglist_classes, :confirmationcodes, :addresses,
|
27
|
+
:addresses_mailinglists, :sys_configs
|
28
|
+
|
25
29
|
def setup
|
26
30
|
@controller = SugoiAdminController.new
|
27
31
|
# @request = ActionController::TestRequest.new
|
@@ -81,8 +85,8 @@ class SugoiAdminControllerTest < Test::Unit::TestCase
|
|
81
85
|
|
82
86
|
def test_create_user_normally
|
83
87
|
assert_nothing_raised do
|
84
|
-
invoke "create_user", "test.domain", "newuser",
|
85
|
-
|
88
|
+
invoke "create_user", "test.domain", "newuser",
|
89
|
+
"newuser@foo.test", "New User"
|
86
90
|
end
|
87
91
|
assert_equal [ "create_user: User \"newuser@test.domain\" created successfully" ],
|
88
92
|
assigns["messages"]
|
@@ -186,48 +190,48 @@ class SugoiAdminControllerTest < Test::Unit::TestCase
|
|
186
190
|
assert assigns["mailinglist_classes"]
|
187
191
|
end
|
188
192
|
|
189
|
-
def
|
193
|
+
def test_create_list_wrong_class
|
190
194
|
assert_nothing_raised do
|
191
|
-
invoke "
|
192
|
-
"testuser", "New Mailing List"
|
195
|
+
invoke "create_list", "newmailinglist", "test.domain",
|
196
|
+
"testuser", "New Mailing List", 100
|
193
197
|
end
|
194
198
|
assert assigns["error"]
|
195
|
-
assert_equal "
|
199
|
+
assert_equal "create_list: Invalid mailing list class: 100",
|
196
200
|
assigns["error"]
|
197
201
|
assert_nil Mailinglist.find_by_address("newmailinglist@test.domain")
|
198
202
|
end
|
199
203
|
|
200
|
-
def
|
204
|
+
def test_create_list_wrong_domain
|
201
205
|
assert_nothing_raised do
|
202
|
-
invoke "
|
206
|
+
invoke "create_list", "newmailinglist",
|
203
207
|
"nonexistent.domain", "testuser", "New Mailing List"
|
204
208
|
end
|
205
209
|
assert assigns["error"]
|
206
|
-
assert_equal "
|
210
|
+
assert_equal "create_list: Domain \"nonexistent.domain\" not found.",
|
207
211
|
assigns["error"]
|
208
212
|
assert_nil Mailinglist.find_by_address("newmailinglist@test.domain")
|
209
213
|
end
|
210
214
|
|
211
215
|
def test_create_Mailing_list_wrong_user
|
212
216
|
assert_nothing_raised do
|
213
|
-
invoke "
|
217
|
+
invoke "create_list", "newmailinglist",
|
214
218
|
"test.domain", "nonexistentuser", "New Mailing List"
|
215
219
|
end
|
216
220
|
|
217
221
|
assert assigns["error"]
|
218
|
-
assert_equal "
|
222
|
+
assert_equal "create_list: User \"nonexistentuser\" not found in domain \"test.domain\".",
|
219
223
|
assigns["error"]
|
220
224
|
assert_nil Mailinglist.find_by_address("newmailinglist@test.domain")
|
221
225
|
end
|
222
226
|
|
223
|
-
def
|
227
|
+
def test_create_list_normal
|
224
228
|
assert_nothing_raised do
|
225
|
-
invoke "
|
229
|
+
invoke "create_list", "newmailinglist", "test.domain",
|
226
230
|
"testuser"
|
227
231
|
end
|
228
232
|
|
229
233
|
assert assigns["messages"]
|
230
|
-
assert_equal ["
|
234
|
+
assert_equal ["create_list: Mailing list \"newmailinglist@test.domain\" created successfully."],
|
231
235
|
assigns["messages"]
|
232
236
|
assert Mailinglist.find_by_address("newmailinglist@test.domain")
|
233
237
|
end
|
@@ -253,7 +257,7 @@ class SugoiAdminControllerTest < Test::Unit::TestCase
|
|
253
257
|
end
|
254
258
|
assert_nil assigns["messages"]
|
255
259
|
assert assigns["error"]
|
256
|
-
assert_equal "subscribe: Mailing list \"nonexistent@test.domain\"
|
260
|
+
assert_equal "subscribe: Mailing list \"nonexistent@test.domain\" not found.", assigns["error"]
|
257
261
|
end
|
258
262
|
|
259
263
|
def test_unsubscribe_address_from_mailing_list
|
data/test/unit/address_test.rb
CHANGED
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
2
2
|
|
3
3
|
class AddressTest < Test::Unit::TestCase
|
4
4
|
fixtures :mailinglists, :users, :addresses_mailinglists, :addresses,
|
5
|
-
:domains
|
5
|
+
:domains, :sys_configs
|
6
6
|
|
7
7
|
def test_parse_1
|
8
8
|
assert_equal [ 'address1@foo.test', 'Address One'],
|
@@ -4,7 +4,8 @@ require 'net-smtp-stub'
|
|
4
4
|
|
5
5
|
class MailinglistTest < Test::Unit::TestCase
|
6
6
|
fixtures :mailinglists, :addresses_mailinglists, :addresses,
|
7
|
-
:confirmationcodes, :users, :admin_messages, :domains, :messages
|
7
|
+
:confirmationcodes, :users, :admin_messages, :domains, :messages,
|
8
|
+
:proxy_links
|
8
9
|
|
9
10
|
def setup
|
10
11
|
@ml=Mailinglist.find 1
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class SysConfigTest < Test::Unit::TestCase
|
4
|
+
fixtures :sys_configs
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@testconfig = @loaded_fixtures["sys_configs"]
|
8
|
+
end
|
9
|
+
|
10
|
+
# Replace this with your real tests.
|
11
|
+
def test_truth
|
12
|
+
assert true
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_param_not_found
|
16
|
+
assert_raises ActiveRecord::RecordNotFound do
|
17
|
+
SysConfig.nosuchparam
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_fixture_retrieval
|
22
|
+
assert_equal @testconfig["smtpserver"]["value"], SysConfig.smtpserver
|
23
|
+
assert_equal @testconfig["smtpport"]["value"],
|
24
|
+
SysConfig.smtpport
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_set_new_simple_param
|
28
|
+
assert_equal 42, SysConfig.test1=42
|
29
|
+
assert_equal 42, SysConfig.test1
|
30
|
+
|
31
|
+
assert_equal "test", SysConfig.test2="test"
|
32
|
+
assert_equal "test", SysConfig.test2
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_old_activerecord_functionality
|
36
|
+
assert_nothing_raised do
|
37
|
+
param = SysConfig.find_by_name "smtpserver"
|
38
|
+
assert_equal @testconfig["smtpserver"]["value"], param.value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: sugoi-mail
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date:
|
6
|
+
version: 0.0.2
|
7
|
+
date: 2007-01-04 00:00:00 +09:00
|
8
8
|
summary: Powerful mailing list manager.
|
9
9
|
require_paths:
|
10
10
|
- .
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- app/controllers/address_controller.rb
|
100
100
|
- app/controllers/application.rb
|
101
101
|
- app/controllers/domain_controller.rb
|
102
|
+
- app/models/sys_config.rb
|
102
103
|
- app/models/mailinglist_class.rb
|
103
104
|
- app/models/domain.rb
|
104
105
|
- app/models/message.rb
|
@@ -126,13 +127,13 @@ files:
|
|
126
127
|
- app/views/sugoi_admin/subscribe.rhtml
|
127
128
|
- app/views/sugoi_admin/list_addresses.rhtml
|
128
129
|
- app/views/sugoi_admin/list_domains.rhtml
|
129
|
-
- app/views/sugoi_admin/create_mailing_list.rhtml
|
130
130
|
- app/views/sugoi_admin/unsubscribe.rhtml
|
131
131
|
- app/views/sugoi_admin/list_mailinglist_classes.rhtml
|
132
132
|
- app/views/sugoi_admin/list_mailinglists.rhtml
|
133
133
|
- app/views/sugoi_admin/list_users.rhtml
|
134
134
|
- app/views/sugoi_admin/create_user.rhtml
|
135
135
|
- app/views/sugoi_admin/create_domain.rhtml
|
136
|
+
- app/views/sugoi_admin/create_list.rhtml
|
136
137
|
- app/views/layouts/scaffold.rhtml
|
137
138
|
- app/views/layouts/address.rhtml
|
138
139
|
- app/views/address/new.rhtml
|
@@ -190,6 +191,7 @@ files:
|
|
190
191
|
- db/migrate/015_add_messages_to_mailinglists.rb
|
191
192
|
- db/migrate/014_create_admin_messages.rb
|
192
193
|
- db/migrate/010_add_domain_to_users.rb
|
194
|
+
- db/migrate/026_create_sys_configs.rb
|
193
195
|
- db/migrate/022_add_virtual_to_users.rb
|
194
196
|
- db/migrate/007_create_messages.rb
|
195
197
|
- db/migrate/013_add_description_to_mailinglists.rb
|
@@ -216,9 +218,11 @@ files:
|
|
216
218
|
- test/unit/mailinglist_class_test.rb
|
217
219
|
- test/unit/mailinglist_test.rb
|
218
220
|
- test/unit/message_test.rb
|
221
|
+
- test/unit/sys_config_test.rb
|
219
222
|
- test/unit/address_test.rb
|
220
223
|
- test/unit/confirmationcode_test.rb
|
221
224
|
- test/unit/domain_test.rb
|
225
|
+
- test/fixtures/sys_configs.yml
|
222
226
|
- test/fixtures/confirmationcodes.yml
|
223
227
|
- test/fixtures/addresses_mailinglists.yml
|
224
228
|
- test/fixtures/messages.yml
|