[Git][noosfero/noosfero][master] 2 commits: Render index page when current theme is an angular theme

Leandro Nunes gitlab at mg.gitlab.com
Thu Jun 1 10:55:08 BRT 2017


Leandro Nunes pushed to branch master at Noosfero / noosfero


Commits:
d61290e3 by Victor Costa at 2017-05-30T11:29:15-03:00
Render index page when current theme is an angular theme

- - - - -
87f5c5a7 by Leandro Nunes at 2017-06-01T13:54:22+00:00
Merge branch 'angular-theme-route' into 'master'

Render index page when current theme is an angular theme

See merge request !1220
- - - - -


3 changed files:

- app/controllers/application_controller.rb
- test/functional/application_controller_test.rb
- + test/integration/angular_theme_test.rb


Changes:

=====================================
app/controllers/application_controller.rb
=====================================
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -14,6 +14,7 @@ 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,4 +213,8 @@ class ApplicationController < ActionController::Base
     end
   end
 
+  def verify_angular_theme
+    render 'home/index' if Theme.angular_theme?(current_theme) && !request.path.starts_with?('/api/')
+  end
+
 end


=====================================
test/functional/application_controller_test.rb
=====================================
--- a/test/functional/application_controller_test.rb
+++ b/test/functional/application_controller_test.rb
@@ -603,4 +603,9 @@ class ApplicationControllerTest < ActionController::TestCase
     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
=====================================
--- /dev/null
+++ b/test/integration/angular_theme_test.rb
@@ -0,0 +1,25 @@
+require_relative "../test_helper"
+
+class AngularThemeTest < ActionDispatch::IntegrationTest
+
+  should 'render index page for angular theme when access an inexistent route' do
+    Theme.stubs(:angular_theme?).returns(true)
+    profile = fast_create(Community)
+    get "/myprofile/#{profile.identifier}/members"
+    assert_response 200
+  end
+
+  should 'render not found when access an inexistent route' do
+    Theme.stubs(:angular_theme?).returns(false)
+    profile = fast_create(Community)
+    get "/myprofile/#{profile.identifier}/members"
+    assert_response 404
+  end
+
+  should 'render not found when theme is angular and path starts with api' do
+    Theme.stubs(:angular_theme?).returns(false)
+    profile = fast_create(Community)
+    get "/api/v1/some_endpoint"
+    assert_response 404
+  end
+end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/aa2d39258e3d9e5ad0c3cae10ab93e5050f0b8a1...87f5c5a79b81e20009574582906ac4a446ba2e06

---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/aa2d39258e3d9e5ad0c3cae10ab93e5050f0b8a1...87f5c5a79b81e20009574582906ac4a446ba2e06
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/20170601/b1cca4ce/attachment-0001.html>


More information about the Noosfero-dev mailing list