parlement 0.14 → 0.17

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 (205) hide show
  1. data/CHANGES +41 -1
  2. data/MEMORY +66 -5
  3. data/README +10 -5
  4. data/Rakefile +15 -23
  5. data/app/controllers/account_controller.rb +48 -43
  6. data/app/controllers/{application.rb → application_controller.rb} +15 -12
  7. data/app/controllers/elt_controller.rb +77 -32
  8. data/app/controllers/subscriber_controller.rb +11 -10
  9. data/app/helpers/application_helper.rb +14 -1
  10. data/app/helpers/elt_helper.rb +9 -7
  11. data/app/models/elt.rb +25 -24
  12. data/app/models/mail.rb +44 -47
  13. data/app/models/person_notify.rb +2 -2
  14. data/app/models/user.rb +128 -2
  15. data/app/models/user_notify.rb +15 -15
  16. data/app/views/account/_login.rhtml +39 -39
  17. data/app/views/account/_show.rhtml +22 -30
  18. data/app/views/account/signup.rhtml +2 -2
  19. data/app/views/elt/_choice.rhtml +6 -6
  20. data/app/views/elt/_elt.rhtml +27 -32
  21. data/app/views/elt/choices.rhtml +16 -18
  22. data/app/views/elt/list/_byDate.rhtml +14 -14
  23. data/app/views/elt/list/_byVote.rhtml +15 -15
  24. data/app/views/elt/list/_children.rhtml +48 -40
  25. data/app/views/elt/list/_subscribers.rhtml +1 -1
  26. data/app/views/elt/new.rhtml +22 -21
  27. data/app/views/elt/rss.rxml +4 -11
  28. data/app/views/elt/show.rhtml +65 -61
  29. data/app/views/elt/vote_rss.rxml +4 -11
  30. data/app/views/layouts/top.rhtml +39 -50
  31. data/app/views/person/_listElts.rhtml +1 -1
  32. data/app/views/person/show.rhtml +1 -1
  33. data/{vendor/plugins/login_engine/app → app}/views/user_notify/change_password.rhtml +0 -0
  34. data/{vendor/plugins/login_engine/app → app}/views/user_notify/delete.rhtml +0 -0
  35. data/{vendor/plugins/login_engine/app → app}/views/user_notify/forgot_password.rhtml +0 -0
  36. data/{vendor/plugins/login_engine/app → app}/views/user_notify/pending_delete.rhtml +0 -0
  37. data/{vendor/plugins/login_engine/app → app}/views/user_notify/signup.rhtml +0 -0
  38. data/config/boot.rb +97 -32
  39. data/config/environment.rb +37 -35
  40. data/config/environments/development.rb +2 -3
  41. data/config/environments/production.rb +3 -0
  42. data/config/initializers/string_ruby_1.8.rb +10 -0
  43. data/config/routes.rb +17 -22
  44. data/db/schema.rb +102 -74
  45. data/lib/tasks/rspec.rake +167 -0
  46. data/public/404.html +25 -7
  47. data/public/500.html +26 -7
  48. data/public/dispatch.cgi +0 -0
  49. data/public/dispatch.fcgi +0 -0
  50. data/public/dispatch.rb +0 -0
  51. data/public/images/live_tree_branch_collapsed_icon.gif +0 -0
  52. data/public/images/live_tree_branch_expanded_icon.gif +0 -0
  53. data/public/images/live_tree_leaf_icon.gif +0 -0
  54. data/public/javascripts/application.js +258 -0
  55. data/public/javascripts/controls.js +544 -414
  56. data/public/javascripts/dragdrop.js +229 -198
  57. data/public/javascripts/effects.js +499 -459
  58. data/public/javascripts/prototype.js +2926 -1121
  59. data/public/javascripts/shadedborder.js +68 -50
  60. data/public/stylesheets/default.css +34 -34
  61. data/public/stylesheets/live_tree.css +0 -0
  62. data/public/stylesheets/scaffold.css +6 -6
  63. data/script/about +0 -0
  64. data/script/autospec +6 -0
  65. data/script/benchmarker +0 -0
  66. data/script/breakpointer +0 -0
  67. data/script/console +0 -0
  68. data/script/dbconsole +3 -0
  69. data/script/destroy +0 -0
  70. data/script/generate +0 -0
  71. data/script/plugin +0 -0
  72. data/script/profiler +0 -0
  73. data/script/runner +0 -0
  74. data/script/server +0 -0
  75. data/script/spec +10 -0
  76. data/script/spec_server +9 -0
  77. data/test/unit/attachment_test.rb +4 -4
  78. data/test/unit/choice_test.rb +1 -1
  79. data/test/unit/elt_test.rb +9 -9
  80. data/test/unit/mail_notify_test.rb +2 -2
  81. data/test/unit/mail_test.rb +18 -11
  82. data/test/unit/person_notify_test.rb +1 -1
  83. data/test/unit/person_test.rb +1 -1
  84. data/test/unit/subscriber_test.rb +1 -1
  85. data/test/unit/user_test.rb +81 -0
  86. data/test/unit/visit_test.rb +6 -6
  87. data/vendor/plugins/activerecord_foreign_key_extensions/init.rb +2 -0
  88. data/vendor/plugins/activerecord_foreign_key_extensions/lib/active_record_extensions.rb +182 -0
  89. data/vendor/plugins/activerecord_text_id_extensions/init.rb +2 -0
  90. data/vendor/plugins/activerecord_text_id_extensions/lib/active_record_extensions.rb +24 -0
  91. data/vendor/plugins/acts_as_nested_set/README +15 -0
  92. data/vendor/plugins/acts_as_nested_set/init.rb +1 -0
  93. data/vendor/plugins/acts_as_nested_set/lib/active_record/acts/nested_set.rb +210 -0
  94. data/vendor/plugins/acts_as_nested_set/test/nested_set_test.rb +269 -0
  95. data/vendor/plugins/acts_as_tree/README +26 -0
  96. data/vendor/plugins/acts_as_tree/Rakefile +22 -0
  97. data/vendor/plugins/acts_as_tree/init.rb +1 -0
  98. data/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb +96 -0
  99. data/vendor/plugins/{output_compression/CHANGELOG → acts_as_tree/test/abstract_unit.rb} +0 -0
  100. data/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb +219 -0
  101. data/vendor/plugins/acts_as_tree/test/database.yml +0 -0
  102. data/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb +0 -0
  103. data/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml +0 -0
  104. data/vendor/plugins/acts_as_tree/test/schema.rb +0 -0
  105. data/vendor/plugins/classic_pagination/CHANGELOG +152 -0
  106. data/vendor/plugins/classic_pagination/README +18 -0
  107. data/vendor/plugins/{output_compression/rakefile → classic_pagination/Rakefile} +22 -22
  108. data/vendor/plugins/classic_pagination/init.rb +33 -0
  109. data/vendor/plugins/classic_pagination/install.rb +1 -0
  110. data/vendor/plugins/classic_pagination/lib/pagination.rb +405 -0
  111. data/vendor/plugins/classic_pagination/lib/pagination_helper.rb +135 -0
  112. data/vendor/plugins/classic_pagination/test/fixtures/companies.yml +24 -0
  113. data/vendor/plugins/classic_pagination/test/fixtures/company.rb +9 -0
  114. data/vendor/plugins/classic_pagination/test/fixtures/developer.rb +7 -0
  115. data/vendor/plugins/classic_pagination/test/fixtures/developers.yml +21 -0
  116. data/vendor/plugins/classic_pagination/test/fixtures/developers_projects.yml +13 -0
  117. data/vendor/plugins/classic_pagination/test/fixtures/project.rb +3 -0
  118. data/vendor/plugins/classic_pagination/test/fixtures/projects.yml +7 -0
  119. data/vendor/plugins/classic_pagination/test/fixtures/replies.yml +13 -0
  120. data/vendor/plugins/classic_pagination/test/fixtures/reply.rb +5 -0
  121. data/vendor/plugins/classic_pagination/test/fixtures/schema.sql +42 -0
  122. data/vendor/plugins/classic_pagination/test/fixtures/topic.rb +3 -0
  123. data/vendor/plugins/classic_pagination/test/fixtures/topics.yml +22 -0
  124. data/vendor/plugins/classic_pagination/test/helper.rb +117 -0
  125. data/vendor/plugins/classic_pagination/test/pagination_helper_test.rb +38 -0
  126. data/vendor/plugins/classic_pagination/test/pagination_test.rb +177 -0
  127. data/vendor/plugins/file_column/lib/file_column.rb +1 -1
  128. data/vendor/plugins/file_column/test/file_column_test.rb +0 -0
  129. metadata +151 -197
  130. data/app/helpers/live_tree.rb +0 -238
  131. data/app/views/elt/_form.rhtml +0 -31
  132. data/app/views/elt/show_tree.rhtml +0 -8
  133. data/config/environments/user_environment.rb +0 -1
  134. data/db/ROOT/Titemagli.txt +0 -3
  135. data/db/ROOT/titemagli.txt +0 -9
  136. data/public/javascripts/behaviour.js +0 -254
  137. data/public/javascripts/ie7-load.htc +0 -1
  138. data/public/javascripts/ie7.js +0 -6
  139. data/public/javascripts/live_tree.js +0 -749
  140. data/public/javascripts/mybehaviour.js +0 -225
  141. data/public/javascripts/scriptaculous.js +0 -47
  142. data/public/javascripts/slider.js +0 -283
  143. data/public/stylesheets/blue.css +0 -471
  144. data/vendor/plugins/engines/CHANGELOG +0 -241
  145. data/vendor/plugins/engines/MIT-LICENSE +0 -21
  146. data/vendor/plugins/engines/README +0 -64
  147. data/vendor/plugins/engines/Rakefile +0 -32
  148. data/vendor/plugins/engines/UPGRADING +0 -93
  149. data/vendor/plugins/engines/about.yml +0 -7
  150. data/vendor/plugins/engines/generators/plugin_migration/USAGE +0 -45
  151. data/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb +0 -79
  152. data/vendor/plugins/engines/generators/plugin_migration/templates/plugin_migration.erb +0 -13
  153. data/vendor/plugins/engines/init.rb +0 -40
  154. data/vendor/plugins/engines/install.rb +0 -32
  155. data/vendor/plugins/engines/lib/engines.rb +0 -323
  156. data/vendor/plugins/engines/lib/engines/deprecated_config_support.rb +0 -135
  157. data/vendor/plugins/engines/lib/engines/plugin.rb +0 -214
  158. data/vendor/plugins/engines/lib/engines/plugin_list.rb +0 -31
  159. data/vendor/plugins/engines/lib/engines/plugin_migrator.rb +0 -60
  160. data/vendor/plugins/engines/lib/engines/rails_extensions.rb +0 -6
  161. data/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb +0 -19
  162. data/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb +0 -143
  163. data/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb +0 -155
  164. data/vendor/plugins/engines/lib/engines/rails_extensions/public_asset_helpers.rb +0 -116
  165. data/vendor/plugins/engines/lib/engines/rails_extensions/rails.rb +0 -20
  166. data/vendor/plugins/engines/lib/engines/rails_extensions/rails_initializer.rb +0 -86
  167. data/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb +0 -77
  168. data/vendor/plugins/engines/lib/engines/rails_extensions/templates.rb +0 -140
  169. data/vendor/plugins/engines/lib/engines/testing.rb +0 -87
  170. data/vendor/plugins/engines/tasks/engines.rake +0 -149
  171. data/vendor/plugins/login_engine/CHANGELOG +0 -22
  172. data/vendor/plugins/login_engine/README +0 -344
  173. data/vendor/plugins/login_engine/app/controllers/user_controller.rb +0 -262
  174. data/vendor/plugins/login_engine/app/helpers/user_helper.rb +0 -88
  175. data/vendor/plugins/login_engine/app/models/user.rb +0 -7
  176. data/vendor/plugins/login_engine/app/models/user_notify.rb +0 -75
  177. data/vendor/plugins/login_engine/app/views/user/_edit.rhtml +0 -11
  178. data/vendor/plugins/login_engine/app/views/user/_password.rhtml +0 -9
  179. data/vendor/plugins/login_engine/app/views/user/change_password.rhtml +0 -17
  180. data/vendor/plugins/login_engine/app/views/user/edit.rhtml +0 -23
  181. data/vendor/plugins/login_engine/app/views/user/forgot_password.rhtml +0 -18
  182. data/vendor/plugins/login_engine/app/views/user/home.rhtml +0 -7
  183. data/vendor/plugins/login_engine/app/views/user/login.rhtml +0 -17
  184. data/vendor/plugins/login_engine/app/views/user/logout.rhtml +0 -8
  185. data/vendor/plugins/login_engine/app/views/user/signup.rhtml +0 -17
  186. data/vendor/plugins/login_engine/db/migrate/001_initial_schema.rb +0 -25
  187. data/vendor/plugins/login_engine/init_engine.rb +0 -11
  188. data/vendor/plugins/login_engine/install.rb +0 -4
  189. data/vendor/plugins/login_engine/lib/login_engine.rb +0 -62
  190. data/vendor/plugins/login_engine/lib/login_engine/authenticated_system.rb +0 -113
  191. data/vendor/plugins/login_engine/lib/login_engine/authenticated_user.rb +0 -155
  192. data/vendor/plugins/login_engine/public/stylesheets/login_engine.css +0 -81
  193. data/vendor/plugins/login_engine/test/fixtures/users.yml +0 -41
  194. data/vendor/plugins/login_engine/test/functional/user_controller_test.rb +0 -536
  195. data/vendor/plugins/login_engine/test/mocks/mail.rb +0 -14
  196. data/vendor/plugins/login_engine/test/mocks/time.rb +0 -19
  197. data/vendor/plugins/login_engine/test/test_helper.rb +0 -11
  198. data/vendor/plugins/login_engine/test/unit/user_test.rb +0 -114
  199. data/vendor/plugins/output_compression/MIT-LICENSE +0 -20
  200. data/vendor/plugins/output_compression/README +0 -4
  201. data/vendor/plugins/output_compression/init.rb +0 -1
  202. data/vendor/plugins/output_compression/lib/output_compression.rb +0 -84
  203. data/vendor/plugins/output_compression/test/output_test.rb +0 -11
  204. data/vendor/plugins/output_compression/test/test_controller.rb +0 -3
  205. data/vendor/plugins/output_compression/test/test_helper.rb +0 -14
@@ -1,86 +0,0 @@
1
- # Enhances the Rails::Initializer class to be a bit smarter about
2
- # plugins. See Engines::RailsExtensions::RailsInitializer for more
3
- # details.
4
-
5
- require "engines/rails_extensions/rails"
6
- require 'engines/plugin_list'
7
-
8
- # The engines plugin changes the way that Rails actually loads other plugins.
9
- # It creates instances of the Plugin class to represent each plugin, stored
10
- # in the <tt>Rails.plugins</tt> PluginList.
11
- #
12
- # ---
13
- #
14
- # Three methods from the original Rails::Initializer module are overridden
15
- # by Engines::RailsExtensions::RailsInitializer:
16
- #
17
- # [+load_plugin+] which now creates Plugin instances and calls Plugin#load
18
- # [+after_initialize+] which now performs Engines.after_initialize in addition
19
- # to the given config block
20
- # [<tt>plugin_enabled?</tt>] which now respects the result of
21
- # Engines.load_all_plugins?
22
- #
23
- module Engines::RailsExtensions::RailsInitializer
24
- def self.included(base) #:nodoc:
25
- base.class_eval do
26
- alias_method_chain :load_plugin, :engine_additions
27
- alias_method_chain :after_initialize, :engine_additions
28
- alias_method_chain :plugin_enabled?, :engine_additions
29
- end
30
- end
31
-
32
- # Loads all plugins in configuration.plugin_paths, regardless of the contents
33
- # of configuration.plugins
34
- def load_all_plugins
35
- # a nil value implies we don't care about plugins; load 'em all in a reliable order
36
- find_plugins(configuration.plugin_paths).sort.each { |path| load_plugin path }
37
- end
38
-
39
- # Loads a plugin, performing the extra load path/public file magic of
40
- # engines by calling Plugin#load.
41
- def load_plugin_with_engine_additions(directory)
42
- name = plugin_name(directory)
43
- return false if loaded_plugins.include?(name)
44
-
45
- logger.debug "loading plugin from #{directory} with engine additions"
46
-
47
- # add the Plugin object
48
- plugin = Plugin.new(plugin_name(directory), directory)
49
- Rails.plugins << plugin
50
-
51
- # do the other stuff that load_plugin used to do. This includes
52
- # allowing the plugin's init.rb to set configuration options on
53
- # it's instance, which can then be used in it's initialization
54
- load_plugin_without_engine_additions(directory)
55
-
56
- # perform additional loading tasks like mirroring public assets
57
- # and adding app directories to the appropriate load paths
58
- plugin.load
59
-
60
- true
61
- end
62
-
63
- # Allow the engines plugin to do whatever it needs to do after Rails has
64
- # loaded, and then call the actual after_initialize block. Currently, this
65
- # is call Engines.after_initialize.
66
- def after_initialize_with_engine_additions
67
- Engines.after_initialize
68
- after_initialize_without_engine_additions
69
- end
70
-
71
- protected
72
-
73
- # Returns true if the plugin at the given path should be loaded; false
74
- # otherwise. If Engines.load_all_plugins? is true, this method will return
75
- # true regardless of the path given.
76
- def plugin_enabled_with_engine_additions?(path)
77
- Engines.load_all_plugins? || plugin_enabled_without_engine_additions?(path)
78
- end
79
-
80
- # Returns the name of the plugin at the given path.
81
- def plugin_name(path)
82
- File.basename(path)
83
- end
84
- end
85
-
86
- ::Rails::Initializer.send(:include, Engines::RailsExtensions::RailsInitializer)
@@ -1,77 +0,0 @@
1
- # Effective use of Rails' routes can help create a tidy and elegant set of URLs,
2
- # and is a significant part of creating an external API for your web application.
3
- #
4
- # When developing plugins which contain controllers, it seems obvious that including
5
- # the corresponding routes would be extremely useful. This is particularly true
6
- # when exposing RESTful resources using the new REST-ian features of Rails 1.2.
7
- #
8
- # == Including routes in your plugin
9
- #
10
- # The engines plugin makes it possible to include a set of routes within your plugin
11
- # very simply, as it turns out. In your plugin, you simply include a <tt>routes.rb</tt>
12
- # file like the one below at the root of your plugin:
13
- #
14
- # connect "/login", :controller => "my_plugin/account", :action => "login"
15
- #
16
- # # add a named route
17
- # logout "/logout", :controller => "my_plugin/account", :action => "logout"
18
- #
19
- # # some restful stuff
20
- # resources :things do |t|
21
- # t.resources :other_things
22
- # end
23
- #
24
- # Everywhere in a normal <tt>RAILS_ROOT/config/routes.rb</tt> file
25
- # where you might have <tt>map.connect</tt>, you just use <tt>connect</tt> in your
26
- # plugin's <tt>routes.rb</tt>.
27
- #
28
- # === Hooking it up in your application
29
- #
30
- # While it would be possible to have each plugin's routes automagically included into
31
- # the application's route set, to do so would actually be a stunningly bad idea. Route
32
- # priority is the key issue here. You, the application developer, needs to be in complete
33
- # control when it comes to specifying the priority of routes in your application, since
34
- # the ordering of your routes directly affects how Rails will interpret incoming requests.
35
- #
36
- # To add plugin routes into your application's <tt>routes.rb</tt> file, you need to explicitly
37
- # map them in using the Engines::RailsExtensions::Routing#from_plugin method:
38
- #
39
- # ApplicationController::Routing::Routes.draw do |map|
40
- #
41
- # map.connect "/app_stuff", :controller => "application_thing" # etc...
42
- #
43
- # # This line includes the routes from the given plugin at this point, giving you
44
- # # control over the priority of your application routes
45
- # map.from_plugin :your_plugin
46
- #
47
- # map.connect ":controller/:action/:id"
48
- # end
49
- #
50
- # By including routes in plugins which have controllers, you can now share in a simple way
51
- # a compact and elegant URL scheme which corresponds to those controllers.
52
- #
53
- # ---
54
- #
55
- # The Engines::RailsExtensions::Routing module defines extensions to Rails'
56
- # routing (ActionController::Routing) mechanism such that routes can be loaded
57
- # from a given plugin.
58
- #
59
- # The key method is Engines::RailsExtensions::Routing#from_plugin, which can be called
60
- # within your application's <tt>config/routes.rb</tt> file to load plugin routes at that point.
61
- #
62
- module Engines::RailsExtensions::Routing
63
- # Loads the set of routes from within a plugin and evaluates them at this
64
- # point within an application's main <tt>routes.rb</tt> file.
65
- #
66
- # Plugin routes are loaded from <tt><plugin_root>/routes.rb</tt>.
67
- def from_plugin(name)
68
- # At the point in which routing is loaded, we cannot guarantee that all
69
- # plugins are in Rails.plugins, so instead we need to use find_plugin_path
70
- path = Engines.find_plugin_path(name)
71
- routes_path = File.join(path, name.to_s, "routes.rb")
72
- logger.debug "loading routes from #{routes_path}"
73
- eval(IO.read(routes_path), binding, routes_path) if File.file?(routes_path)
74
- end
75
- end
76
-
77
- ::ActionController::Routing::RouteSet::Mapper.send(:include, Engines::RailsExtensions::Routing)
@@ -1,140 +0,0 @@
1
- # As well as providing code overloading for controllers and helpers
2
- # (see Engines::RailsExtensions::Dependencies), the engines plugin also allows
3
- # developers to selectively override views and partials within their application.
4
- #
5
- # == An example
6
- #
7
- # This is achieved in much the same way as controller overriding. Our plugin contains
8
- # a view to be rendered at the URL <tt>/test/hello</tt>, in
9
- # <tt>our_plugin/app/views/test/hello.rhtml</tt>:
10
- #
11
- # <div class="greeting">Hi, <%= @dude.name %>, what's up?</div>
12
- #
13
- # If in a particular application we're not happy with this message, we can override
14
- # it by replacing the partial in our own application -
15
- # <tt>RAILS_ROOT/app/views/test/hello.rhtml</tt>:
16
- #
17
- # <div class="greeting custom_class">Wassup <%= @dude.name %>.
18
- # Waaaaassaaaaaaaaup</div>
19
- #
20
- # This view will then be rendered in favour of that in the plugin.
21
- #
22
- module Engines::RailsExtensions::Templates
23
-
24
- # Override the finding of partials and views. This is achieved by wrapping
25
- # the (private) method #full_template_path_with_engine_additions, that checks
26
- # for the given template within plugins as well as the application.
27
- module ActionView
28
- def self.included(base) #:nodoc:
29
- base.class_eval { alias_method_chain :full_template_path, :engine_additions }
30
- end
31
-
32
- private
33
- def full_template_path_with_engine_additions(template_path, extension)
34
- path_in_app_directory = full_template_path_from_application(template_path, extension)
35
-
36
- # First check for this template in the application. If it exists, the user has
37
- # overridden anything from the plugin, so use it (unless we're testing plugins;
38
- # see full_template_path_from_application())
39
- return path_in_app_directory if path_in_app_directory && File.exist?(path_in_app_directory)
40
-
41
- # Otherwise, check in the plugins to see if the template can be found there.
42
- # Load this in order so that more recently started plugins will take priority.
43
- Rails.plugins.by_precedence do |plugin|
44
- plugin_specific_path = File.join(plugin.root, 'app', 'views',
45
- template_path.to_s + '.' + extension.to_s)
46
- return plugin_specific_path if File.exist?(plugin_specific_path)
47
- end
48
-
49
- # If it cannot be found anywhere, return the default path.
50
- return full_template_path_without_engine_additions(template_path, extension)
51
- end
52
-
53
- # Return a path to this template within our default app/views directory.
54
- # In some circumstances, we may wish to prevent users from overloading views,
55
- # such as when we are testing plugins with views. In this case, return "".
56
- def full_template_path_from_application(template_path, extension)
57
- if Engines.disable_application_view_loading
58
- nil
59
- else
60
- full_template_path_without_engine_additions(template_path, extension)
61
- end
62
- end
63
- end
64
-
65
-
66
- # The Layout module overrides a single (private) method in ActionController::Layout::ClassMethods,
67
- # called #layout_list. This method now returns an array of layouts, including those in plugins.
68
- module Layout
69
- def self.included(base) #:nodoc:
70
- base.class_eval { alias_method_chain :layout_list, :engine_additions }
71
- end
72
-
73
- private
74
- # Return the list of layouts, including any in the <tt>app/views/layouts</tt>
75
- # directories of loaded plugins.
76
- def layout_list_with_engine_additions
77
- plugin_layouts = Rails.plugins.by_precedence.map do |p|
78
- File.join(p.root, "app", "views", "layouts")
79
- end
80
- layout_list_without_engine_additions + Dir["{#{plugin_layouts.join(",")}}/**/*"]
81
- end
82
- end
83
-
84
-
85
- # The way ActionMailer is coded in terms of finding templates is very restrictive, to the point
86
- # where all templates for rendering must exist under the single base path. This is difficult to
87
- # work around without re-coding significant parts of the action mailer code.
88
- #
89
- # ---
90
- #
91
- # The MailTemplates module overrides two (private) methods from ActionMailer to enable mail
92
- # templates within plugins:
93
- #
94
- # [+template_path+] which now produces the contents of #template_paths
95
- # [+render+] which now find the first matching template and creates an ActionVew::Base
96
- # instance with the correct @base_path for that template
97
- module MailTemplates
98
- def self.included(base) #:nodoc:
99
- base.class_eval do
100
- alias_method_chain :template_path, :engine_additions
101
- alias_method_chain :render, :engine_additions
102
- end
103
- end
104
-
105
- private
106
- # Returns all possible template paths for the current mailer, including those
107
- # within the loaded plugins.
108
- def template_paths
109
- paths = Rails.plugins.by_precedence.map { |p| "#{p.root}/app/views/#{mailer_name}" }
110
- paths.unshift(template_path_without_engine_additions) unless Engines.disable_application_view_loading
111
- paths
112
- end
113
-
114
- # Return something that Dir[] can glob against. This method is called in
115
- # ActionMailer::Base#create! and used as part of an argument to Dir. We can
116
- # take advantage of this by using some of the features of Dir.glob to search
117
- # multiple paths for matching files.
118
- def template_path_with_engine_additions
119
- "{#{template_paths.join(",")}}"
120
- end
121
-
122
- # We've broken this up so that we can dynamically alter the base_path that ActionView
123
- # is rendering from so that templates can be located from plugins.
124
- def render_with_engine_additions(opts)
125
- template_path_for_method = Dir["#{template_path}/#{opts[:file]}*"].first
126
- body = opts.delete(:body)
127
- i = initialize_template_class(body)
128
- i.base_path = File.dirname(template_path_for_method)
129
- i.render(opts)
130
- end
131
- end
132
- end
133
-
134
-
135
- ::ActionView::Base.send(:include, Engines::RailsExtensions::Templates::ActionView)
136
- ::ActionController::Layout::ClassMethods.send(:include, Engines::RailsExtensions::Templates::Layout)
137
-
138
- if Object.const_defined?(:ActionMailer) # We don't need to do this if ActionMailer hasn't been loaded.
139
- ::ActionMailer::Base.send(:include, Engines::RailsExtensions::Templates::MailTemplates)
140
- end
@@ -1,87 +0,0 @@
1
- # Contains the enhancements to assist in testing plugins. See Engines::Testing
2
- # for more details.
3
-
4
- require 'test/unit'
5
-
6
- require 'tmpdir'
7
- require 'fileutils'
8
-
9
- # In most cases, Rails' own plugin testing mechanisms are sufficient. However, there
10
- # are cases where plugins can be given a helping hand in the testing arena. This module
11
- # contains some methods to assist when testing plugins that contain fixtures.
12
- #
13
- # == Fixtures and plugins
14
- #
15
- # Since Rails' own fixtures method is fairly strict about where files can be loaded from,
16
- # the simplest approach when running plugin tests with fixtures is to simply copy all
17
- # fixtures into a single temporary location and inform the standard Rails mechanism to
18
- # use this directory, rather than RAILS_ROOT/test/fixtures.
19
- #
20
- # The Engines::Testing#setup_plugin_fixtures method does this, copying all plugin fixtures
21
- # into the temporary location before and tests are performed. This behaviour is invoked
22
- # the the rake tasks provided by the Engines plugin, in the "test:plugins" namespace. If
23
- # necessary, you can invoke the task manually.
24
- #
25
- # If you wish to take advantage of this, add a call to the Engines::Testing.set_fixture_path
26
- # method somewhere before your tests (in a test_helper file, or above the TestCase itself).
27
- #
28
- # = Testing plugins
29
- #
30
- # Normally testing a plugin will require that Rails is loaded, unless you are including
31
- # a skeleton Rails environment or set of mocks within your plugin tests. If you require
32
- # the Rails environment to be started, you must ensure that this actually happens; while
33
- # it's not obvious, your tests do not automatically run with Rails loaded.
34
- #
35
- # The simplest way to setup plugin tests is to include a test helper with the following
36
- # contents:
37
- #
38
- # # Load the normal Rails helper. This ensures the environment is loaded
39
- # require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper')
40
- # # Ensure that we are using the temporary fixture path
41
- # Engines::Testing.set_fixture_path
42
- #
43
- # Then run tests using the provided tasks (<tt>test:plugins</tt>, or the tasks that the engines
44
- # plugin provides - <tt>test:plugins:units</tt>, etc.).
45
- #
46
- # Alternatively, you can explicitly load the environment by adpating the contents of the
47
- # default <tt>test_helper</tt>:
48
- #
49
- # ENV["RAILS_ENV"] = "test"
50
- # # Note that we are requiring config/environment from the root of the enclosing application.
51
- # require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment")
52
- # require 'test_help'
53
- #
54
- module Engines::Testing
55
- mattr_accessor :temporary_fixtures_directory
56
- self.temporary_fixtures_directory = FileUtils.mkdir_p(File.join(Dir.tmpdir, "rails_fixtures"))
57
-
58
- # Copies fixtures from plugins and the application into a temporary directory
59
- # (Engines::Testing.temporary_fixtures_directory).
60
- #
61
- # If a set of plugins is not given, fixtures are copied from all plugins in order
62
- # of precedence, meaning that plugins can 'overwrite' the fixtures of others if they are
63
- # loaded later; the application's fixtures are copied last, allowing any custom fixtures
64
- # to override those in the plugins. If no argument is given, plugins are loaded via
65
- # PluginList#by_precedence.
66
- #
67
- # This method is called by the engines-supplied plugin testing rake tasks
68
- def self.setup_plugin_fixtures(plugins=Rails.plugins.by_precedence)
69
-
70
- # Copy all plugin fixtures, and then the application fixtures, into this directory
71
- plugins.each do |plugin|
72
- plugin_fixtures_directory = File.join(plugin.root, "test", "fixtures")
73
- if File.directory?(plugin_fixtures_directory)
74
- Engines.mirror_files_from(plugin_fixtures_directory, self.temporary_fixtures_directory)
75
- end
76
- end
77
- Engines.mirror_files_from(File.join(RAILS_ROOT, "test", "fixtures"),
78
- self.temporary_fixtures_directory)
79
- end
80
-
81
- # Sets the fixture path used by Test::Unit::TestCase to the temporary
82
- # directory which contains all plugin fixtures.
83
- def self.set_fixture_path
84
- Test::Unit::TestCase.fixture_path = self.temporary_fixtures_directory
85
- $LOAD_PATH.unshift self.temporary_fixtures_directory
86
- end
87
- end
@@ -1,149 +0,0 @@
1
- # This code lets us redefine existing Rake tasks, which is extremely
2
- # handy for modifying existing Rails rake tasks.
3
- # Credit for this snippet of code goes to Jeremy Kemper
4
- # http://pastie.caboo.se/9620
5
- unless Rake::TaskManager.methods.include?(:redefine_task)
6
- module Rake
7
- module TaskManager
8
- def redefine_task(task_class, args, &block)
9
- task_name, deps = resolve_args(args)
10
- task_name = task_class.scope_name(@scope, task_name)
11
- deps = [deps] unless deps.respond_to?(:to_ary)
12
- deps = deps.collect {|d| d.to_s }
13
- task = @tasks[task_name.to_s] = task_class.new(task_name, self)
14
- task.application = self
15
- task.add_comment(@last_comment)
16
- @last_comment = nil
17
- task.enhance(deps, &block)
18
- task
19
- end
20
- end
21
- class Task
22
- class << self
23
- def redefine_task(args, &block)
24
- Rake.application.redefine_task(self, args, &block)
25
- end
26
- end
27
- end
28
- end
29
- end
30
-
31
-
32
- namespace :db do
33
- namespace :fixtures do
34
- namespace :plugins do
35
-
36
- desc "Load plugin fixtures into the current environment's database."
37
- task :load => :environment do
38
- require 'active_record/fixtures'
39
- ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
40
- Dir.glob(File.join(RAILS_ROOT, 'vendor', 'plugins', ENV['PLUGIN'] || '**',
41
- 'test', 'fixtures', '*.yml')).each do |fixture_file|
42
- Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
43
- end
44
- end
45
-
46
- end
47
- end
48
- end
49
-
50
- # this is just a modification of the original task in railties/lib/tasks/documentation.rake,
51
- # because the default task doesn't support subdirectories like <plugin>/app or
52
- # <plugin>/component. These tasks now include every file under a plugin's code paths (see
53
- # Plugin#code_paths).
54
- namespace :doc do
55
-
56
- plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) }
57
-
58
- namespace :plugins do
59
-
60
- # Define doc tasks for each plugin
61
- plugins.each do |plugin|
62
- desc "Create plugin documentation for '#{plugin}'"
63
- Rake::Task.redefine_task(plugin => :environment) do
64
- plugin_base = RAILS_ROOT + "/vendor/plugins/#{plugin}"
65
- options = []
66
- files = Rake::FileList.new
67
- options << "-o doc/plugins/#{plugin}"
68
- options << "--title '#{plugin.titlecase} Plugin Documentation'"
69
- options << '--line-numbers' << '--inline-source'
70
- options << '-T html'
71
-
72
- # Include every file in the plugin's code_paths (see Plugin#code_paths)
73
- if Rails.plugins[plugin]
74
- files.include("#{plugin_base}/{#{Rails.plugins[plugin].code_paths.join(",")}}/**/*.rb")
75
- end
76
- if File.exists?("#{plugin_base}/README")
77
- files.include("#{plugin_base}/README")
78
- options << "--main '#{plugin_base}/README'"
79
- end
80
- files.include("#{plugin_base}/CHANGELOG") if File.exists?("#{plugin_base}/CHANGELOG")
81
-
82
- if files.empty?
83
- puts "No source files found in #{plugin_base}. No documentation will be generated."
84
- else
85
- options << files.to_s
86
- sh %(rdoc #{options * ' '})
87
- end
88
- end
89
- end
90
- end
91
- end
92
-
93
-
94
-
95
- namespace :test do
96
- task :warn_about_multiple_plugin_testing_with_engines do
97
- puts %{-~============== A Moste Polite Warninge ===========================~-
98
-
99
- You may experience issues testing multiple plugins at once when using
100
- the code-mixing features that the engines plugin provides. If you do
101
- experience any problems, please test plugins individually, i.e.
102
-
103
- $ rake test:plugins PLUGIN=my_plugin
104
-
105
- or use the per-type plugin test tasks:
106
-
107
- $ rake test:plugins:units
108
- $ rake test:plugins:functionals
109
- $ rake test:plugins:integration
110
- $ rake test:plugins:all
111
-
112
- Report any issues on http://dev.rails-engines.org. Thanks!
113
-
114
- -~===============( ... as you were ... )============================~-}
115
- end
116
-
117
- namespace :plugins do
118
-
119
- desc "Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name)"
120
- task :all => [:warn_about_multiple_plugin_testing_with_engines,
121
- :units, :functionals, :integration]
122
-
123
- desc "Run all plugin unit tests"
124
- Rake::TestTask.new(:units => :setup_plugin_fixtures) do |t|
125
- t.pattern = "vendor/plugins/#{ENV['PLUGIN'] || "**"}/test/unit/**/*_test.rb"
126
- t.verbose = true
127
- end
128
-
129
- desc "Run all plugin functional tests"
130
- Rake::TestTask.new(:functionals => :setup_plugin_fixtures) do |t|
131
- t.pattern = "vendor/plugins/#{ENV['PLUGIN'] || "**"}/test/functional/**/*_test.rb"
132
- t.verbose = true
133
- end
134
-
135
- desc "Integration test engines"
136
- Rake::TestTask.new(:integration => :setup_plugin_fixtures) do |t|
137
- t.pattern = "vendor/plugins/#{ENV['PLUGIN'] || "**"}/test/integration/**/*_test.rb"
138
- t.verbose = true
139
- end
140
-
141
- desc "Mirrors plugin fixtures into a single location to help plugin tests"
142
- task :setup_plugin_fixtures => :environment do
143
- Engines::Testing.setup_plugin_fixtures
144
- end
145
-
146
- # Patch the default plugin testing task to have setup_plugin_fixtures as a prerequisite
147
- Rake::Task["test:plugins"].prerequisites << "test:plugins:setup_plugin_fixtures"
148
- end
149
- end