parlement 0.8 → 0.9

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.
Files changed (70) hide show
  1. data/CHANGES +22 -0
  2. data/Rakefile +2 -2
  3. data/app/controllers/account_controller.rb +20 -7
  4. data/app/controllers/application.rb +17 -4
  5. data/app/controllers/elt_controller.rb +1 -10
  6. data/app/controllers/person_controller.rb +1 -1
  7. data/app/helpers/elt_helper.rb +14 -0
  8. data/app/models/elt.rb +2 -0
  9. data/app/models/mail.rb +6 -5
  10. data/app/models/person.rb +5 -0
  11. data/app/views/account/_login.rhtml +52 -48
  12. data/app/views/account/_show.rhtml +13 -12
  13. data/app/views/elt/_choice.rhtml +11 -2
  14. data/app/views/elt/_elt.rhtml +38 -50
  15. data/app/views/elt/new.rhtml +8 -8
  16. data/app/views/elt/show.rhtml +21 -12
  17. data/app/views/layouts/top.rhtml +1 -0
  18. data/app/views/person/_listElts.rhtml +47 -26
  19. data/app/views/person/show.rhtml +8 -18
  20. data/config/environment.rb +6 -3
  21. data/db/ROOT/fr.txt +34 -31
  22. data/db/ROOT/parlement/test.txt +6 -4
  23. data/db/development_structure.sql +18 -20
  24. data/public/engine_files/login_engine/stylesheets/login_engine.css +81 -0
  25. data/public/images/ParlementLogo_fr.png +0 -0
  26. data/public/images/comments.gif +0 -0
  27. data/public/images/vote_minus.png +0 -0
  28. data/public/images/vote_plus.png +0 -0
  29. data/public/images/vote_plus_minus.svg +79 -0
  30. data/public/images/write.png +0 -0
  31. data/public/images/write.svg +70 -0
  32. data/public/javascripts/mybehaviour.js +3 -4
  33. data/public/stylesheets/default.css +449 -0
  34. data/public/stylesheets/live_tree.css +62 -0
  35. data/public/stylesheets/scaffold.css +74 -0
  36. data/script/about +3 -0
  37. data/script/benchmarker +19 -0
  38. data/script/breakpointer +3 -0
  39. data/script/console +3 -0
  40. data/script/create_db +7 -0
  41. data/script/destroy +3 -0
  42. data/script/generate +3 -0
  43. data/script/plugin +3 -0
  44. data/script/profiler +34 -0
  45. data/script/runner +3 -0
  46. data/script/server +3 -0
  47. data/test/unit/elt_test.rb +11 -0
  48. data/test/unit/mail_test.rb +29 -0
  49. metadata +27 -40
  50. data/test/fixtures/attachments.yml +0 -13
  51. data/test/fixtures/choices.yml +0 -13
  52. data/test/fixtures/elts.yml +0 -36
  53. data/test/fixtures/img.png +0 -0
  54. data/test/fixtures/mail/avatar +0 -249
  55. data/test/fixtures/mail/mail_ruby +0 -39
  56. data/test/fixtures/mail/mail_rubyChild +0 -30
  57. data/test/fixtures/mail/mail_rubyChild2 +0 -30
  58. data/test/fixtures/mail/mail_rubyWithAttachment +0 -7932
  59. data/test/fixtures/mail/mail_rubyWithSubject +0 -27
  60. data/test/fixtures/mails.yml +0 -13
  61. data/test/fixtures/people.yml +0 -68
  62. data/test/fixtures/subscribers.yml +0 -14
  63. data/test/fixtures/users.yml +0 -41
  64. data/test/functional/account_controller_test.rb +0 -317
  65. data/test/functional/elt_controller_test.rb +0 -87
  66. data/test/functional/person_controller_test.rb +0 -18
  67. data/test/functional/subscriber_controller_test.rb +0 -128
  68. data/test/mocks/test/time.rb +0 -17
  69. data/test/mocks/test/user_notify.rb +0 -16
  70. data/test/test_helper.rb +0 -72
@@ -1,87 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require 'elt_controller'
3
-
4
- # Re-raise errors caught by the controller.
5
- class EltController; def rescue_action(e) raise e end; end
6
-
7
- class EltControllerTest < Test::Unit::TestCase
8
- fixtures :people, LoginEngine.config(:user_table).to_sym, :elts, :mails, :attachments, :subscribers
9
-
10
- def setup
11
- @controller = EltController.new
12
- @request = ActionController::TestRequest.new
13
- @response = ActionController::TestResponse.new
14
-
15
- @elt = Elt.find 'ROOT'
16
- end
17
-
18
- def test_preview
19
- post :preview, :id => @elt.id, :commit => "Propose!",
20
- :elt =>{
21
- :body => "Un joli test", :subject => "test_create", :parent_id => @elt.id }
22
- assert_equal 3, @elt.children_count
23
- assert_response :success
24
- end
25
-
26
- def test_create
27
- post :create, :id => @elt.id, :commit => "Propose!",
28
- :elt =>{
29
- :body => "Un joli test", :subject => "test_create", :parent_id => @elt.id }
30
- assert_equal 4, @elt.children_count
31
- assert_response :success
32
- end
33
-
34
- def test_create_login
35
- login
36
- post :create, :id => @elt.id, :commit => "Propose!",
37
- :elt =>{
38
- :body => "Un joli test", :subject => "test_create", :parent_id => @elt.id }
39
- assert_equal 4, @elt.children_count
40
- end
41
-
42
- def test_vote_pro
43
- login
44
- post :vote, :id => @elt.id, :choice => { :value => "+1" }, :commit => "Vote!"
45
- assert_equal 4, @elt.children_count
46
- assert_equal 1, @elt.result
47
- end
48
-
49
- def test_vote_con
50
- login
51
- post :vote, :id => @elt.id, :choice => { :value => "-1" }, :commit => "Vote!"
52
- assert_equal 4, @elt.children_count
53
- assert_equal -1, @elt.result
54
- end
55
-
56
- def test_vote_zero
57
- login
58
- post :vote, :id => @elt.id, :choice => { :value => "+1" }, :commit => "Vote!"
59
- post :vote, :id => @elt.id, :choice => { :value => "+1" }, :commit => "Vote!"
60
- assert_equal 5, @elt.children_count
61
- assert_equal 0, @elt.result
62
-
63
- post :vote, :id => @elt.id, :choice => { :value => "-1" }, :commit => "Vote!"
64
- post :vote, :id => @elt.id, :choice => { :value => "-1" }, :commit => "Vote!"
65
- assert_equal 7, @elt.children_count
66
- assert_equal 0, @elt.result
67
- end
68
-
69
- def test_fight_spam
70
- post :create, :id => @elt.id, :commit => "Propose!", :elt => {
71
- :parent_id => @elt.id,
72
- :subject => "cheap_atenolol<a_href='http_pohyis.org_tramadol_'",
73
- :body => "Un spam" }
74
- assert_equal 3, @elt.children_count
75
-
76
- post :create, :id => @elt.id, :commit => "Propose!", :elt => {
77
- :parent_id => @elt.id,
78
- :subject => "href='http_pohyis.org_tramadol_'",
79
- :body => "Un spam" }
80
- assert_equal 3, @elt.children_count
81
-
82
- post :create, :id => @elt.id, :commit => "Propose!", :elt => {
83
- :parent_id => @elt.id, :subject => ">'", :body => "Un spam" }
84
- assert_equal 3, @elt.children_count
85
- end
86
- end
87
-
@@ -1,18 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require 'person_controller'
3
-
4
- # Re-raise errors caught by the controller.
5
- class PersonController; def rescue_action(e) raise e end; end
6
-
7
- class PersonControllerTest < Test::Unit::TestCase
8
- def setup
9
- @controller = PersonController.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- end
13
-
14
- # Replace this with your real tests.
15
- def test_truth
16
- assert true
17
- end
18
- end
@@ -1,128 +0,0 @@
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
-
@@ -1,17 +0,0 @@
1
- require 'time'
2
-
3
- Time.class_eval {
4
- @@advance_by_days = 0
5
- cattr_accessor :advance_by_days
6
-
7
- class << Time
8
- alias now_old now
9
- def now
10
- if Time.advance_by_days != 0
11
- return Time.at(now_old.to_i + Time.advance_by_days * 60 * 60 * 24 + 1)
12
- else
13
- now_old
14
- end
15
- end
16
- end
17
- }
@@ -1,16 +0,0 @@
1
- require 'models/user_notify.rb'
2
-
3
- ActionMailer::Base.class_eval {
4
- @@inject_one_error = false
5
- cattr_accessor :inject_one_error
6
-
7
- private
8
- def perform_delivery_test(mail)
9
- if inject_one_error
10
- ActionMailer::Base::inject_one_error = false
11
- raise "Failed to send email" if raise_delivery_errors
12
- else
13
- deliveries << mail
14
- end
15
- end
16
- }
data/test/test_helper.rb DELETED
@@ -1,72 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
- require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3
- require 'test_help'
4
-
5
- class Test::Unit::TestCase
6
- FIXTURES_PATH = File.dirname(__FILE__) + '/fixtures'
7
- CHARSET = "utf-8"
8
-
9
- include ActionMailer::Quoting
10
-
11
-
12
- # Transactional fixtures accelerate your tests by wrapping each test method
13
- # in a transaction that's rolled back on completion. This ensures that the
14
- # test database remains unchanged so your fixtures don't have to be reloaded
15
- # between every test method. Fewer database queries means faster tests.
16
- #
17
- # Read Mike Clark's excellent walkthrough at
18
- # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
19
- #
20
- # Every Active Record database supports transactions except MyISAM tables
21
- # in MySQL. Turn off transactional fixtures in this case; however, if you
22
- # don't care one way or the other, switching from MyISAM to InnoDB tables
23
- # is recommended.
24
- self.use_transactional_fixtures = true
25
-
26
- # Instantiated fixtures are slow, but give you @david where otherwise you
27
- # would need people(:david). If you don't want to migrate your existing
28
- # test cases which use the @david style and don't mind the speed hit (each
29
- # instantiated fixtures translates to a database query per test method),
30
- # then set this back to true.
31
- self.use_instantiated_fixtures = false
32
-
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
71
- end
72
-