parlement 0.3 → 0.4

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 (122) hide show
  1. data/CHANGES +16 -0
  2. data/README +36 -3
  3. data/Rakefile +8 -12
  4. data/app/controllers/account_controller.rb +2 -0
  5. data/app/controllers/elt_controller.rb +1 -5
  6. data/app/controllers/subscriber_controller.rb +1 -1
  7. data/app/helpers/elt_helper.rb +30 -10
  8. data/app/models/elt.rb +2 -1
  9. data/app/models/mail.rb +41 -41
  10. data/app/models/mail_notify.rb +27 -10
  11. data/app/views/account/_login.rhtml +9 -7
  12. data/app/views/account/_show.rhtml +4 -4
  13. data/app/views/elt/_elt.rhtml +52 -51
  14. data/app/views/elt/_list.rhtml +22 -14
  15. data/app/views/elt/new.rhtml +1 -1
  16. data/app/views/elt/show.rhtml +15 -16
  17. data/app/views/layouts/top.rhtml +13 -1
  18. data/app/views/person/show.rhtml +1 -7
  19. data/config/boot.rb +32 -7
  20. data/config/database.yml +3 -0
  21. data/config/environment.rb +3 -1
  22. data/config/environments/development.rb +1 -1
  23. data/db/ROOT/parlement/ddRing.txt +14 -0
  24. data/db/ROOT/parlement/top-politics.txt +12 -0
  25. data/db/ROOT/perso.txt +1 -1
  26. data/db/development_structure.sql +30 -16
  27. data/db/schema.rb +18 -10
  28. data/db/schema.sql +34 -34
  29. data/public/javascripts/application.js +2 -0
  30. data/public/javascripts/blank.gif +0 -0
  31. data/public/javascripts/borders.js +687 -0
  32. data/public/javascripts/controls.js +95 -30
  33. data/public/javascripts/dragdrop.js +161 -21
  34. data/public/javascripts/effects.js +310 -211
  35. data/public/javascripts/ie7-load.htc +1 -0
  36. data/public/javascripts/prototype.js +228 -28
  37. data/test/fixtures/attachments.yml +3 -0
  38. data/test/fixtures/mail/mail_ruby +1 -0
  39. data/test/fixtures/people.yml +14 -0
  40. data/test/functional/account_controller_test.rb +3 -2
  41. data/test/unit/mail_notify_test.rb +2 -0
  42. data/test/unit/mail_test.rb +59 -6
  43. data/test/unit/person_test.rb +1 -1
  44. data/vendor/plugins/engines/CHANGELOG +92 -0
  45. data/vendor/plugins/engines/MIT-LICENSE +21 -0
  46. data/vendor/plugins/engines/README +325 -39
  47. data/vendor/plugins/engines/generators/engine/USAGE +26 -0
  48. data/vendor/plugins/engines/generators/engine/engine_generator.rb +199 -0
  49. data/vendor/plugins/engines/generators/engine/templates/README +85 -0
  50. data/vendor/plugins/engines/generators/engine/templates/init_engine.erb +13 -0
  51. data/vendor/plugins/engines/generators/engine/templates/install.erb +4 -0
  52. data/vendor/plugins/engines/generators/engine/templates/lib/engine.erb +6 -0
  53. data/vendor/plugins/engines/generators/engine/templates/licenses/GPL +18 -0
  54. data/vendor/plugins/engines/generators/engine/templates/licenses/LGPL +19 -0
  55. data/vendor/plugins/engines/generators/engine/templates/licenses/MIT +22 -0
  56. data/vendor/plugins/engines/generators/engine/templates/licenses/None +1 -0
  57. data/vendor/plugins/engines/generators/engine/templates/public/javascripts/engine.js +0 -0
  58. data/vendor/plugins/engines/generators/engine/templates/public/stylesheets/engine.css +0 -0
  59. data/vendor/plugins/engines/generators/engine/templates/tasks/engine.rake +0 -0
  60. data/vendor/plugins/engines/generators/engine/templates/test/test_helper.erb +13 -0
  61. data/vendor/plugins/engines/init.rb +18 -3
  62. data/vendor/plugins/engines/lib/bundles/require_resource.rb +124 -0
  63. data/vendor/plugins/engines/lib/bundles.rb +77 -0
  64. data/vendor/plugins/engines/lib/{action_mailer_extensions.rb → engines/action_mailer_extensions.rb} +15 -36
  65. data/vendor/plugins/engines/lib/{action_view_extensions.rb → engines/action_view_extensions.rb} +40 -33
  66. data/vendor/plugins/engines/lib/engines/active_record_extensions.rb +19 -0
  67. data/vendor/plugins/engines/lib/engines/dependencies_extensions.rb +118 -0
  68. data/vendor/plugins/engines/lib/engines/migration_extensions.rb +53 -0
  69. data/vendor/plugins/engines/lib/{ruby_extensions.rb → engines/ruby_extensions.rb} +14 -28
  70. data/vendor/plugins/engines/lib/engines/testing_extensions.rb +323 -0
  71. data/vendor/plugins/engines/lib/engines.rb +258 -148
  72. data/vendor/plugins/engines/tasks/engines.rake +161 -0
  73. data/vendor/plugins/engines/test/action_view_extensions_test.rb +9 -0
  74. data/vendor/plugins/engines/test/ruby_extensions_test.rb +24 -3
  75. data/vendor/plugins/guid/README.TXT +14 -4
  76. data/vendor/plugins/guid/init.rb +9 -2
  77. data/vendor/plugins/guid/lib/uuidtools.rb +22 -15
  78. data/vendor/plugins/login_engine/CHANGELOG +14 -0
  79. data/vendor/plugins/login_engine/README +93 -7
  80. data/vendor/plugins/login_engine/app/controllers/user_controller.rb +30 -20
  81. data/vendor/plugins/login_engine/app/helpers/user_helper.rb +1 -1
  82. data/vendor/plugins/login_engine/app/views/user/forgot_password.rhtml +2 -2
  83. data/vendor/plugins/login_engine/db/migrate/001_initial_schema.rb +25 -0
  84. data/vendor/plugins/login_engine/install.rb +4 -0
  85. data/vendor/plugins/login_engine/lib/login_engine/authenticated_system.rb +11 -5
  86. data/vendor/plugins/login_engine/lib/login_engine/authenticated_user.rb +15 -9
  87. data/vendor/plugins/login_engine/lib/login_engine.rb +7 -3
  88. data/vendor/plugins/login_engine/test/functional/user_controller_test.rb +22 -19
  89. data/vendor/plugins/login_engine/test/test_helper.rb +4 -8
  90. data/vendor/plugins/login_engine/test/unit/user_test.rb +31 -11
  91. metadata +60 -57
  92. data/app/models/attachment.rb +0 -6
  93. data/public/attachment/file/architecture.png +0 -0
  94. data/public/attachment/file/architecture.svg +0 -8972
  95. data/public/attachment/file/security.svg +0 -8960
  96. data/public/engine_files/login_engine/stylesheets/login_engine.css +0 -81
  97. data/public/oldREADME +0 -190
  98. data/public/stylesheets/default.css +0 -235
  99. data/public/stylesheets/live_tree.css +0 -62
  100. data/public/stylesheets/scaffold.css +0 -74
  101. data/script/about +0 -3
  102. data/script/benchmarker +0 -19
  103. data/script/breakpointer +0 -3
  104. data/script/console +0 -3
  105. data/script/create_db +0 -7
  106. data/script/destroy +0 -3
  107. data/script/generate +0 -3
  108. data/script/performance/benchmarker +0 -3
  109. data/script/performance/profiler +0 -3
  110. data/script/plugin +0 -3
  111. data/script/process/reaper +0 -3
  112. data/script/process/spawner +0 -3
  113. data/script/process/spinner +0 -3
  114. data/script/profiler +0 -34
  115. data/script/runner +0 -3
  116. data/script/server +0 -3
  117. data/test/unit/user_test.rb +0 -94
  118. data/vendor/plugins/engines/lib/dependencies_extensions.rb +0 -56
  119. data/vendor/plugins/engines/lib/testing_extensions.rb +0 -33
  120. data/vendor/plugins/login_engine/db/schema.rb +0 -25
  121. data/vendor/plugins/login_engine/test/fixtures/templates/users.yml +0 -41
  122. /data/public/images/{eltBackground.png → eltBackground.jng} +0 -0
@@ -0,0 +1,323 @@
1
+ # The Engines testing extensions enable developers to load fixtures into specific
2
+ # tables irrespective of the name of the fixtures file. This work is heavily based on
3
+ # patches made by Duane Johnson (canadaduane), viewable at
4
+ # http://dev.rubyonrails.org/ticket/1911
5
+ #
6
+ # Engine developers should supply fixture files in the <engine>/test/fixtures directory
7
+ # as normal. Within their tests, they should load the fixtures using the 'fixture' command
8
+ # (rather than the normal 'fixtures' command). For example:
9
+ #
10
+ # class UserTest < Test::Unit::TestCase
11
+ # fixture :users, :table_name => LoginEngine.config(:user_table), :class_name => "User"
12
+ #
13
+ # ...
14
+ #
15
+ # This will ensure that the fixtures/users.yml file will get loaded into the correct
16
+ # table, and will use the correct model object class.
17
+
18
+
19
+
20
+ # A FixtureGroup is a set of fixtures identified by a name. Normally, this is the name of the
21
+ # corresponding fixture filename. For example, when you declare the use of fixtures in a
22
+ # TestUnit class, like so:
23
+ # fixtures :users
24
+ # you are creating a FixtureGroup whose name is 'users', and whose defaults are set such that the
25
+ # +class_name+, +file_name+ and +table_name+ are guessed from the FixtureGroup's name.
26
+ class FixtureGroup
27
+ attr_accessor :table_name, :class_name, :connection
28
+ attr_reader :group_name, :file_name
29
+
30
+ def initialize(file_name, optional_names = {})
31
+ self.file_name = file_name
32
+ self.group_name = optional_names[:group_name] || file_name
33
+ if optional_names[:table_name]
34
+ self.table_name = optional_names[:table_name]
35
+ self.class_name = optional_names[:class_name] || Inflector.classify(@table_name.to_s.gsub('.','_'))
36
+ elsif optional_names[:class_name]
37
+ self.class_name = optional_names[:class_name]
38
+ if Object.const_defined?(@class_name)
39
+ model_class = Object.const_get(@class_name)
40
+ self.table_name = ActiveRecord::Base.table_name_prefix + model_class.table_name + ActiveRecord::Base.table_name_suffix
41
+ end
42
+ end
43
+
44
+ # In case either :table_name or :class_name was not set:
45
+ self.table_name ||= ActiveRecord::Base.table_name_prefix + @group_name.to_s + ActiveRecord::Base.table_name_suffix
46
+ self.class_name ||= Inflector.classify(@table_name.to_s.gsub('.','_'))
47
+ end
48
+
49
+ def file_name=(name)
50
+ @file_name = name.to_s
51
+ end
52
+
53
+ def group_name=(name)
54
+ @group_name = name.to_sym
55
+ end
56
+
57
+ def class_file_name
58
+ Inflector.underscore(@class_name)
59
+ end
60
+
61
+ # Instantiate an array of FixtureGroup objects from an array of strings (table_names)
62
+ def self.array_from_names(names)
63
+ names.collect { |n| FixtureGroup.new(n) }
64
+ end
65
+
66
+ def hash
67
+ @group_name.hash
68
+ end
69
+
70
+ def eql?(other)
71
+ @group_name.eql? other.group_name
72
+ end
73
+ end
74
+
75
+ class Fixtures < YAML::Omap
76
+
77
+ def self.instantiate_fixtures(object, fixture_group_name, fixtures, load_instances=true)
78
+ old_logger_level = ActiveRecord::Base.logger.level
79
+ ActiveRecord::Base.logger.level = Logger::ERROR
80
+
81
+ # table_name.to_s.gsub('.','_') replaced by 'fixture_group_name'
82
+ object.instance_variable_set "@#{fixture_group_name}", fixtures
83
+ if load_instances
84
+ ActiveRecord::Base.silence do
85
+ fixtures.each do |name, fixture|
86
+ if model = fixture.find
87
+ object.instance_variable_set "@#{name}", model
88
+ end
89
+ end
90
+ end
91
+ end
92
+
93
+ ActiveRecord::Base.logger.level = old_logger_level
94
+ end
95
+
96
+ # this doesn't really need to be overridden...
97
+ def self.instantiate_all_loaded_fixtures(object, load_instances=true)
98
+ all_loaded_fixtures.each do |fixture_group_name, fixtures|
99
+ Fixtures.instantiate_fixtures(object, fixture_group_name, fixtures, load_instances)
100
+ end
101
+ end
102
+
103
+ def self.create_fixtures(fixtures_directory, *fixture_groups)
104
+ connection = block_given? ? yield : ActiveRecord::Base.connection
105
+ fixture_groups.flatten!
106
+
107
+ # Backwards compatibility: Allow an array of table names to be passed in, but just use them
108
+ # to create an array of FixtureGroup objects
109
+ if not fixture_groups.empty? and fixture_groups.first.is_a?(String)
110
+ fixture_groups = FixtureGroup.array_from_names(fixture_groups)
111
+ end
112
+
113
+ ActiveRecord::Base.silence do
114
+ fixtures_map = {}
115
+ fixtures = fixture_groups.map do |group|
116
+ fixtures_map[group.group_name] = Fixtures.new(connection, fixtures_directory, group)
117
+ end
118
+ # Make sure all refs to all_loaded_fixtures use group_name as hash index, not table_name
119
+ all_loaded_fixtures.merge! fixtures_map
120
+
121
+ connection.transaction do
122
+ fixtures.reverse.each { |fixture| fixture.delete_existing_fixtures }
123
+ fixtures.each { |fixture| fixture.insert_fixtures }
124
+
125
+ # Cap primary key sequences to max(pk).
126
+ if connection.respond_to?(:reset_pk_sequence!)
127
+ fixture_groups.each do |fg|
128
+ connection.reset_pk_sequence!(fg.table_name)
129
+ end
130
+ end
131
+ end
132
+
133
+ return fixtures.size > 1 ? fixtures : fixtures.first
134
+ end
135
+ end
136
+
137
+
138
+ attr_accessor :connection, :fixtures_directory, :file_filter
139
+ attr_accessor :fixture_group
140
+
141
+ def initialize(connection, fixtures_directory, fixture_group, file_filter = DEFAULT_FILTER_RE)
142
+ @connection, @fixtures_directory = connection, fixtures_directory
143
+ @fixture_group = fixture_group
144
+ @file_filter = file_filter
145
+ read_fixture_files
146
+ end
147
+
148
+ def delete_existing_fixtures
149
+ @connection.delete "DELETE FROM #{@fixture_group.table_name}", 'Fixture Delete'
150
+ end
151
+
152
+ def insert_fixtures
153
+ values.each do |fixture|
154
+ @connection.execute "INSERT INTO #{@fixture_group.table_name} (#{fixture.key_list}) VALUES (#{fixture.value_list})", 'Fixture Insert'
155
+ end
156
+ end
157
+
158
+ private
159
+ def read_fixture_files
160
+ if File.file?(yaml_file_path)
161
+ read_yaml_fixture_files
162
+ elsif File.file?(csv_file_path)
163
+ read_csv_fixture_files
164
+ elsif File.file?(deprecated_yaml_file_path)
165
+ raise Fixture::FormatError, ".yml extension required: rename #{deprecated_yaml_file_path} to #{yaml_file_path}"
166
+ elsif File.directory?(single_file_fixtures_path)
167
+ read_standard_fixture_files
168
+ else
169
+ raise Fixture::FixtureError, "Couldn't find a yaml, csv or standard file to load at #{@fixtures_directory} (#{@fixture_group.file_name})."
170
+ end
171
+ end
172
+
173
+ def read_yaml_fixture_files
174
+ # YAML fixtures
175
+ begin
176
+ if yaml = YAML::load(erb_render(IO.read(yaml_file_path)))
177
+ yaml = yaml.value if yaml.respond_to?(:type_id) and yaml.respond_to?(:value)
178
+ yaml.each do |name, data|
179
+ self[name] = Fixture.new(data, fixture_group.class_name)
180
+ end
181
+ end
182
+ rescue Exception=>boom
183
+ raise Fixture::FormatError, "a YAML error occured parsing #{yaml_file_path}. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html\nThe exact error was:\n #{boom.class}: #{boom}"
184
+ end
185
+ end
186
+
187
+ def read_csv_fixture_files
188
+ # CSV fixtures
189
+ reader = CSV::Reader.create(erb_render(IO.read(csv_file_path)))
190
+ header = reader.shift
191
+ i = 0
192
+ reader.each do |row|
193
+ data = {}
194
+ row.each_with_index { |cell, j| data[header[j].to_s.strip] = cell.to_s.strip }
195
+ self["#{@fixture_group.class_file_name}_#{i+=1}"]= Fixture.new(data, @fixture_group.class_name)
196
+ end
197
+ end
198
+
199
+ def read_standard_fixture_files
200
+ # Standard fixtures
201
+ path = File.join(@fixtures_directory, @fixture_group.file_name)
202
+ Dir.entries(path).each do |file|
203
+ path = File.join(@fixtures_directory, @fixture_group.file_name, file)
204
+ if File.file?(path) and file !~ @file_filter
205
+ self[file] = Fixture.new(path, @fixture_group.class_name)
206
+ end
207
+ end
208
+ end
209
+
210
+ def yaml_file_path
211
+ fixture_path_with_extension ".yml"
212
+ end
213
+
214
+ def deprecated_yaml_file_path
215
+ fixture_path_with_extension ".yaml"
216
+ end
217
+
218
+ def csv_file_path
219
+ fixture_path_with_extension ".csv"
220
+ end
221
+
222
+ def single_file_fixtures_path
223
+ fixture_path_with_extension ""
224
+ end
225
+
226
+ def fixture_path_with_extension(ext)
227
+ File.join(@fixtures_directory, @fixture_group.file_name + ext)
228
+ end
229
+
230
+ def erb_render(fixture_content)
231
+ ERB.new(fixture_content).result
232
+ end
233
+
234
+ end
235
+
236
+ module Test #:nodoc:
237
+ module Unit #:nodoc:
238
+ class TestCase #:nodoc:
239
+ cattr_accessor :fixtures_directory
240
+ class_inheritable_accessor :fixture_groups
241
+ class_inheritable_accessor :fixture_table_names
242
+ class_inheritable_accessor :use_transactional_fixtures
243
+ class_inheritable_accessor :use_instantiated_fixtures # true, false, or :no_instances
244
+ class_inheritable_accessor :pre_loaded_fixtures
245
+
246
+ self.fixture_groups = []
247
+ self.use_transactional_fixtures = false
248
+ self.use_instantiated_fixtures = true
249
+ self.pre_loaded_fixtures = false
250
+
251
+ @@already_loaded_fixtures = {}
252
+
253
+ # Backwards compatibility
254
+ def self.fixture_path=(path); self.fixtures_directory = path; end
255
+ def self.fixture_path; self.fixtures_directory; end
256
+ def fixture_group_names; fixture_groups.collect { |g| g.group_name }; end
257
+ def fixture_table_names; fixture_group_names; end
258
+
259
+ def self.fixture(file_name, options = {})
260
+ self.fixture_groups |= [FixtureGroup.new(file_name, options)]
261
+ require_fixture_classes
262
+ setup_fixture_accessors
263
+ end
264
+
265
+ def self.fixtures(*file_names)
266
+ self.fixture_groups |= FixtureGroup.array_from_names(file_names.flatten)
267
+ require_fixture_classes
268
+ setup_fixture_accessors
269
+ end
270
+
271
+ def self.require_fixture_classes(fixture_groups_override = nil)
272
+ (fixture_groups_override || fixture_groups).each do |group|
273
+ begin
274
+ require group.class_file_name
275
+ rescue LoadError
276
+ # Let's hope the developer has included it himself
277
+ end
278
+ end
279
+ end
280
+
281
+ def self.setup_fixture_accessors(fixture_groups_override=nil)
282
+ (fixture_groups_override || fixture_groups).each do |group|
283
+ define_method(group.group_name) do |fixture, *optionals|
284
+ force_reload = optionals.shift
285
+ @fixture_cache[group.group_name] ||= Hash.new
286
+ @fixture_cache[group.group_name][fixture] = nil if force_reload
287
+ @fixture_cache[group.group_name][fixture] ||= @loaded_fixtures[group.group_name][fixture.to_s].find
288
+ end
289
+ end
290
+ end
291
+
292
+ private
293
+ def load_fixtures
294
+ @loaded_fixtures = {}
295
+ fixtures = Fixtures.create_fixtures(fixtures_directory, fixture_groups)
296
+ unless fixtures.nil?
297
+ if fixtures.instance_of?(Fixtures)
298
+ @loaded_fixtures[fixtures.fixture_group.group_name] = fixtures
299
+ else
300
+ fixtures.each { |f| @loaded_fixtures[f.fixture_group.group_name] = f }
301
+ end
302
+ end
303
+ end
304
+
305
+ def instantiate_fixtures
306
+ if pre_loaded_fixtures
307
+ raise RuntimeError, 'Load fixtures before instantiating them.' if Fixtures.all_loaded_fixtures.empty?
308
+ unless @@required_fixture_classes
309
+ groups = Fixtures.all_loaded_fixtures.values.collect { |f| f.group_name }
310
+ self.class.require_fixture_classes groups
311
+ @@required_fixture_classes = true
312
+ end
313
+ Fixtures.instantiate_all_loaded_fixtures(self, load_instances?)
314
+ else
315
+ raise RuntimeError, 'Load fixtures before instantiating them.' if @loaded_fixtures.nil?
316
+ @loaded_fixtures.each do |fixture_group_name, fixtures|
317
+ Fixtures.instantiate_fixtures(self, fixture_group_name, fixtures, load_instances?)
318
+ end
319
+ end
320
+ end
321
+ end
322
+ end
323
+ end