[Git][noosfero/noosfero][master] 2 commits: CustomRoutesPlugin: treats invalid routes on reload
Rodrigo Souto
gitlab at mg.gitlab.com
Mon Jun 26 10:15:05 BRT 2017
Rodrigo Souto pushed to branch master at Noosfero / noosfero
Commits:
418a22f7 by Gabriel Silva at 2017-06-21T22:27:18+00:00
CustomRoutesPlugin: treats invalid routes on reload
Signed-off-by: Gabriel Silva <gabriel93.silva at gmail.com>
- - - - -
930edc33 by Rodrigo Souto at 2017-06-26T13:14:35+00:00
Merge branch 'custom_routes_fix' into 'master'
CustomRoutesPlugin: ignores invalid routes on reload
See merge request !1254
- - - - -
2 changed files:
- plugins/custom_routes/lib/custom_routes_plugin/custom_routes.rb
- plugins/custom_routes/test/integration/custom_routes_test.rb
Changes:
=====================================
plugins/custom_routes/lib/custom_routes_plugin/custom_routes.rb
=====================================
--- a/plugins/custom_routes/lib/custom_routes_plugin/custom_routes.rb
+++ b/plugins/custom_routes/lib/custom_routes_plugin/custom_routes.rb
@@ -4,8 +4,12 @@ class CustomRoutesPlugin::CustomRoutes
Noosfero::Application.routes.draw do
CustomRoutesPlugin::Route.where(enabled: true).each do |route|
- # TODO: also set query params? Maybe using a controller before_action
- get route.source_url, route.metadata.symbolize_keys
+ begin
+ # TODO: also set query params? Maybe using a controller before_action
+ get route.source_url, route.metadata.symbolize_keys
+ rescue
+ # ignore possible invalid routes, so the startup doesn't break
+ end
end
end
end
=====================================
plugins/custom_routes/test/integration/custom_routes_test.rb
=====================================
--- a/plugins/custom_routes/test/integration/custom_routes_test.rb
+++ b/plugins/custom_routes/test/integration/custom_routes_test.rb
@@ -28,4 +28,14 @@ class CustomRoutesTest < ActionDispatch::IntegrationTest
assert_template "not_found"
end
+ should 'not break when reloading routes with invalid records' do
+ fast_create(CustomRoutesPlugin::Route, source_url: '/source',
+ target_url: '/target', environment_id: Environment.default.id,
+ metadata: {})
+
+ assert_nothing_raised do
+ CustomRoutesPlugin::CustomRoutes.reload
+ end
+ end
+
end
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/c5d818e7f42922cb0582976983ce747a9c84e9ba...930edc3335915a4f28aaaba80e8358b1d2f495b4
---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/c5d818e7f42922cb0582976983ce747a9c84e9ba...930edc3335915a4f28aaaba80e8358b1d2f495b4
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170626/c66b9882/attachment-0001.html>
More information about the Noosfero-dev
mailing list