parlement 0.8 → 0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +22 -0
- data/Rakefile +2 -2
- data/app/controllers/account_controller.rb +20 -7
- data/app/controllers/application.rb +17 -4
- data/app/controllers/elt_controller.rb +1 -10
- data/app/controllers/person_controller.rb +1 -1
- data/app/helpers/elt_helper.rb +14 -0
- data/app/models/elt.rb +2 -0
- data/app/models/mail.rb +6 -5
- data/app/models/person.rb +5 -0
- data/app/views/account/_login.rhtml +52 -48
- data/app/views/account/_show.rhtml +13 -12
- data/app/views/elt/_choice.rhtml +11 -2
- data/app/views/elt/_elt.rhtml +38 -50
- data/app/views/elt/new.rhtml +8 -8
- data/app/views/elt/show.rhtml +21 -12
- data/app/views/layouts/top.rhtml +1 -0
- data/app/views/person/_listElts.rhtml +47 -26
- data/app/views/person/show.rhtml +8 -18
- data/config/environment.rb +6 -3
- data/db/ROOT/fr.txt +34 -31
- data/db/ROOT/parlement/test.txt +6 -4
- data/db/development_structure.sql +18 -20
- data/public/engine_files/login_engine/stylesheets/login_engine.css +81 -0
- data/public/images/ParlementLogo_fr.png +0 -0
- data/public/images/comments.gif +0 -0
- data/public/images/vote_minus.png +0 -0
- data/public/images/vote_plus.png +0 -0
- data/public/images/vote_plus_minus.svg +79 -0
- data/public/images/write.png +0 -0
- data/public/images/write.svg +70 -0
- data/public/javascripts/mybehaviour.js +3 -4
- data/public/stylesheets/default.css +449 -0
- data/public/stylesheets/live_tree.css +62 -0
- data/public/stylesheets/scaffold.css +74 -0
- data/script/about +3 -0
- data/script/benchmarker +19 -0
- data/script/breakpointer +3 -0
- data/script/console +3 -0
- data/script/create_db +7 -0
- data/script/destroy +3 -0
- data/script/generate +3 -0
- data/script/plugin +3 -0
- data/script/profiler +34 -0
- data/script/runner +3 -0
- data/script/server +3 -0
- data/test/unit/elt_test.rb +11 -0
- data/test/unit/mail_test.rb +29 -0
- metadata +27 -40
- data/test/fixtures/attachments.yml +0 -13
- data/test/fixtures/choices.yml +0 -13
- data/test/fixtures/elts.yml +0 -36
- data/test/fixtures/img.png +0 -0
- data/test/fixtures/mail/avatar +0 -249
- data/test/fixtures/mail/mail_ruby +0 -39
- data/test/fixtures/mail/mail_rubyChild +0 -30
- data/test/fixtures/mail/mail_rubyChild2 +0 -30
- data/test/fixtures/mail/mail_rubyWithAttachment +0 -7932
- data/test/fixtures/mail/mail_rubyWithSubject +0 -27
- data/test/fixtures/mails.yml +0 -13
- data/test/fixtures/people.yml +0 -68
- data/test/fixtures/subscribers.yml +0 -14
- data/test/fixtures/users.yml +0 -41
- data/test/functional/account_controller_test.rb +0 -317
- data/test/functional/elt_controller_test.rb +0 -87
- data/test/functional/person_controller_test.rb +0 -18
- data/test/functional/subscriber_controller_test.rb +0 -128
- data/test/mocks/test/time.rb +0 -17
- data/test/mocks/test/user_notify.rb +0 -16
- data/test/test_helper.rb +0 -72
@@ -1,27 +0,0 @@
|
|
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
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
-
first_mail:
|
3
|
-
id: 1
|
4
|
-
elt_id: ROOT
|
5
|
-
message: <hello@world>
|
6
|
-
another_mail:
|
7
|
-
id: 2
|
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
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
-
first_person:
|
3
|
-
id: first
|
4
|
-
name: first
|
5
|
-
email: manu@localhost
|
6
|
-
created_on: 2006-03-02
|
7
|
-
echarp:
|
8
|
-
id: echarp
|
9
|
-
name: echarp
|
10
|
-
email: manu@leparlement.org
|
11
|
-
created_on: 2006-03-02
|
12
|
-
another_person:
|
13
|
-
id: second
|
14
|
-
name: second
|
15
|
-
created_on: 2006-03-02
|
16
|
-
bob:
|
17
|
-
id: bob
|
18
|
-
name: bob
|
19
|
-
email: bob@test.com
|
20
|
-
created_on: 2006-03-02
|
21
|
-
bob_other:
|
22
|
-
id: bob_other
|
23
|
-
name: bob_other
|
24
|
-
created_on: 2006-03-02
|
25
|
-
bob2_person:
|
26
|
-
id: bob2
|
27
|
-
name: bob2
|
28
|
-
created_on: 2006-03-02
|
29
|
-
bob3_person:
|
30
|
-
id: bob3
|
31
|
-
name: bob3
|
32
|
-
created_on: 2006-03-02
|
33
|
-
|
34
|
-
existingbob:
|
35
|
-
id: 1000002
|
36
|
-
name: existingbob
|
37
|
-
created_on: 2006-03-02
|
38
|
-
longbob:
|
39
|
-
id: 1000003
|
40
|
-
name: longbob
|
41
|
-
email: longbob@test.com
|
42
|
-
created_on: 2006-03-02
|
43
|
-
|
44
|
-
deletebob1:
|
45
|
-
id: 1000004
|
46
|
-
name: deletebob1
|
47
|
-
email: deletebob1@test.com
|
48
|
-
created_on: 2006-03-02
|
49
|
-
|
50
|
-
deletebob2:
|
51
|
-
id: 1000005
|
52
|
-
name: deletebob2
|
53
|
-
email: deletebob2@test.com
|
54
|
-
created_on: 2006-03-02
|
55
|
-
|
56
|
-
noName:
|
57
|
-
id: noName
|
58
|
-
name: ""
|
59
|
-
created_on: 2006-03-02
|
60
|
-
justForTest:
|
61
|
-
id: justForTest
|
62
|
-
name: hugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhug
|
63
|
-
created_on: 2006-03-02
|
64
|
-
bo:
|
65
|
-
id: bo
|
66
|
-
name: bo
|
67
|
-
created_on: 2006-03-02
|
68
|
-
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
-
first:
|
3
|
-
elt_id: 'ROOT'
|
4
|
-
person_id: 'first'
|
5
|
-
another:
|
6
|
-
elt_id: 'ROOT'
|
7
|
-
person_id: 'second'
|
8
|
-
mail:
|
9
|
-
elt_id: 'mail'
|
10
|
-
person_id: 'echarp'
|
11
|
-
first_mail:
|
12
|
-
elt_id: 'mail'
|
13
|
-
person_id: 'first'
|
14
|
-
|
data/test/fixtures/users.yml
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
-
|
3
|
-
bob:
|
4
|
-
id: 1000001
|
5
|
-
login: bob
|
6
|
-
salted_password: b1de1d1d2aec05df2be6f02995537c1783f08490 # atest
|
7
|
-
salt: bf3c47e71c0bfeb6288c9b6b5e24e15256a0e407
|
8
|
-
email: bob@test.com
|
9
|
-
verified: 1
|
10
|
-
|
11
|
-
existingbob:
|
12
|
-
id: 1000002
|
13
|
-
login: existingbob
|
14
|
-
salted_password: b1de1d1d2aec05df2be6f02995537c1783f08490 # atest
|
15
|
-
salt: bf3c47e71c0bfeb6288c9b6b5e24e15256a0e407
|
16
|
-
email: existingbob@test.com
|
17
|
-
verified: 1
|
18
|
-
|
19
|
-
longbob:
|
20
|
-
id: 1000003
|
21
|
-
login: longbob
|
22
|
-
salted_password: 53427dca242488e885216a579e362ee888c3ebc1 # alongtest
|
23
|
-
salt: d35a9cc89af83799d9a938a74cb06a11d295aa9c
|
24
|
-
email: longbob@test.com
|
25
|
-
verified: 1
|
26
|
-
|
27
|
-
deletebob1:
|
28
|
-
id: 1000004
|
29
|
-
login: deletebob1
|
30
|
-
salted_password: 53427dca242488e885216a579e362ee888c3ebc1 # alongtest
|
31
|
-
salt: d35a9cc89af83799d9a938a74cb06a11d295aa9c
|
32
|
-
email: deletebob1@test.com
|
33
|
-
verified: 1
|
34
|
-
|
35
|
-
deletebob2:
|
36
|
-
id: 1000005
|
37
|
-
login: deletebob2
|
38
|
-
salted_password: 53427dca242488e885216a579e362ee888c3ebc1 # alongtest
|
39
|
-
salt: d35a9cc89af83799d9a938a74cb06a11d295aa9c
|
40
|
-
email: deletebob2@test.com
|
41
|
-
verified: 1
|
@@ -1,317 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
-
require_dependency 'account_controller'
|
3
|
-
require 'breakpoint'
|
4
|
-
|
5
|
-
# ADD to fix advance_by_days= problem
|
6
|
-
require File.dirname(__FILE__) + '/../mocks/test/time'
|
7
|
-
|
8
|
-
# Raise errors beyond the default web-based presentation
|
9
|
-
class AccountController; def rescue_action(e) raise e end; end
|
10
|
-
|
11
|
-
class AccountControllerTest < Test::Unit::TestCase
|
12
|
-
|
13
|
-
fixtures :people, LoginEngine.config(:user_table).to_sym, :elts, :mails, :attachments, :subscribers
|
14
|
-
#fixtures :people, :users
|
15
|
-
|
16
|
-
def setup
|
17
|
-
LoginEngine::CONFIG[:salt] = "test-salt"
|
18
|
-
|
19
|
-
@controller = AccountController.new
|
20
|
-
@request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new
|
21
|
-
@request.host = "localhost"
|
22
|
-
|
23
|
-
@elt = Elt.find '1'
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
""" _ _
|
28
|
-
_ __ ___ ___ _ _ __| | ___ ___ _ __ | |_ _
|
29
|
-
| '_ \/ __|/ _ \ | | |/ _` |/ _ \ / _ \| '_ \| | | | |
|
30
|
-
| |_) \__ \ __/ |_| | (_| | (_) | | (_) | | | | | |_| |
|
31
|
-
| .__/|___/\___|\__,_|\__,_|\___/ \___/|_| |_|_|\__, |
|
32
|
-
|_| |___/
|
33
|
-
"""
|
34
|
-
def test_signup
|
35
|
-
post :login, :person => { :name => "my_bob", :email => "" },
|
36
|
-
:user => { :password => "" }
|
37
|
-
assert_not_nil session[:person]
|
38
|
-
assert_nil session[:user]
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_login_logoff_no_password
|
42
|
-
post :login, :person => { :name => "bob_other", :email => "" },
|
43
|
-
:user => { :password => "" }
|
44
|
-
assert_equal people(:bob_other), @request.session[:person]
|
45
|
-
assert_nil session[:user]
|
46
|
-
get :logout
|
47
|
-
assert_nil session[:person]
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_bad_pseudo
|
51
|
-
post :login, :person => { :name => "yo", :email => "" },
|
52
|
-
:user => { :password => "" }
|
53
|
-
assert_invalid_column_on_record "person", :name
|
54
|
-
assert_success
|
55
|
-
assert_nil session[:person]
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
""" _
|
60
|
-
_ __ __ _ ___ _____ _____ _ __ __| |
|
61
|
-
| '_ \ / _` / __/ __\ \ /\ / / _ \| '__/ _` |
|
62
|
-
| |_) | (_| \__ \__ \\ V V / (_) | | | (_| |
|
63
|
-
| .__/ \__,_|___/___/ \_/\_/ \___/|_| \__,_|
|
64
|
-
|_|
|
65
|
-
"""
|
66
|
-
def test_password_protect
|
67
|
-
post :login, :person => { :name => "bob_another", :email => "" },
|
68
|
-
:user => { :password => "atest" }
|
69
|
-
assert_not_nil session[:person]
|
70
|
-
assert_not_nil session[:user]
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_auth_bob
|
74
|
-
post :login, :person => { :name => "bob", :email => "" },
|
75
|
-
:user => { :password => "atest" }
|
76
|
-
assert_equal people(:bob), @response.session[:person]
|
77
|
-
assert_not_nil session[:person]
|
78
|
-
assert_not_nil session[:user]
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_bad_password
|
82
|
-
post :login, :person => { :name => "newbob", :email => "" },
|
83
|
-
:user => { :password => "newpassword", :password_confirmation => "wrong" }
|
84
|
-
#assert_invalid_column_on_record "user", :password
|
85
|
-
assert_success
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_login_logoff_password
|
89
|
-
post :login, :person => { :name => "my_bob", :email => "" },
|
90
|
-
:user => { :password => "my_bob" }
|
91
|
-
assert_not_nil session[:person]
|
92
|
-
get :logout
|
93
|
-
assert_nil session[:user]
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_invalid_password
|
97
|
-
post :login, :person => { :name => "my_bob", :email => "" },
|
98
|
-
:user => { :password => "my_bob" }
|
99
|
-
assert_not_nil session[:person]
|
100
|
-
assert_not_nil session[:user]
|
101
|
-
get :logout
|
102
|
-
post :login, :person => { :name => "my_bob", :email => "" },
|
103
|
-
:user => { :password => "my_bo" }
|
104
|
-
assert_nil session[:person]
|
105
|
-
assert_nil session[:user]
|
106
|
-
#assert_template_has "login"
|
107
|
-
end
|
108
|
-
|
109
|
-
|
110
|
-
""" _ _
|
111
|
-
___ _ __ ___ __ _(_) |
|
112
|
-
/ _ \ '_ ` _ \ / _` | | |
|
113
|
-
| __/ | | | | | (_| | | |
|
114
|
-
\___|_| |_| |_|\__,_|_|_|
|
115
|
-
"""
|
116
|
-
def test_password_and_email_protect
|
117
|
-
post :login, :person => { :name => "my_bob", :email => "manu@noos.fr" },
|
118
|
-
:user => { :password => "my_bob" }
|
119
|
-
assert_not_nil session[:person]
|
120
|
-
assert_not_nil session[:user]
|
121
|
-
assert_equal "my_bob", @request.session[:person].name
|
122
|
-
assert_equal "manu@noos.fr", @request.session[:user].email
|
123
|
-
assert_not_equal @request.session[:person].email, @request.session[:user].email
|
124
|
-
assert_not_nil @request.session[:user].security_token
|
125
|
-
end
|
126
|
-
|
127
|
-
def invalid_email
|
128
|
-
post :login, :person => { :name => "bob", :email => "" },
|
129
|
-
:user => { :password => "not_correct" }
|
130
|
-
|
131
|
-
assert_nil session[:person]
|
132
|
-
assert_nil session[:user]
|
133
|
-
|
134
|
-
assert_template_has "login"
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_email_protect
|
138
|
-
LoginEngine::CONFIG[:use_email_notification] = true
|
139
|
-
|
140
|
-
|
141
|
-
ActionMailer::Base.deliveries = []
|
142
|
-
|
143
|
-
#@request.session['return-to'] = "/bogus/location"
|
144
|
-
|
145
|
-
assert_equal 5, User.count
|
146
|
-
post :login, :person => { :name => "newbob", :email => "newbob@test.com" },
|
147
|
-
:user => { :password => "newpassword" }
|
148
|
-
assert_not_nil session[:person]
|
149
|
-
assert_not_nil session[:user]
|
150
|
-
assert_equal 6, User.count
|
151
|
-
|
152
|
-
assert_equal 1, ActionMailer::Base.deliveries.size
|
153
|
-
mail = ActionMailer::Base.deliveries[0]
|
154
|
-
assert_equal "newbob@test.com", mail.to_addrs[0].to_s
|
155
|
-
assert_match /login:\s+\w+\n/, mail.encoded
|
156
|
-
assert_match /password:\s+\w+\n/, mail.encoded
|
157
|
-
mail.encoded =~ /key=(.*?)"/
|
158
|
-
key = $1
|
159
|
-
|
160
|
-
user = User.find_by_email("newbob@test.com")
|
161
|
-
person = Person.find_by_name(user.login)
|
162
|
-
assert_not_nil user
|
163
|
-
assert_not_nil person
|
164
|
-
assert_equal 1, user.verified
|
165
|
-
assert_not_equal user.email, person.email
|
166
|
-
|
167
|
-
# First past the expiration.
|
168
|
-
Time.advance_by_days = 1
|
169
|
-
get :check_key, :user=> { :id => "#{user.id}" }, :key => "#{key}"
|
170
|
-
Time.advance_by_days = 0
|
171
|
-
user = User.find_by_email("newbob@test.com")
|
172
|
-
person = Person.find_by_name(user.login)
|
173
|
-
assert_not_equal user.email, person.email
|
174
|
-
|
175
|
-
# Then a bogus key.
|
176
|
-
get :check_key, :user=> { :id => "#{user.id}" }, :key => "boguskey"
|
177
|
-
user = User.find_by_email("newbob@test.com")
|
178
|
-
person = Person.find_by_name(user.login) if user != nil
|
179
|
-
assert_not_equal user.email, person.email
|
180
|
-
|
181
|
-
# Now the real one.
|
182
|
-
get :check_key, :user=> { :id => "#{user.id}" }, :key => "#{key}"
|
183
|
-
user = User.find_by_email("newbob@test.com")
|
184
|
-
person = Person.find_by_name(user.login)
|
185
|
-
assert_equal user.email, person.email
|
186
|
-
|
187
|
-
post :login, :person => { :name => "newbob", :email => "" },
|
188
|
-
:user => { :password => "newpassword" }
|
189
|
-
assert_not_nil session[:person]
|
190
|
-
assert_not_nil session[:user]
|
191
|
-
get :logout
|
192
|
-
end
|
193
|
-
|
194
|
-
def test_forgotten_password
|
195
|
-
LoginEngine::CONFIG[:use_email_notification] = true
|
196
|
-
|
197
|
-
ActionMailer::Base.deliveries = []
|
198
|
-
|
199
|
-
post :login, :person => { :name => "bob", :email => "bob@test.com" },
|
200
|
-
:user => { :password => "" }
|
201
|
-
assert_nil session[:person]
|
202
|
-
assert_nil session[:user]
|
203
|
-
|
204
|
-
assert_equal 1, ActionMailer::Base.deliveries.size
|
205
|
-
mail = ActionMailer::Base.deliveries[0]
|
206
|
-
assert_equal "bob@test.com", mail.to_addrs[0].to_s
|
207
|
-
mail.encoded =~ /key=(.*?)"/
|
208
|
-
key = $1
|
209
|
-
|
210
|
-
# First past the expiration.
|
211
|
-
Time.advance_by_days = 1
|
212
|
-
post :login, :person => { :name => "bob", :email => key },
|
213
|
-
:user => { :password => "newpassword" }
|
214
|
-
assert_nil session[:person]
|
215
|
-
assert_nil session[:user]
|
216
|
-
Time.advance_by_days = 0
|
217
|
-
|
218
|
-
# Then a bogus key.
|
219
|
-
post :login, :person => { :name => "bob", :email => "boguskey" },
|
220
|
-
:user => { :password => "newpassword" }
|
221
|
-
assert_nil session[:person]
|
222
|
-
assert_nil session[:user]
|
223
|
-
|
224
|
-
# Now the real one.
|
225
|
-
post :login, :person => { :name => "bob", :email => key },
|
226
|
-
:user => { :password => "newpassword" }
|
227
|
-
assert_not_nil session[:person]
|
228
|
-
assert_not_nil session[:user]
|
229
|
-
get :logout
|
230
|
-
|
231
|
-
post :login, :person => { :name => "bob", :email => "" },
|
232
|
-
:user => { :password => "password" }
|
233
|
-
assert_nil session[:person]
|
234
|
-
assert_nil session[:user]
|
235
|
-
post :login, :person => { :name => "bob", :email => "" },
|
236
|
-
:user => { :password => "newpassword" }
|
237
|
-
assert_not_nil session[:person]
|
238
|
-
assert_not_nil session[:user]
|
239
|
-
get :logout
|
240
|
-
end
|
241
|
-
|
242
|
-
def test_update_subscribe
|
243
|
-
post :login, :person => { :name => "bob_other", :email => "" },
|
244
|
-
:user => { :password => "" }, :divId => 'author_ROOT'
|
245
|
-
|
246
|
-
controller = @controller
|
247
|
-
@controller = EltController.new
|
248
|
-
post :create, :id => @elt.id, :commit => "Propose!",
|
249
|
-
:elt =>{
|
250
|
-
:body => "+1", :subject => "test_create", :parent_id => @elt.id }
|
251
|
-
@controller = controller
|
252
|
-
get :logout
|
253
|
-
|
254
|
-
post :login, :person => { :name => "bob_other", :email => "" },
|
255
|
-
:user => { :password => "" }, :divId => 'author_1'
|
256
|
-
|
257
|
-
assert_success
|
258
|
-
assert_not_nil session[:person]
|
259
|
-
assert_template 'account/_show'
|
260
|
-
|
261
|
-
assert_tag :tag => "div", :attributes => { :class => "choicesToUpdate" }
|
262
|
-
end
|
263
|
-
|
264
|
-
""" _
|
265
|
-
__ ___ ____ _| |_ __ _ _ __
|
266
|
-
/ _` \ \ / / _` | __/ _` | '__|
|
267
|
-
| (_| |\ V / (_| | || (_| | |
|
268
|
-
\__,_| \_/ \__,_|\__\__,_|_|
|
269
|
-
"""
|
270
|
-
def test_set_avatar
|
271
|
-
ActionMailer::Base.deliveries = []
|
272
|
-
post :login, :person => { :name => "bob_other", :email => "" },
|
273
|
-
:user => { :password => "" }, :divId => 'author_ROOT'
|
274
|
-
|
275
|
-
eltsCount = Elt.count
|
276
|
-
img = uploaded_png("#{File.expand_path(RAILS_ROOT)}/test/fixtures/img.png")
|
277
|
-
post :setAvatar, :person => { :image => img }
|
278
|
-
assert_equal eltsCount + 2, Elt.count
|
279
|
-
assert Person.find('bob_other').image.match(/^\/attachment\/file\/imgpng\/img.png$/)
|
280
|
-
|
281
|
-
#puts ActionMailer::Base.deliveries.last.to_yaml
|
282
|
-
assert_equal 3, ActionMailer::Base.deliveries.last.parts.size
|
283
|
-
assert_equal "image/png", ActionMailer::Base.deliveries.last.parts.last.content_type
|
284
|
-
assert_equal "img.png", ActionMailer::Base.deliveries.last.parts.last.disposition_param('filename')
|
285
|
-
assert_equal 90173, ActionMailer::Base.deliveries.last.parts.last.body.size
|
286
|
-
end
|
287
|
-
|
288
|
-
private
|
289
|
-
# get us an object that represents an uploaded file
|
290
|
-
def uploaded_file(path, content_type="application/octet-stream", filename=nil)
|
291
|
-
filename ||= File.basename(path)
|
292
|
-
t = Tempfile.new(filename)
|
293
|
-
FileUtils.copy_file(path, t.path)
|
294
|
-
(class << t; self; end;).class_eval do
|
295
|
-
alias local_path path
|
296
|
-
define_method(:original_filename) { filename }
|
297
|
-
define_method(:content_type) { content_type }
|
298
|
-
end
|
299
|
-
return t
|
300
|
-
end
|
301
|
-
|
302
|
-
# a PNG helper
|
303
|
-
def uploaded_png(path, filename=nil)
|
304
|
-
uploaded_file(path, 'image/png', filename)
|
305
|
-
end
|
306
|
-
|
307
|
-
# a JPEG helper
|
308
|
-
def uploaded_jpeg(path, filename=nil)
|
309
|
-
uploaded_file(path, 'image/jpeg', filename)
|
310
|
-
end
|
311
|
-
|
312
|
-
# a GIF helper
|
313
|
-
def uploaded_gif(path, filename=nil)
|
314
|
-
uploaded_file(path, 'image/gif', filename)
|
315
|
-
end
|
316
|
-
end
|
317
|
-
|