parlement 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,8 +17,7 @@ class MailTest < Test::Unit::TestCase
17
17
  mailFile = TMail::Mail.parse(read_fixture('mail_ruby').to_s)
18
18
  #print "mailFile envelope-to: ", mailFile["envelope-to"]
19
19
  #puts
20
- elt = Elt.new
21
- elt.receive(mailFile)
20
+ Mail.receive(mailFile)
22
21
 
23
22
  assert_equal (mailsCount + 2), Mail.count
24
23
  assert_equal (eltsCount + 2), Elt.count
@@ -35,8 +34,7 @@ class MailTest < Test::Unit::TestCase
35
34
  eltsCount = Elt.count
36
35
 
37
36
  mailFile = TMail::Mail.parse(read_fixture('mail_rubyWithSubject').to_s)
38
- elt = Elt.new
39
- elt.receive(mailFile)
37
+ Mail.receive(mailFile)
40
38
 
41
39
  assert_equal (mailsCount + 2), Mail.count
42
40
  assert_equal (eltsCount + 2), Elt.count
@@ -52,8 +50,7 @@ class MailTest < Test::Unit::TestCase
52
50
  eltsCount = Elt.count
53
51
 
54
52
  mailFile = TMail::Mail.parse(read_fixture('mail_rubyWithAttachment').to_s)
55
- elt = Elt.new
56
- elt.receive(mailFile)
53
+ elt = Mail.receive(mailFile).elt
57
54
 
58
55
  assert_equal (mailsCount + 2), Mail.count
59
56
  # Just one file as an attachment
@@ -70,41 +67,37 @@ class MailTest < Test::Unit::TestCase
70
67
  def test_receiveChild
71
68
  ActionMailer::Base.deliveries = []
72
69
 
73
- elt = Elt.new
74
70
  mailFile = TMail::Mail.parse(read_fixture('mail_ruby').to_s)
75
- elt.receive(mailFile)
71
+ Mail.receive(mailFile)
76
72
 
77
73
  ActionMailer::Base.deliveries = []
78
74
  mailsCount = Mail.count
79
75
  eltsCount = Elt.count
80
76
 
81
77
  mailFileChild = TMail::Mail.parse(read_fixture('mail_rubyChild').to_s)
82
- elt = Elt.new
83
- elt.receive(mailFileChild)
78
+ Mail.receive(mailFileChild)
84
79
 
85
80
  assert_equal (mailsCount + 1), Mail.count
86
81
  assert_equal (eltsCount + 1), Elt.count
87
82
 
88
83
  assert_equal mailFileChild.subject, ActionMailer::Base.deliveries[0].subject
89
84
  assert_equal mailFileChild.references, ActionMailer::Base.deliveries[0].references
90
- assert_equal elt.created_on, ActionMailer::Base.deliveries[0].date
85
+ assert_equal mailFileChild.date, ActionMailer::Base.deliveries[0].date
91
86
  end
92
87
 
93
88
  # Not used, just make sure mails are entered chronologically
94
89
  def est_receiveChildThenParent
95
90
  ActionMailer::Base.deliveries = []
96
91
 
97
- elt = Elt.new
98
92
  mailFile = TMail::Mail.parse(read_fixture('mail_rubyChild').to_s)
99
- elt.receive(mailFile)
93
+ elt = Mail.receive(mailFile).elt
100
94
 
101
95
  ActionMailer::Base.deliveries = []
102
96
  mailsCount = Mail.count
103
97
  eltsCount = Elt.count
104
98
 
105
99
  mailFileChild = TMail::Mail.parse(read_fixture('mail_ruby').to_s)
106
- eltParent = Elt.new
107
- eltParent.receive(mailFileChild)
100
+ eltParent = Mail.receive(mailFileChild).elt
108
101
 
109
102
  assert_equal (mailsCount + 1), Mail.count
110
103
  assert_equal (eltsCount + 1), Elt.count
@@ -116,8 +109,7 @@ class MailTest < Test::Unit::TestCase
116
109
  ActionMailer::Base.deliveries = []
117
110
 
118
111
  mailFile = TMail::Mail.parse(read_fixture('mail_ruby').to_s)
119
- elt = Elt.new
120
- elt.receive(mailFile)
112
+ Mail.receive(mailFile)
121
113
 
122
114
  mailsCount = Mail.count
123
115
  eltsCount = Elt.count
@@ -125,8 +117,7 @@ class MailTest < Test::Unit::TestCase
125
117
 
126
118
  mail = ActionMailer::Base.deliveries[1]
127
119
 
128
- elt = Elt.new
129
- elt.receive(mail)
120
+ Mail.receive(mail)
130
121
 
131
122
  assert_equal mailsCount, Mail.count
132
123
  assert_equal eltsCount, Elt.count
@@ -137,8 +128,7 @@ class MailTest < Test::Unit::TestCase
137
128
  ActionMailer::Base.deliveries = []
138
129
 
139
130
  mailFile = TMail::Mail.parse(read_fixture('mail_ruby').to_s)
140
- elt = Elt.new
141
- elt.receive(mailFile)
131
+ Mail.receive(mailFile)
142
132
 
143
133
  mailsCount = Mail.count
144
134
  eltsCount = Elt.count
@@ -154,8 +144,7 @@ class MailTest < Test::Unit::TestCase
154
144
  #print "new mail.message_Id: ", mail.message_id
155
145
  #puts
156
146
 
157
- elt = Elt.new
158
- elt.receive(mail)
147
+ Mail.receive(mail)
159
148
 
160
149
  assert_equal mailsCount, Mail.count
161
150
  assert_equal eltsCount, Elt.count
@@ -171,8 +160,7 @@ class MailTest < Test::Unit::TestCase
171
160
 
172
161
 
173
162
  mailFile = TMail::Mail.parse(read_fixture('mail_ruby').to_s)
174
- elt = Elt.new
175
- elt.receive(mailFile)
163
+ elt = Mail.receive(mailFile).elt
176
164
 
177
165
  #print mailFile.to_yaml
178
166
  #puts
@@ -180,11 +168,47 @@ class MailTest < Test::Unit::TestCase
180
168
 
181
169
  #puts elt.body
182
170
 
183
- #puts elt.body =~ /même/
184
171
  assert elt.body =~ /même/
172
+ end
185
173
 
186
- #mail = ActionMailer::Base.deliveries[1]
187
- #puts mail.to_yaml
174
+ def test_receive_no_choice
175
+ ActionMailer::Base.deliveries = []
176
+
177
+ mailFile = TMail::Mail.parse(read_fixture('mail_ruby').to_s)
178
+ elt = Mail.receive(mailFile).elt
179
+ choicesCount = 0
180
+
181
+ elt.voters.reload
182
+ assert_equal choicesCount+1, elt.voters.size
183
+ end
184
+
185
+ def test_receive_choice
186
+ ActionMailer::Base.deliveries = []
187
+
188
+ mailFile = TMail::Mail.parse(read_fixture('mail_ruby').to_s)
189
+ elt = Mail.receive(mailFile).elt
190
+
191
+ eltChild = Mail.receive(TMail::Mail.parse(read_fixture('mail_rubyChild').to_s)).elt
192
+
193
+ eltChild.voters.reload
194
+ assert_equal 1, eltChild.voters.size
195
+
196
+ assert_equal 1, eltChild.result
197
+ assert_equal -1, elt.result
198
+ end
199
+
200
+ def test_receive_second_choice
201
+ elt = Mail.receive(TMail::Mail.parse(read_fixture('mail_ruby').to_s)).elt
202
+
203
+ eltChild = Mail.receive(TMail::Mail.parse(read_fixture('mail_rubyChild').to_s)).elt
204
+
205
+ eltChild2 = Mail.receive(TMail::Mail.parse(read_fixture('mail_rubyChild2').to_s)).elt
206
+
207
+ elt.choices.reload
208
+ elt.voters.reload
209
+ assert 1, elt.choices.size
210
+ assert_equal 1, eltChild2.result
211
+ assert_equal 1, elt.result
188
212
  end
189
213
  end
190
214
 
@@ -4,7 +4,7 @@ class SubscriberTest < Test::Unit::TestCase
4
4
  fixtures :people, :users, :elts, :mails, :attachments, :subscribers
5
5
 
6
6
  def setup
7
- @elt = Elt.find('ROOT')
7
+ @elt = Elt.find('mail')
8
8
  @person = Person.find('first')
9
9
  end
10
10
 
@@ -31,5 +31,12 @@ class SubscriberTest < Test::Unit::TestCase
31
31
  @person.subscribed_elts.delete(@elt)
32
32
  assert_equal (num - 1), @person.subscribed_elts.size
33
33
  end
34
+
35
+ def test_all_recipients
36
+ num = @elt.all_recipients.size
37
+ @elt.subscribers << Person.find('bob')
38
+ @elt.parent.subscribers << Person.find('bob2')
39
+ assert_equal (num + 2), @elt.all_recipients.size
40
+ end
34
41
  end
35
42
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: parlement
5
5
  version: !ruby/object:Gem::Version
6
- version: "0.4"
7
- date: 2006-04-17 00:00:00 +02:00
6
+ version: "0.5"
7
+ date: 2006-05-20 00:00:00 +02:00
8
8
  summary: Trusted Direct Democracy on a forum
9
9
  require_paths:
10
10
  - lib
@@ -54,6 +54,7 @@ files:
54
54
  - app/models/person.rb
55
55
  - app/models/mail.rb
56
56
  - app/models/elt.rb
57
+ - app/models/choice.rb
57
58
  - app/models/mail_notify.rb
58
59
  - app/models/user_notify.rb
59
60
  - app/views/layouts
@@ -94,8 +95,10 @@ files:
94
95
  - config/environments/user_environment.rb
95
96
  - db/schema.sql
96
97
  - db/schema.rb
98
+ - db/migrate
97
99
  - db/ROOT
98
100
  - db/development_structure.sql
101
+ - db/migrate/001_create_choices.rb
99
102
  - db/ROOT/perso
100
103
  - db/ROOT/parlement.txt
101
104
  - db/ROOT/perso.txt
@@ -109,10 +112,13 @@ files:
109
112
  - db/ROOT/parlement/news.txt
110
113
  - db/ROOT/parlement/top-politics.txt
111
114
  - db/ROOT/parlement/ddRing.txt
115
+ - db/ROOT/parlement/our-constitution.txt
112
116
  - db/ROOT/parlement/security/anonymity.txt
113
117
  - db/ROOT/parlement/news/release0.1.txt
114
118
  - db/ROOT/parlement/news/release0.2.txt
115
119
  - db/ROOT/parlement/news/release0.3.txt
120
+ - db/ROOT/parlement/news/release0.4.txt
121
+ - db/ROOT/parlement/news/release0.5.txt
116
122
  - lib/localization.rb
117
123
  - lib/tasks
118
124
  - lib/data_import.rb
@@ -171,10 +177,12 @@ files:
171
177
  - test/fixtures/mail
172
178
  - test/fixtures/subscribers.yml
173
179
  - test/fixtures/mail_notify
180
+ - test/fixtures/choices.yml
174
181
  - test/fixtures/mail/mail_ruby
175
182
  - test/fixtures/mail/mail_rubyWithSubject
176
183
  - test/fixtures/mail/mail_rubyWithAttachment
177
184
  - test/fixtures/mail/mail_rubyChild
185
+ - test/fixtures/mail/mail_rubyChild2
178
186
  - test/functional/subscriber_controller_test.rb
179
187
  - test/functional/account_controller_test.rb
180
188
  - test/functional/person_controller_test.rb
@@ -190,6 +198,7 @@ files:
190
198
  - test/unit/attachment_test.rb
191
199
  - test/unit/mail_notify_test.rb
192
200
  - test/unit/subscriber_test.rb
201
+ - test/unit/choice_test.rb
193
202
  - vendor/plugins
194
203
  - vendor/plugins/login_engine
195
204
  - vendor/plugins/engines
@@ -335,6 +344,7 @@ test_files:
335
344
  - test/unit/attachment_test.rb
336
345
  - test/unit/mail_notify_test.rb
337
346
  - test/unit/subscriber_test.rb
347
+ - test/unit/choice_test.rb
338
348
  rdoc_options: []
339
349
 
340
350
  extra_rdoc_files: []