[Git][noosfero/noosfero][master] 2 commits: Do not mess piwik domain with protocol

Rodrigo Souto gitlab at mg.gitlab.com
Wed Aug 22 11:50:49 BRT 2018


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
492d4325 by Aurélio A. Heckert at 2018-08-21T20:58:57Z
Do not mess piwik domain with protocol

- - - - -
3233de53 by Rodrigo Souto at 2018-08-22T14:50:40Z
Merge branch 'piwik-link' into 'master'

Do not mess piwik domain with protocol

See merge request noosfero/noosfero!1600
- - - - -


5 changed files:

- plugins/piwik/controllers/piwik_plugin_admin_controller.rb
- plugins/piwik/lib/piwik_plugin.rb
- plugins/piwik/test/functional/piwik_plugin_test.rb
- plugins/piwik/test/integration/user_menu_test.rb
- plugins/piwik/views/piwik_plugin_admin/index.html.erb


Changes:

=====================================
plugins/piwik/controllers/piwik_plugin_admin_controller.rb
=====================================
@@ -4,6 +4,9 @@ class PiwikPluginAdminController < PluginAdminController
 
   def index
     if request.post?
+      if params[:environment][:piwik_domain]
+        params[:environment][:piwik_domain].sub! /^https?:\/\//, ''
+      end
       if @environment.update(params[:environment])
         session[:notice] = _('Piwik plugin settings updated successfully.')
       else


=====================================
plugins/piwik/lib/piwik_plugin.rb
=====================================
@@ -33,8 +33,7 @@ class PiwikPlugin < Noosfero::Plugin
       path = context.environment.piwik_path
       id_site = context.environment.piwik_site_id
       proc do
-        protocol = request.ssl? ? 'https' : 'http'
-        link = "#{protocol}://#{domain}/#{path}?idSite=#{id_site}"
+        link = "//#{domain}/#{path}?idSite=#{id_site}"
         {:title => _('Piwik'), :icon => 'chart-line', :url => link,
          :html_options => {:target => '_blank'}}
       end


=====================================
plugins/piwik/test/functional/piwik_plugin_test.rb
=====================================
@@ -21,10 +21,16 @@ class PiwikPluginAdminControllerTest < ActionController::TestCase
     assert_nil @environment.reload.piwik_domain
     assert_equal 'piwik', @environment.reload.piwik_path
     assert_nil @environment.reload.piwik_site_id
-    post :index, :environment => { :piwik_domain => 'something', :piwik_site_id => 10, :piwik_path => 'some_path' }
+    post :index, :environment => { piwik_domain: 'something', piwik_site_id: 10, piwik_path: 'some_path' }
     assert_equal 'something', @environment.reload.piwik_domain
     assert_equal '10', @environment.reload.piwik_site_id
     assert_equal 'some_path', @environment.reload.piwik_path
   end
 
+  should 'update piwik plugin settings with protocol on domain field' do
+    assert_nil @environment.reload.piwik_domain
+    post :index, :environment => { piwik_domain: 'http://something' }
+    assert_equal 'something', @environment.reload.piwik_domain
+  end
+
 end


=====================================
plugins/piwik/test/integration/user_menu_test.rb
=====================================
@@ -34,7 +34,7 @@ class AssetsMenuTest < ActionDispatch::IntegrationTest
     @environment.save
 
     get '/'
-    assert_tag 'a', attributes: { href: /http:\/\/piwik.org/ },
+    assert_tag 'a', attributes: { href: /^\/\/piwik.org/ },
                     ancestor: { tag: 'ul', attributes: { class: 'noosfero-dropdown-menu' } }
   end
 
@@ -45,7 +45,7 @@ class AssetsMenuTest < ActionDispatch::IntegrationTest
     @environment.save
 
     get '/'
-    assert_tag 'a', attributes: { href: /https:\/\/piwik.org/ },
+    assert_tag 'a', attributes: { href: /^\/\/piwik.org/ },
                     ancestor: { tag: 'ul', attributes: { class: 'noosfero-dropdown-menu' } }
   end
 


=====================================
plugins/piwik/views/piwik_plugin_admin/index.html.erb
=====================================
@@ -2,11 +2,11 @@
 
 <%= form_for(:environment) do |f| %>
 
-  <%= labelled_form_field _('Piwik domain'), f.text_field(:piwik_domain) %>
+  <%= labelled_form_field _('Piwik domain'), f.text_field(:piwik_domain, size: 30) %>
 
-  <%= labelled_form_field _('Piwik path'), f.text_field(:piwik_path) %>
+  <%= labelled_form_field _('Piwik path'), f.text_field(:piwik_path, size: 30) %>
 
-  <%= labelled_form_field _('Piwik site id'), f.text_field(:piwik_site_id) %>
+  <%= labelled_form_field _('Piwik site id'), f.number_field(:piwik_site_id, size: 3) %>
 
   <%= button_bar do %>
     <%= submit_button(:save, c_('Save'), :cancel => {:controller => 'plugins', :action => 'index'}) %>



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/172088021504575b4b8bb40eea2a8eda8c7c3af8...3233de53c1866a3489773cbba69d0a9654bc8e08

-- 
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/172088021504575b4b8bb40eea2a8eda8c7c3af8...3233de53c1866a3489773cbba69d0a9654bc8e08
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/20180822/dbba798f/attachment-0001.html>


More information about the Noosfero-dev mailing list