From 33f3be1c79209a3a232868b7a963f8205d9f844e Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Wed, 28 Sep 2016 21:23:01 -0500 Subject: [PATCH] fixed turbolinks/ready issue --- Gemfile.lock | 8 ++++---- app/assets/javascripts/passwords.js | 4 +++- app/views/accounts/index.html.erb | 2 +- app/views/layouts/application.html.erb | 9 ++++++--- test/controllers/auth_controller_test.rb | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c87d760..03d0dab 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -105,7 +105,7 @@ GEM railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (2.0.2) - jwt (1.5.5) + jwt (1.5.6) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -120,7 +120,7 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mini_portile2 (2.1.0) - minitest (5.9.0) + minitest (5.9.1) minitest-reporters (1.1.11) ansi builder @@ -145,7 +145,7 @@ GEM multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - parser (2.3.1.3) + parser (2.3.1.4) ast (~> 2.2) pkg-config (1.1.7) powerpack (0.1.1) @@ -188,7 +188,7 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.1.0) - rake (11.2.2) + rake (11.3.0) rb-fsevent (0.9.7) rb-inotify (0.9.7) ffi (>= 0.5.0) diff --git a/app/assets/javascripts/passwords.js b/app/assets/javascripts/passwords.js index 75d694f..44566cf 100644 --- a/app/assets/javascripts/passwords.js +++ b/app/assets/javascripts/passwords.js @@ -15,7 +15,9 @@ function revealPassword($src){ $src.removeClass('fa-lock').addClass('fa-unlock'); } -$(function(){ +// Use this instead of typical $().ready +// because turbolinks. +document.addEventListener("turbolinks:load", function() { $("[data-id=passwd]").on("ajax:success", "a", function(e, data){ getPassword($(e.target).parent(), data.hash); }); diff --git a/app/views/accounts/index.html.erb b/app/views/accounts/index.html.erb index 0765a56..7cf0e48 100644 --- a/app/views/accounts/index.html.erb +++ b/app/views/accounts/index.html.erb @@ -1,6 +1,6 @@

<%= notice %>

-

Accounts

+

FTP Accounts

diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 71b8c52..7fa5a86 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -4,13 +4,16 @@ FtpManager <%= csrf_meta_tags %> - <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> - <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + <%= stylesheet_link_tag('application', media: 'all', 'data-turbolinks-track' => 'reload') %> + <%= javascript_include_tag('application', 'data-turbolinks-track' => 'reload') %>
-

Welcome <%= session[:name] %>

+

+ Welcome <%= session[:name] %> + <% #= "(admin)" if session[:admin] == true %> +

<%= yield %> diff --git a/test/controllers/auth_controller_test.rb b/test/controllers/auth_controller_test.rb index 3650637..2292363 100644 --- a/test/controllers/auth_controller_test.rb +++ b/test/controllers/auth_controller_test.rb @@ -6,7 +6,7 @@ class AuthControllerTest < ActionDispatch::IntegrationTest test "Should fake login process" do # This is not a real test of AuthController! - # We are really testing that the monkey path is correct + # We are really testing that the monkey patch is correct # # This simply tests to make sure the test suite is # properly monkey patching the oAuth network call and