parlement 0.2 → 0.3
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.
- data/CHANGES +14 -4
- data/README +25 -5
- data/Rakefile +21 -21
- data/app/controllers/account_controller.rb +5 -1
- data/app/controllers/elt_controller.rb +7 -10
- data/app/controllers/person_controller.rb +9 -0
- data/app/controllers/subscriber_controller.rb +21 -0
- data/app/helpers/elt_helper.rb +25 -13
- data/app/helpers/mailman.rb +9 -92
- data/app/helpers/subscriber_helper.rb +2 -0
- data/app/models/attachment.rb +2 -0
- data/app/models/elt.rb +64 -2
- data/app/models/mail.rb +198 -0
- data/app/models/mail_notify.rb +63 -0
- data/app/models/person.rb +8 -1
- data/app/views/account/_login.rhtml +31 -28
- data/app/views/account/_show.rhtml +4 -4
- data/app/views/elt/_elt.rhtml +23 -28
- data/app/views/elt/_list.rhtml +6 -2
- data/app/views/elt/new.rhtml +1 -1
- data/app/views/elt/show.rhtml +32 -10
- data/app/views/layouts/top.rhtml +16 -10
- data/app/views/mail_notify/publish.text.html.rhtml +46 -0
- data/app/views/mail_notify/publish.text.plain.rhtml +2 -0
- data/app/views/person/_listElts.rhtml +33 -0
- data/app/views/person/show.rhtml +21 -19
- data/config/boot.rb +2 -0
- data/config/environment.rb +19 -13
- data/config/environments/development.rb +3 -1
- data/config/environments/production.rb +2 -0
- data/config/environments/test.rb +2 -0
- data/config/routes.rb +5 -2
- data/db/ROOT/mail.txt +2 -0
- data/db/ROOT/parlement/news/release0.2.txt +8 -0
- data/db/ROOT/parlement/news/release0.3.txt +11 -0
- data/db/ROOT/parlement/test.txt +6 -1
- data/db/ROOT/parlement.txt +23 -30
- data/db/ROOT/perso.txt +17 -18
- data/db/development_structure.sql +133 -217
- data/db/schema.rb +83 -0
- data/db/schema.sql +11 -15
- data/lib/data_import.rb +3 -1
- data/public/attachment/file/architecture.png +0 -0
- data/public/attachment/file/architecture.svg +8972 -0
- data/public/attachment/file/security.svg +8960 -0
- data/public/images/Sleep-Deprivation-5.JPG +0 -0
- data/public/images/eltBackground.png +0 -0
- data/public/images/eltBackground.svg +89 -0
- data/public/images/orange_by_darren_Hester_350o.jpg +0 -0
- data/public/images/rails.png +0 -0
- data/public/images/smile.png +0 -0
- data/public/images/smile.svg +257 -0
- data/public/images/world.png +0 -0
- data/public/images/world.svg +170 -0
- data/public/javascripts/controls.js +30 -1
- data/public/javascripts/dragdrop.js +210 -145
- data/public/javascripts/effects.js +261 -399
- data/public/javascripts/ie7.js +6 -0
- data/public/javascripts/prototype.js +131 -72
- data/public/oldindex.html +270 -71
- data/public/stylesheets/default.css +189 -215
- data/script/about +1 -1
- data/script/breakpointer +1 -1
- data/script/console +1 -1
- data/script/destroy +1 -1
- data/script/generate +1 -1
- data/script/performance/benchmarker +1 -1
- data/script/performance/profiler +1 -1
- data/script/plugin +1 -1
- data/script/process/reaper +1 -1
- data/script/process/spawner +1 -1
- data/script/process/spinner +1 -1
- data/script/runner +1 -1
- data/script/server +1 -1
- data/test/fixtures/elts.yml +2 -0
- data/test/fixtures/mail/mail_ruby +27 -0
- data/test/fixtures/mail/mail_rubyChild +28 -0
- data/test/fixtures/mail/mail_rubyWithAttachment +7932 -0
- data/test/fixtures/mail/mail_rubyWithSubject +27 -0
- data/test/fixtures/mails.yml +7 -1
- data/test/fixtures/people.yml +5 -0
- data/test/fixtures/subscribers.yml +11 -0
- data/test/functional/account_controller_test.rb +38 -37
- data/test/functional/subscriber_controller_test.rb +128 -0
- data/test/test_helper.rb +44 -0
- data/test/unit/attachment_test.rb +1 -1
- data/test/unit/elt_test.rb +3 -2
- data/test/unit/mail_notify_test.rb +37 -0
- data/test/unit/mail_test.rb +124 -1
- data/test/unit/notifier_test.rb +0 -14
- data/test/unit/person_test.rb +2 -1
- data/test/unit/subscriber_test.rb +35 -0
- data/test/unit/user_test.rb +3 -3
- data/vendor/plugins/file_column/CHANGELOG +64 -0
- data/vendor/plugins/file_column/README +54 -0
- data/vendor/plugins/file_column/Rakefile +36 -0
- data/vendor/plugins/file_column/TODO +6 -0
- data/vendor/plugins/file_column/init.rb +12 -0
- data/vendor/plugins/file_column/lib/file_column.rb +719 -0
- data/vendor/plugins/file_column/lib/file_column_helper.rb +145 -0
- data/vendor/plugins/file_column/lib/file_compat.rb +28 -0
- data/vendor/plugins/file_column/lib/magick_file_column.rb +188 -0
- data/vendor/plugins/file_column/lib/validations.rb +112 -0
- data/vendor/plugins/file_column/test/abstract_unit.rb +90 -0
- data/vendor/plugins/file_column/test/connection.rb +17 -0
- data/vendor/plugins/file_column/test/file_column_helper_test.rb +97 -0
- data/vendor/plugins/file_column/test/file_column_test.rb +630 -0
- data/vendor/plugins/file_column/test/fixtures/entry.rb +32 -0
- data/vendor/plugins/file_column/test/fixtures/invalid-image.jpg +1 -0
- data/vendor/plugins/file_column/test/fixtures/kerb.jpg +0 -0
- data/vendor/plugins/file_column/test/fixtures/mysql.sql +25 -0
- data/vendor/plugins/file_column/test/fixtures/schema.rb +10 -0
- data/vendor/plugins/file_column/test/fixtures/skanthak.png +0 -0
- data/vendor/plugins/file_column/test/magick_test.rb +251 -0
- data/vendor/plugins/file_column/test/magick_view_only_test.rb +21 -0
- data/vendor/plugins/guid/README.TXT +19 -0
- data/vendor/plugins/guid/init.rb +23 -0
- data/vendor/plugins/guid/lib/usesguid.rb +37 -0
- data/vendor/plugins/guid/lib/uuid22.rb +43 -0
- data/vendor/plugins/guid/lib/uuidtools.rb +565 -0
- metadata +83 -15
- data/db/ROOT/CV.txt +0 -166
- data/lib/file_column.rb +0 -263
- data/lib/file_column_helper.rb +0 -45
- /data/{lib → vendor/plugins/file_column/lib}/rails_file_column.rb +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
From manu@leparlement.org Fri Jan 20 20:58:33 2006
|
|
2
|
+
Return-path: <manu@leparlement.org>
|
|
3
|
+
Envelope-to: manu@localhost
|
|
4
|
+
Delivery-date: Fri, 20 Jan 2006 20:58:33 +0100
|
|
5
|
+
Received: from localhost ([127.0.0.1])
|
|
6
|
+
by localhost.localdomain with esmtp (Exim 4.60)
|
|
7
|
+
(envelope-from <manu@leparlement.org>)
|
|
8
|
+
id 1F02P3-0005yR-JN
|
|
9
|
+
for manu@localhost; Fri, 20 Jan 2006 20:58:33 +0100
|
|
10
|
+
Received: from echarp.org [81.66.133.96]
|
|
11
|
+
by localhost with IMAP (fetchmail-6.2.5.4)
|
|
12
|
+
for manu@localhost (single-drop); Fri, 20 Jan 2006 20:58:33 +0100 (CET)
|
|
13
|
+
Received: from manu by vvv with local (Exim 4.60)
|
|
14
|
+
(envelope-from <manu@leparlement.org>)
|
|
15
|
+
id 1F02OK-0002EG-DN
|
|
16
|
+
for manu@localhost; Fri, 20 Jan 2006 20:57:48 +0100
|
|
17
|
+
From: echarp <manu@leparlement.org>
|
|
18
|
+
To: manu@localhost
|
|
19
|
+
Subject: [TEST_with_subject] test parlement
|
|
20
|
+
Date: Fri, 20 Jan 2006 18:11:00 -0000
|
|
21
|
+
Content-Type: text/plain; charset="utf-8"
|
|
22
|
+
Message-Id: <E1F02OK-0002EG-DR@vvv>
|
|
23
|
+
Status: RO
|
|
24
|
+
Content-Length: 1007
|
|
25
|
+
Lines: 18
|
|
26
|
+
|
|
27
|
+
Test d'envoi de mail!
|
data/test/fixtures/mails.yml
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
|
2
2
|
first_mail:
|
|
3
3
|
id: 1
|
|
4
|
-
elt_id:
|
|
4
|
+
elt_id: ROOT
|
|
5
|
+
message: <hello@world>
|
|
5
6
|
another_mail:
|
|
6
7
|
id: 2
|
|
7
8
|
elt_id: mail
|
|
9
|
+
message: <helloMail@world>
|
|
10
|
+
parent_mail:
|
|
11
|
+
id: 3
|
|
12
|
+
elt_id: 0
|
|
13
|
+
message: <helloParent@world>
|
data/test/fixtures/people.yml
CHANGED
|
@@ -10,7 +10,8 @@ class AccountController; def rescue_action(e) raise e end; end
|
|
|
10
10
|
|
|
11
11
|
class AccountControllerTest < Test::Unit::TestCase
|
|
12
12
|
|
|
13
|
-
fixtures :people, LoginEngine.config(:user_table).to_sym
|
|
13
|
+
#fixtures :people, LoginEngine.config(:user_table).to_sym
|
|
14
|
+
fixtures :people, :users, :subscribers
|
|
14
15
|
|
|
15
16
|
def setup
|
|
16
17
|
LoginEngine::CONFIG[:salt] = "test-salt"
|
|
@@ -31,17 +32,17 @@ class AccountControllerTest < Test::Unit::TestCase
|
|
|
31
32
|
def test_signup
|
|
32
33
|
post :login, :person => { :name => "my_bob", :email => "" },
|
|
33
34
|
:user => { :password => "" }
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
assert_not_nil session[:person]
|
|
36
|
+
assert_nil session[:user]
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
def test_login_logoff_no_password
|
|
39
40
|
post :login, :person => { :name => "bob_other", :email => "" },
|
|
40
41
|
:user => { :password => "" }
|
|
41
42
|
assert_equal people(:bob_other), @request.session[:person]
|
|
42
|
-
|
|
43
|
+
assert_nil session[:user]
|
|
43
44
|
get :logout
|
|
44
|
-
|
|
45
|
+
assert_nil session[:person]
|
|
45
46
|
end
|
|
46
47
|
|
|
47
48
|
def test_bad_pseudo
|
|
@@ -49,7 +50,7 @@ class AccountControllerTest < Test::Unit::TestCase
|
|
|
49
50
|
:user => { :password => "" }
|
|
50
51
|
assert_invalid_column_on_record "person", :name
|
|
51
52
|
assert_success
|
|
52
|
-
|
|
53
|
+
assert_nil session[:person]
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
|
|
@@ -63,43 +64,43 @@ class AccountControllerTest < Test::Unit::TestCase
|
|
|
63
64
|
def test_password_protect
|
|
64
65
|
post :login, :person => { :name => "bob_another", :email => "" },
|
|
65
66
|
:user => { :password => "atest" }
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
assert_not_nil session[:person]
|
|
68
|
+
assert_not_nil session[:user]
|
|
68
69
|
end
|
|
69
70
|
|
|
70
71
|
def test_auth_bob
|
|
71
72
|
post :login, :person => { :name => "bob", :email => "" },
|
|
72
73
|
:user => { :password => "atest" }
|
|
73
74
|
assert_equal people(:bob), @response.session[:person]
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
assert_not_nil session[:person]
|
|
76
|
+
assert_not_nil session[:user]
|
|
76
77
|
end
|
|
77
78
|
|
|
78
79
|
def test_bad_password
|
|
79
80
|
post :login, :person => { :name => "newbob", :email => "" },
|
|
80
81
|
:user => { :password => "newpassword", :password_confirmation => "wrong" }
|
|
81
|
-
assert_invalid_column_on_record "user", :password
|
|
82
|
+
#assert_invalid_column_on_record "user", :password
|
|
82
83
|
assert_success
|
|
83
84
|
end
|
|
84
85
|
|
|
85
86
|
def test_login_logoff_password
|
|
86
87
|
post :login, :person => { :name => "my_bob", :email => "" },
|
|
87
88
|
:user => { :password => "my_bob" }
|
|
88
|
-
|
|
89
|
+
assert_not_nil session[:person]
|
|
89
90
|
get :logout
|
|
90
|
-
|
|
91
|
+
assert_nil session[:user]
|
|
91
92
|
end
|
|
92
93
|
|
|
93
94
|
def test_invalid_password
|
|
94
95
|
post :login, :person => { :name => "my_bob", :email => "" },
|
|
95
96
|
:user => { :password => "my_bob" }
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
assert_not_nil session[:person]
|
|
98
|
+
assert_not_nil session[:user]
|
|
98
99
|
get :logout
|
|
99
100
|
post :login, :person => { :name => "my_bob", :email => "" },
|
|
100
101
|
:user => { :password => "my_bo" }
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
assert_nil session[:person]
|
|
103
|
+
assert_nil session[:user]
|
|
103
104
|
#assert_template_has "login"
|
|
104
105
|
end
|
|
105
106
|
|
|
@@ -113,8 +114,8 @@ class AccountControllerTest < Test::Unit::TestCase
|
|
|
113
114
|
def test_password_and_email_protect
|
|
114
115
|
post :login, :person => { :name => "my_bob", :email => "manu@noos.fr" },
|
|
115
116
|
:user => { :password => "my_bob" }
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
assert_not_nil session[:person]
|
|
118
|
+
assert_not_nil session[:user]
|
|
118
119
|
assert_equal "my_bob", @request.session[:person].name
|
|
119
120
|
assert_equal "manu@noos.fr", @request.session[:user].email
|
|
120
121
|
assert_not_equal @request.session[:person].email, @request.session[:user].email
|
|
@@ -125,8 +126,8 @@ class AccountControllerTest < Test::Unit::TestCase
|
|
|
125
126
|
post :login, :person => { :name => "bob", :email => "" },
|
|
126
127
|
:user => { :password => "not_correct" }
|
|
127
128
|
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
assert_nil session[:person]
|
|
130
|
+
assert_nil session[:user]
|
|
130
131
|
|
|
131
132
|
assert_template_has "login"
|
|
132
133
|
end
|
|
@@ -142,8 +143,8 @@ class AccountControllerTest < Test::Unit::TestCase
|
|
|
142
143
|
assert_equal 5, User.count
|
|
143
144
|
post :login, :person => { :name => "newbob", :email => "newbob@test.com" },
|
|
144
145
|
:user => { :password => "newpassword" }
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
assert_not_nil session[:person]
|
|
147
|
+
assert_not_nil session[:user]
|
|
147
148
|
assert_equal 6, User.count
|
|
148
149
|
|
|
149
150
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
|
@@ -183,8 +184,8 @@ class AccountControllerTest < Test::Unit::TestCase
|
|
|
183
184
|
|
|
184
185
|
post :login, :person => { :name => "newbob", :email => "" },
|
|
185
186
|
:user => { :password => "newpassword" }
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
assert_not_nil session[:person]
|
|
188
|
+
assert_not_nil session[:user]
|
|
188
189
|
get :logout
|
|
189
190
|
end
|
|
190
191
|
|
|
@@ -195,8 +196,8 @@ class AccountControllerTest < Test::Unit::TestCase
|
|
|
195
196
|
|
|
196
197
|
post :login, :person => { :name => "bob", :email => "bob@test.com" },
|
|
197
198
|
:user => { :password => "" }
|
|
198
|
-
|
|
199
|
-
|
|
199
|
+
assert_nil session[:person]
|
|
200
|
+
assert_nil session[:user]
|
|
200
201
|
|
|
201
202
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
|
202
203
|
mail = ActionMailer::Base.deliveries[0]
|
|
@@ -208,31 +209,31 @@ class AccountControllerTest < Test::Unit::TestCase
|
|
|
208
209
|
Time.advance_by_days = 1
|
|
209
210
|
post :login, :person => { :name => "bob", :email => key },
|
|
210
211
|
:user => { :password => "newpassword" }
|
|
211
|
-
|
|
212
|
-
|
|
212
|
+
assert_nil session[:person]
|
|
213
|
+
assert_nil session[:user]
|
|
213
214
|
Time.advance_by_days = 0
|
|
214
215
|
|
|
215
216
|
# Then a bogus key.
|
|
216
217
|
post :login, :person => { :name => "bob", :email => "boguskey" },
|
|
217
218
|
:user => { :password => "newpassword" }
|
|
218
|
-
|
|
219
|
-
|
|
219
|
+
assert_nil session[:person]
|
|
220
|
+
assert_nil session[:user]
|
|
220
221
|
|
|
221
222
|
# Now the real one.
|
|
222
223
|
post :login, :person => { :name => "bob", :email => key },
|
|
223
224
|
:user => { :password => "newpassword" }
|
|
224
|
-
|
|
225
|
-
|
|
225
|
+
assert_not_nil session[:person]
|
|
226
|
+
assert_not_nil session[:user]
|
|
226
227
|
get :logout
|
|
227
228
|
|
|
228
229
|
post :login, :person => { :name => "bob", :email => "" },
|
|
229
230
|
:user => { :password => "password" }
|
|
230
|
-
|
|
231
|
-
|
|
231
|
+
assert_nil session[:person]
|
|
232
|
+
assert_nil session[:user]
|
|
232
233
|
post :login, :person => { :name => "bob", :email => "" },
|
|
233
234
|
:user => { :password => "newpassword" }
|
|
234
|
-
|
|
235
|
-
|
|
235
|
+
assert_not_nil session[:person]
|
|
236
|
+
assert_not_nil session[:user]
|
|
236
237
|
get :logout
|
|
237
238
|
end
|
|
238
239
|
end
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'subscriber_controller'
|
|
3
|
+
|
|
4
|
+
# Re-raise errors caught by the controller.
|
|
5
|
+
class SubscriberController; def rescue_action(e) raise e end; end
|
|
6
|
+
|
|
7
|
+
class SubscriberControllerTest < Test::Unit::TestCase
|
|
8
|
+
fixtures :people, :users, :elts, :mails, :attachments, :subscribers
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
@controller = SubscriberController.new
|
|
12
|
+
@request = ActionController::TestRequest.new
|
|
13
|
+
@response = ActionController::TestResponse.new
|
|
14
|
+
|
|
15
|
+
ActionMailer::Base.delivery_method = :test
|
|
16
|
+
ActionMailer::Base.perform_deliveries = true
|
|
17
|
+
ActionMailer::Base.deliveries = []
|
|
18
|
+
|
|
19
|
+
@expected = TMail::Mail.new
|
|
20
|
+
@expected.set_content_type "text", "plain", { "charset" => CHARSET }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_subscribe
|
|
24
|
+
login
|
|
25
|
+
|
|
26
|
+
elt = Elt.find('0')
|
|
27
|
+
numSubscribers = elt.subscribers.size
|
|
28
|
+
post :subscribe, :id => '0'
|
|
29
|
+
elt = Elt.find('0')
|
|
30
|
+
assert_equal (numSubscribers + 1), elt.subscribers.size
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_unsubscribe
|
|
34
|
+
login
|
|
35
|
+
post :subscribe, :id => '0'
|
|
36
|
+
|
|
37
|
+
elt = Elt.find('0')
|
|
38
|
+
numSubscribers = elt.subscribers.size
|
|
39
|
+
post :subscribe, :id => '0'
|
|
40
|
+
elt = Elt.find('0')
|
|
41
|
+
assert_equal (numSubscribers - 1), elt.subscribers.size
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def test_post_elt
|
|
46
|
+
#puts "CCCCCCCC"
|
|
47
|
+
#puts Elt.find('0').all_recipients.join(', ')
|
|
48
|
+
|
|
49
|
+
controller = @controller
|
|
50
|
+
@controller = EltController.new
|
|
51
|
+
|
|
52
|
+
numChildren = Elt.find(0).children.size
|
|
53
|
+
numMails = Mail.find_all.size
|
|
54
|
+
|
|
55
|
+
post :create, :elt => { :parent_id => '0', :subject => 'A new mail',
|
|
56
|
+
:body => 'testing a new mail' }
|
|
57
|
+
|
|
58
|
+
assert_equal 1, ActionMailer::Base.deliveries.size
|
|
59
|
+
assert_equal (numChildren + 1), Elt.find(0).children.size
|
|
60
|
+
assert_equal (numMails + 1), Mail.find_all.size
|
|
61
|
+
|
|
62
|
+
mail = ActionMailer::Base.deliveries[0]
|
|
63
|
+
|
|
64
|
+
elt = Elt.find(0).children[0]
|
|
65
|
+
|
|
66
|
+
assert_equal mail.destinations, elt.all_recipients.collect { |i| i.email }.reject { |i| i == nil }
|
|
67
|
+
assert_equal '0@'+ActionMailer::Base.server_settings[:domain], mail.to[0]
|
|
68
|
+
assert_equal ANONYMOUS_POSTER+' <'+ANONYMOUS_POSTER+'@'+ActionMailer::Base.server_settings[:domain]+'>', mail.from_addrs[0].to_s
|
|
69
|
+
|
|
70
|
+
@controller = controller
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_post_loggedin_elt
|
|
74
|
+
login
|
|
75
|
+
|
|
76
|
+
controller = @controller
|
|
77
|
+
@controller = EltController.new
|
|
78
|
+
|
|
79
|
+
post :create, :elt => { :parent_id => '0', :subject => 'A new mail',
|
|
80
|
+
:body => 'testing a new mail as user my_bob' }
|
|
81
|
+
|
|
82
|
+
mail = ActionMailer::Base.deliveries[1]
|
|
83
|
+
elt = Elt.find(0).children[0]
|
|
84
|
+
|
|
85
|
+
# Because the logged in user is not email verified!
|
|
86
|
+
assert_equal 'my_bob <'+ANONYMOUS_POSTER+'@'+ActionMailer::Base.server_settings[:domain]+'>', mail.from_addrs[0].to_s
|
|
87
|
+
assert_equal elt.parent.mail.message, mail.references.to_s
|
|
88
|
+
|
|
89
|
+
# Check every body replies to the mailing list
|
|
90
|
+
assert_equal mail.to, mail.reply_to
|
|
91
|
+
|
|
92
|
+
@controller = controller
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_send_elt
|
|
96
|
+
fixture = read_fixture('mail_ruby').to_s
|
|
97
|
+
orig = TMail::Mail.parse(fixture)
|
|
98
|
+
Mailman.receive(fixture)
|
|
99
|
+
|
|
100
|
+
# Created the elt itself, and a parent mailing list element called
|
|
101
|
+
# "mailingList
|
|
102
|
+
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
103
|
+
|
|
104
|
+
mail = ActionMailer::Base.deliveries[0]
|
|
105
|
+
assert_equal 'mailingList', mail.subject
|
|
106
|
+
|
|
107
|
+
mail = ActionMailer::Base.deliveries[1]
|
|
108
|
+
assert_equal orig.message_id, mail.message_id
|
|
109
|
+
assert_equal orig.references, mail.references
|
|
110
|
+
assert_equal orig.subject, mail.subject
|
|
111
|
+
assert_equal orig.body, mail.body
|
|
112
|
+
assert_equal orig.to, mail.to
|
|
113
|
+
assert_equal orig.cc, mail.cc
|
|
114
|
+
assert_equal orig.from, mail.from
|
|
115
|
+
assert_equal orig.sender(nil), mail.sender(nil)
|
|
116
|
+
assert_equal orig.date, mail.date
|
|
117
|
+
assert_equal orig.reply_to, mail.reply_to
|
|
118
|
+
|
|
119
|
+
# Check that we are actually sending the mail to other recipients
|
|
120
|
+
assert_not_equal orig.bcc, mail.bcc
|
|
121
|
+
|
|
122
|
+
assert_equal mail.destinations, mail.bcc
|
|
123
|
+
|
|
124
|
+
elt = Mail.find_by_message(mail.message_id).elt
|
|
125
|
+
assert_equal mail.destinations, elt.all_recipients.collect { |i| i.email }.reject { |i| i == nil }
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
data/test/test_helper.rb
CHANGED
|
@@ -3,6 +3,12 @@ require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
|
|
3
3
|
require 'test_help'
|
|
4
4
|
|
|
5
5
|
class Test::Unit::TestCase
|
|
6
|
+
FIXTURES_PATH = File.dirname(__FILE__) + '/fixtures'
|
|
7
|
+
CHARSET = "utf-8"
|
|
8
|
+
|
|
9
|
+
include ActionMailer::Quoting
|
|
10
|
+
|
|
11
|
+
|
|
6
12
|
# Transactional fixtures accelerate your tests by wrapping each test method
|
|
7
13
|
# in a transaction that's rolled back on completion. This ensures that the
|
|
8
14
|
# test database remains unchanged so your fixtures don't have to be reloaded
|
|
@@ -25,4 +31,42 @@ class Test::Unit::TestCase
|
|
|
25
31
|
self.use_instantiated_fixtures = false
|
|
26
32
|
|
|
27
33
|
# Add more helper methods to be used by all tests here...
|
|
34
|
+
#
|
|
35
|
+
|
|
36
|
+
def Xteardown
|
|
37
|
+
self.class.fixture_table_names.reverse.each do |table_name|
|
|
38
|
+
klass_name = Inflector.classify(table_name.to_s)
|
|
39
|
+
if Object.const_defined?(klass_name)
|
|
40
|
+
klass = Object.const_get(klass_name)
|
|
41
|
+
klass.connection.delete("DELETE FROM #{table_name}", 'Fixture Delete')
|
|
42
|
+
else
|
|
43
|
+
flunk("Cannot find class for table '#{table_name}' to delete fixtures")
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
#
|
|
50
|
+
# A simple convenience method, its name makes it obvious isn't it ;)
|
|
51
|
+
#
|
|
52
|
+
def login
|
|
53
|
+
controller = @controller
|
|
54
|
+
@controller = AccountController.new
|
|
55
|
+
|
|
56
|
+
post :login, :person => { :name => "my_bob", :email => "manu@noos.fr" },
|
|
57
|
+
:user => { :password => "my_bob" }
|
|
58
|
+
assert_not_nil session[:person]
|
|
59
|
+
assert_not_nil session[:user]
|
|
60
|
+
|
|
61
|
+
@controller = controller
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def read_fixture(action)
|
|
65
|
+
IO.readlines("#{FIXTURES_PATH}/mail/#{action}")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def encode(subject)
|
|
69
|
+
quoted_printable(subject, CHARSET)
|
|
70
|
+
end
|
|
28
71
|
end
|
|
72
|
+
|
data/test/unit/elt_test.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
2
|
|
|
3
3
|
class EltTest < Test::Unit::TestCase
|
|
4
|
-
fixtures :elts, :
|
|
4
|
+
fixtures :elts, :mails, :attachments
|
|
5
5
|
|
|
6
6
|
def setup
|
|
7
7
|
@elt = Elt.find(1)
|
|
@@ -9,6 +9,7 @@ class EltTest < Test::Unit::TestCase
|
|
|
9
9
|
|
|
10
10
|
# Replace this with your real tests.
|
|
11
11
|
def test_truth
|
|
12
|
-
assert_kind_of Elt,
|
|
12
|
+
assert_kind_of Elt, @elt
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'mail_notify'
|
|
3
|
+
|
|
4
|
+
class MailNotifyTest < Test::Unit::TestCase
|
|
5
|
+
fixtures :elts, :mails, :attachments, :people, :users, :subscribers
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
ActionMailer::Base.delivery_method = :test
|
|
9
|
+
ActionMailer::Base.perform_deliveries = true
|
|
10
|
+
ActionMailer::Base.deliveries = []
|
|
11
|
+
|
|
12
|
+
@expected = TMail::Mail.new
|
|
13
|
+
@expected.set_content_type "text", "plain", { "charset" => CHARSET }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_deliver_mail
|
|
17
|
+
ActionMailer::Base.deliveries = []
|
|
18
|
+
|
|
19
|
+
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
20
|
+
|
|
21
|
+
elt = Elt.find('mail')
|
|
22
|
+
assert elt.save
|
|
23
|
+
|
|
24
|
+
assert_equal 1, ActionMailer::Base.deliveries.size
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_redeliver_mail
|
|
28
|
+
ActionMailer::Base.deliveries = []
|
|
29
|
+
|
|
30
|
+
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
31
|
+
|
|
32
|
+
elt = Elt.find('mail')
|
|
33
|
+
assert elt.save
|
|
34
|
+
|
|
35
|
+
assert_equal 1, ActionMailer::Base.deliveries.size
|
|
36
|
+
end
|
|
37
|
+
end
|
data/test/unit/mail_test.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
2
|
|
|
3
3
|
class MailTest < Test::Unit::TestCase
|
|
4
|
-
fixtures :elts, :mails, :attachments
|
|
4
|
+
fixtures :people, :users, :elts, :mails, :attachments, :subscribers
|
|
5
5
|
|
|
6
6
|
def setup
|
|
7
7
|
@mail = Mail.find(1)
|
|
@@ -11,4 +11,127 @@ class MailTest < Test::Unit::TestCase
|
|
|
11
11
|
def test_truth
|
|
12
12
|
assert_kind_of Mail, @mail
|
|
13
13
|
end
|
|
14
|
+
|
|
15
|
+
def test_receive
|
|
16
|
+
ActionMailer::Base.deliveries = []
|
|
17
|
+
|
|
18
|
+
mailsCount = Mail.count
|
|
19
|
+
eltsCount = Elt.count
|
|
20
|
+
deliveredMailsCount = ActionMailer::Base.deliveries.size
|
|
21
|
+
|
|
22
|
+
mailFile = TMail::Mail.parse(read_fixture('mail_ruby').to_s)
|
|
23
|
+
elt = Elt.new
|
|
24
|
+
elt.receive(mailFile)
|
|
25
|
+
|
|
26
|
+
assert_equal (mailsCount + 2), Mail.count
|
|
27
|
+
assert_equal (eltsCount + 2), Elt.count
|
|
28
|
+
# manu@noos.fr, manu@localhost
|
|
29
|
+
# delivering elt and parent's
|
|
30
|
+
assert_equal (deliveredMailsCount + 2), ActionMailer::Base.deliveries.size
|
|
31
|
+
assert_equal mailFile.message_id, ActionMailer::Base.deliveries[1].message_id
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_receiveWithSubject
|
|
35
|
+
ActionMailer::Base.deliveries = []
|
|
36
|
+
|
|
37
|
+
mailsCount = Mail.count
|
|
38
|
+
eltsCount = Elt.count
|
|
39
|
+
|
|
40
|
+
mailFile = TMail::Mail.parse(read_fixture('mail_rubyWithSubject').to_s)
|
|
41
|
+
elt = Elt.new
|
|
42
|
+
elt.receive(mailFile)
|
|
43
|
+
|
|
44
|
+
assert_equal (mailsCount + 2), Mail.count
|
|
45
|
+
assert_equal (eltsCount + 2), Elt.count
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_receiveWithAttachment
|
|
49
|
+
ActionMailer::Base.deliveries = []
|
|
50
|
+
|
|
51
|
+
mailsCount = Mail.count
|
|
52
|
+
attachmentsCount = Attachment.count
|
|
53
|
+
eltsCount = Elt.count
|
|
54
|
+
|
|
55
|
+
mailFile = TMail::Mail.parse(read_fixture('mail_rubyWithAttachment').to_s)
|
|
56
|
+
elt = Elt.new
|
|
57
|
+
elt.receive(mailFile)
|
|
58
|
+
|
|
59
|
+
assert_equal (mailsCount + 2), Mail.count
|
|
60
|
+
# Just one file as an attachment
|
|
61
|
+
assert_equal (attachmentsCount + 1), Attachment.count
|
|
62
|
+
assert_equal (eltsCount + 2), Elt.count
|
|
63
|
+
|
|
64
|
+
assert_equal File.split(elt.attachments[0].file)[1], 'ylona.jpg'
|
|
65
|
+
elt.attachments.each do |i|
|
|
66
|
+
File.delete(i.file)
|
|
67
|
+
Dir.rmdir(File.split(i.file)[0])
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_receiveChild
|
|
72
|
+
ActionMailer::Base.deliveries = []
|
|
73
|
+
|
|
74
|
+
elt = Elt.new
|
|
75
|
+
mailFile = TMail::Mail.parse(read_fixture('mail_ruby').to_s)
|
|
76
|
+
elt.receive(mailFile)
|
|
77
|
+
|
|
78
|
+
ActionMailer::Base.deliveries = []
|
|
79
|
+
mailsCount = Mail.count
|
|
80
|
+
eltsCount = Elt.count
|
|
81
|
+
|
|
82
|
+
mailFileChild = TMail::Mail.parse(read_fixture('mail_rubyChild').to_s)
|
|
83
|
+
elt = Elt.new
|
|
84
|
+
elt.receive(mailFileChild)
|
|
85
|
+
|
|
86
|
+
assert_equal (mailsCount + 1), Mail.count
|
|
87
|
+
assert_equal (eltsCount + 1), Elt.count
|
|
88
|
+
|
|
89
|
+
assert_equal mailFileChild.subject, ActionMailer::Base.deliveries[0].subject
|
|
90
|
+
assert_equal mailFileChild.references, ActionMailer::Base.deliveries[0].references
|
|
91
|
+
assert_equal elt.created_on, ActionMailer::Base.deliveries[0].date
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_re_receive
|
|
95
|
+
ActionMailer::Base.deliveries = []
|
|
96
|
+
|
|
97
|
+
mailFile = TMail::Mail.parse(read_fixture('mail_ruby').to_s)
|
|
98
|
+
elt = Elt.new
|
|
99
|
+
elt.receive(mailFile)
|
|
100
|
+
|
|
101
|
+
mailsCount = Mail.count
|
|
102
|
+
eltsCount = Elt.count
|
|
103
|
+
deliveredMailsCount = ActionMailer::Base.deliveries.size
|
|
104
|
+
|
|
105
|
+
mail = ActionMailer::Base.deliveries[1]
|
|
106
|
+
|
|
107
|
+
elt = Elt.new
|
|
108
|
+
elt.receive(mail)
|
|
109
|
+
|
|
110
|
+
assert_equal mailsCount, Mail.count
|
|
111
|
+
assert_equal eltsCount, Elt.count
|
|
112
|
+
assert_equal deliveredMailsCount, ActionMailer::Base.deliveries.size
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_receive_change_ID
|
|
116
|
+
ActionMailer::Base.deliveries = []
|
|
117
|
+
|
|
118
|
+
mailFile = TMail::Mail.parse(read_fixture('mail_ruby').to_s)
|
|
119
|
+
elt = Elt.new
|
|
120
|
+
elt.receive(mailFile)
|
|
121
|
+
|
|
122
|
+
mailsCount = Mail.count
|
|
123
|
+
eltsCount = Elt.count
|
|
124
|
+
deliveredMailsCount = ActionMailer::Base.deliveries.size
|
|
125
|
+
|
|
126
|
+
mail = ActionMailer::Base.deliveries[1]
|
|
127
|
+
mail.message_id = "<truc#{mail.message_id[1..-1]}"
|
|
128
|
+
|
|
129
|
+
elt = Elt.new
|
|
130
|
+
elt.receive(mail)
|
|
131
|
+
|
|
132
|
+
assert_equal mailsCount, Mail.count
|
|
133
|
+
assert_equal eltsCount, Elt.count
|
|
134
|
+
assert_equal deliveredMailsCount, ActionMailer::Base.deliveries.size
|
|
135
|
+
end
|
|
14
136
|
end
|
|
137
|
+
|
data/test/unit/notifier_test.rb
CHANGED
|
@@ -2,11 +2,6 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
|
2
2
|
require 'notifier'
|
|
3
3
|
|
|
4
4
|
class NotifierTest < Test::Unit::TestCase
|
|
5
|
-
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
|
|
6
|
-
CHARSET = "utf-8"
|
|
7
|
-
|
|
8
|
-
include ActionMailer::Quoting
|
|
9
|
-
|
|
10
5
|
def setup
|
|
11
6
|
ActionMailer::Base.delivery_method = :test
|
|
12
7
|
ActionMailer::Base.perform_deliveries = true
|
|
@@ -19,13 +14,4 @@ class NotifierTest < Test::Unit::TestCase
|
|
|
19
14
|
def test_truth
|
|
20
15
|
assert true
|
|
21
16
|
end
|
|
22
|
-
|
|
23
|
-
private
|
|
24
|
-
def read_fixture(action)
|
|
25
|
-
IO.readlines("#{FIXTURES_PATH}/notifier/#{action}")
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def encode(subject)
|
|
29
|
-
quoted_printable(subject, CHARSET)
|
|
30
|
-
end
|
|
31
17
|
end
|
data/test/unit/person_test.rb
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
2
|
|
|
3
3
|
class PersonTest < Test::Unit::TestCase
|
|
4
|
-
fixtures :people, LoginEngine.config(:user_table).to_sym
|
|
4
|
+
#fixtures :people, LoginEngine.config(:user_table).to_sym
|
|
5
|
+
fixtures :people, :users, :subscribers
|
|
5
6
|
|
|
6
7
|
def setup
|
|
7
8
|
@person = Person.find(:first)
|