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.
- data/CHANGES +16 -0
- data/README +36 -3
- data/Rakefile +8 -12
- data/app/controllers/account_controller.rb +2 -0
- data/app/controllers/elt_controller.rb +1 -5
- data/app/controllers/subscriber_controller.rb +1 -1
- data/app/helpers/elt_helper.rb +30 -10
- data/app/models/elt.rb +2 -1
- data/app/models/mail.rb +41 -41
- data/app/models/mail_notify.rb +27 -10
- data/app/views/account/_login.rhtml +9 -7
- data/app/views/account/_show.rhtml +4 -4
- data/app/views/elt/_elt.rhtml +52 -51
- data/app/views/elt/_list.rhtml +22 -14
- data/app/views/elt/new.rhtml +1 -1
- data/app/views/elt/show.rhtml +15 -16
- data/app/views/layouts/top.rhtml +13 -1
- data/app/views/person/show.rhtml +1 -7
- data/config/boot.rb +32 -7
- data/config/database.yml +3 -0
- data/config/environment.rb +3 -1
- data/config/environments/development.rb +1 -1
- data/db/ROOT/parlement/ddRing.txt +14 -0
- data/db/ROOT/parlement/top-politics.txt +12 -0
- data/db/ROOT/perso.txt +1 -1
- data/db/development_structure.sql +30 -16
- data/db/schema.rb +18 -10
- data/db/schema.sql +34 -34
- data/public/javascripts/application.js +2 -0
- data/public/javascripts/blank.gif +0 -0
- data/public/javascripts/borders.js +687 -0
- data/public/javascripts/controls.js +95 -30
- data/public/javascripts/dragdrop.js +161 -21
- data/public/javascripts/effects.js +310 -211
- data/public/javascripts/ie7-load.htc +1 -0
- data/public/javascripts/prototype.js +228 -28
- data/test/fixtures/attachments.yml +3 -0
- data/test/fixtures/mail/mail_ruby +1 -0
- data/test/fixtures/people.yml +14 -0
- data/test/functional/account_controller_test.rb +3 -2
- data/test/unit/mail_notify_test.rb +2 -0
- data/test/unit/mail_test.rb +59 -6
- data/test/unit/person_test.rb +1 -1
- data/vendor/plugins/engines/CHANGELOG +92 -0
- data/vendor/plugins/engines/MIT-LICENSE +21 -0
- data/vendor/plugins/engines/README +325 -39
- data/vendor/plugins/engines/generators/engine/USAGE +26 -0
- data/vendor/plugins/engines/generators/engine/engine_generator.rb +199 -0
- data/vendor/plugins/engines/generators/engine/templates/README +85 -0
- data/vendor/plugins/engines/generators/engine/templates/init_engine.erb +13 -0
- data/vendor/plugins/engines/generators/engine/templates/install.erb +4 -0
- data/vendor/plugins/engines/generators/engine/templates/lib/engine.erb +6 -0
- data/vendor/plugins/engines/generators/engine/templates/licenses/GPL +18 -0
- data/vendor/plugins/engines/generators/engine/templates/licenses/LGPL +19 -0
- data/vendor/plugins/engines/generators/engine/templates/licenses/MIT +22 -0
- data/vendor/plugins/engines/generators/engine/templates/licenses/None +1 -0
- data/vendor/plugins/engines/generators/engine/templates/public/javascripts/engine.js +0 -0
- data/vendor/plugins/engines/generators/engine/templates/public/stylesheets/engine.css +0 -0
- data/vendor/plugins/engines/generators/engine/templates/tasks/engine.rake +0 -0
- data/vendor/plugins/engines/generators/engine/templates/test/test_helper.erb +13 -0
- data/vendor/plugins/engines/init.rb +18 -3
- data/vendor/plugins/engines/lib/bundles/require_resource.rb +124 -0
- data/vendor/plugins/engines/lib/bundles.rb +77 -0
- data/vendor/plugins/engines/lib/{action_mailer_extensions.rb → engines/action_mailer_extensions.rb} +15 -36
- data/vendor/plugins/engines/lib/{action_view_extensions.rb → engines/action_view_extensions.rb} +40 -33
- data/vendor/plugins/engines/lib/engines/active_record_extensions.rb +19 -0
- data/vendor/plugins/engines/lib/engines/dependencies_extensions.rb +118 -0
- data/vendor/plugins/engines/lib/engines/migration_extensions.rb +53 -0
- data/vendor/plugins/engines/lib/{ruby_extensions.rb → engines/ruby_extensions.rb} +14 -28
- data/vendor/plugins/engines/lib/engines/testing_extensions.rb +323 -0
- data/vendor/plugins/engines/lib/engines.rb +258 -148
- data/vendor/plugins/engines/tasks/engines.rake +161 -0
- data/vendor/plugins/engines/test/action_view_extensions_test.rb +9 -0
- data/vendor/plugins/engines/test/ruby_extensions_test.rb +24 -3
- data/vendor/plugins/guid/README.TXT +14 -4
- data/vendor/plugins/guid/init.rb +9 -2
- data/vendor/plugins/guid/lib/uuidtools.rb +22 -15
- data/vendor/plugins/login_engine/CHANGELOG +14 -0
- data/vendor/plugins/login_engine/README +93 -7
- data/vendor/plugins/login_engine/app/controllers/user_controller.rb +30 -20
- data/vendor/plugins/login_engine/app/helpers/user_helper.rb +1 -1
- data/vendor/plugins/login_engine/app/views/user/forgot_password.rhtml +2 -2
- data/vendor/plugins/login_engine/db/migrate/001_initial_schema.rb +25 -0
- data/vendor/plugins/login_engine/install.rb +4 -0
- data/vendor/plugins/login_engine/lib/login_engine/authenticated_system.rb +11 -5
- data/vendor/plugins/login_engine/lib/login_engine/authenticated_user.rb +15 -9
- data/vendor/plugins/login_engine/lib/login_engine.rb +7 -3
- data/vendor/plugins/login_engine/test/functional/user_controller_test.rb +22 -19
- data/vendor/plugins/login_engine/test/test_helper.rb +4 -8
- data/vendor/plugins/login_engine/test/unit/user_test.rb +31 -11
- metadata +60 -57
- data/app/models/attachment.rb +0 -6
- data/public/attachment/file/architecture.png +0 -0
- data/public/attachment/file/architecture.svg +0 -8972
- data/public/attachment/file/security.svg +0 -8960
- data/public/engine_files/login_engine/stylesheets/login_engine.css +0 -81
- data/public/oldREADME +0 -190
- data/public/stylesheets/default.css +0 -235
- data/public/stylesheets/live_tree.css +0 -62
- data/public/stylesheets/scaffold.css +0 -74
- data/script/about +0 -3
- data/script/benchmarker +0 -19
- data/script/breakpointer +0 -3
- data/script/console +0 -3
- data/script/create_db +0 -7
- data/script/destroy +0 -3
- data/script/generate +0 -3
- data/script/performance/benchmarker +0 -3
- data/script/performance/profiler +0 -3
- data/script/plugin +0 -3
- data/script/process/reaper +0 -3
- data/script/process/spawner +0 -3
- data/script/process/spinner +0 -3
- data/script/profiler +0 -34
- data/script/runner +0 -3
- data/script/server +0 -3
- data/test/unit/user_test.rb +0 -94
- data/vendor/plugins/engines/lib/dependencies_extensions.rb +0 -56
- data/vendor/plugins/engines/lib/testing_extensions.rb +0 -33
- data/vendor/plugins/login_engine/db/schema.rb +0 -25
- data/vendor/plugins/login_engine/test/fixtures/templates/users.yml +0 -41
- /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
|