[Git][noosfero/noosfero][master] 2 commits: Render angular-theme when doesn't match any route
Leandro Nunes
gitlab at mg.gitlab.com
Mon Jun 5 11:37:20 BRT 2017
Leandro Nunes pushed to branch master at Noosfero / noosfero
Commits:
5d83b8c1 by Victor Costa at 2017-06-05T10:51:07-03:00
Render angular-theme when doesn't match any route
- - - - -
3b814421 by Leandro Nunes at 2017-06-05T14:36:48+00:00
Merge branch 'angular-theme-route' into 'master'
Fix route for angular-theme
See merge request !1227
- - - - -
7 changed files:
- + app/controllers/angular_theme_controller.rb
- app/controllers/application_controller.rb
- config/application.rb
- + config/routes/angular_theme/10_angular_theme.rb
- config/routes/cms/60_cms.rb
- test/functional/application_controller_test.rb
- test/integration/angular_theme_test.rb
Changes:
=====================================
app/controllers/angular_theme_controller.rb
=====================================
--- /dev/null
+++ b/app/controllers/angular_theme_controller.rb
@@ -0,0 +1,12 @@
+class AngularThemeController < ApplicationController
+ needs_profile
+ before_filter :verify_angular_theme
+
+ def index
+ render_not_found
+ end
+
+ def verify_angular_theme
+ render 'home/index' if Theme.angular_theme?(current_theme) && !request.path.starts_with?('/api/')
+ end
+end
=====================================
app/controllers/application_controller.rb
=====================================
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -14,7 +14,6 @@ class ApplicationController < ActionController::Base
before_filter :redirect_to_current_user
before_filter :set_session_theme
- before_filter :verify_angular_theme
# FIXME: only include necessary methods
include ApplicationHelper
@@ -212,9 +211,4 @@ class ApplicationController < ActionController::Base
end
end
end
-
- def verify_angular_theme
- render 'home/index' if Theme.angular_theme?(current_theme) && !request.path.starts_with?('/api/')
- end
-
end
=====================================
config/application.rb
=====================================
--- a/config/application.rb
+++ b/config/application.rb
@@ -127,7 +127,8 @@ module Noosfero
Dir['config/routes/myprofile/*.rb'] +
Dir['config/routes/admin/*.rb'] +
Dir['{baseplugins,config/plugins}/*/config/routes**.rb'] +
- Dir['config/routes/cms/*.rb']
+ Dir['config/routes/cms/*.rb'] +
+ Dir['config/routes/angular_theme/*.rb']
config.paths['db/migrate'].concat Dir.glob("{baseplugins,config/plugins}/*/db/migrate")
config.i18n.load_path.concat Dir.glob("{baseplugins,config/plugins}/*/locales/*.{rb,yml}")
=====================================
config/routes/angular_theme/10_angular_theme.rb
=====================================
--- /dev/null
+++ b/config/routes/angular_theme/10_angular_theme.rb
@@ -0,0 +1,3 @@
+Noosfero::Application.routes.draw do
+ match 'myprofile/:profile/(*page)', controller: :angular_theme, action: :index, profile: /#{Noosfero.identifier_format_in_url}/i, via: :get
+end
=====================================
config/routes/cms/60_cms.rb
=====================================
--- a/config/routes/cms/60_cms.rb
+++ b/config/routes/cms/60_cms.rb
@@ -1,6 +1,6 @@
Noosfero::Application.routes.draw do
- environment_domain_constraint = -> request { !Domain.hosting_profile_at(request.host) }
+ environment_domain_constraint = -> request { !Domain.hosting_profile_at(request.host) && !request.path.starts_with?('/myprofile') }
match ':profile/*page/versions', controller: :content_viewer, action: :article_versions, profile: /#{Noosfero.identifier_format_in_url}/i, constraints: environment_domain_constraint, via: :all
match '*page/versions', controller: :content_viewer, action: :article_versions, via: :all
@@ -13,6 +13,6 @@ Noosfero::Application.routes.draw do
constraints: environment_domain_constraint, via: :all, as: :page
# match requests for content in domains hosted for profiles
- match '/(*page)', controller: :content_viewer, action: :view_page, via: :all
+ match '/(*page)', controller: :content_viewer, action: :view_page, via: :all, constraints: lambda { |request| !request.path.starts_with?('/myprofile') }
end
=====================================
test/functional/application_controller_test.rb
=====================================
--- a/test/functional/application_controller_test.rb
+++ b/test/functional/application_controller_test.rb
@@ -602,10 +602,4 @@ class ApplicationControllerTest < ActionController::TestCase
get :index, :theme => 'another_theme'
assert_nil @request.session[:theme]
end
-
- should 'render index page when theme is angular' do
- Theme.stubs(:angular_theme?).returns(true)
- get :index
- assert_template 'home/index'
- end
end
=====================================
test/integration/angular_theme_test.rb
=====================================
--- a/test/integration/angular_theme_test.rb
+++ b/test/integration/angular_theme_test.rb
@@ -22,4 +22,13 @@ class AngularThemeTest < ActionDispatch::IntegrationTest
get "/api/v1/some_endpoint"
assert_response 404
end
+
+ should 'render index page for angular theme when access myprofile route of an angular profile' do
+ Theme.stubs(:angular_theme?).with('noosfero').returns(false)
+ Theme.stubs(:angular_theme?).with('angular').returns(true)
+ profile = fast_create(Community)
+ profile.update_attribute(:theme, 'angular')
+ get "/myprofile/#{profile.identifier}/members"
+ assert_response 200
+ end
end
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/0094e86d3f3eddaea9bcae9f5b141bc173260ed7...3b8144214d1d0a6ab0e8da542e83777320b23305
---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/0094e86d3f3eddaea9bcae9f5b141bc173260ed7...3b8144214d1d0a6ab0e8da542e83777320b23305
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/20170605/23b20a8e/attachment-0001.html>
More information about the Noosfero-dev
mailing list