diff --git a/ruby/.simplecov b/ruby/.simplecov index 20d05200f..e2b9790a8 100644 --- a/ruby/.simplecov +++ b/ruby/.simplecov @@ -1,18 +1,22 @@ -SimpleCov.start do - add_filter "/test/" - add_filter "/bin/" - add_filter "/scripts/" - add_filter "/tmp/" - add_filter "/vendor/" -end +if ENV['COVERAGE'] == "1" - #SimpleCov.coverage_dir 'coverage/' - all_files = Dir['**/*.rb'] + SimpleCov.start do + add_filter "/test/" + add_filter "/bin/" + add_filter "/scripts/" + add_filter "/tmp/" + add_filter "/vendor/" + add_filter "/spec/" + end + + all_files = Dir['**/*.rb'] base_result = {} all_files.each do |file| absolute = File::expand_path(file) lines = File.readlines(absolute, :encoding => 'UTF-8') base_result[absolute] = lines.map do |l| + l.encode!('UTF-16', 'UTF-8', :invalid => :replace, :replace => '') + l.encode!('UTF-8', 'UTF-16') l.strip! l.empty? || l =~ /^end$/ || l[0] == '#' ? nil : 0 end @@ -29,3 +33,4 @@ end result.format! end +end diff --git a/web/app/controllers/clients_controller.rb b/web/app/controllers/clients_controller.rb index d8dde3f7a..455c23b03 100644 --- a/web/app/controllers/clients_controller.rb +++ b/web/app/controllers/clients_controller.rb @@ -1,5 +1,6 @@ class ClientsController < ApplicationController + include ClientHelper include UsersHelper def index @@ -19,15 +20,7 @@ class ClientsController < ApplicationController gon.allow_force_native_client = Rails.application.config.allow_force_native_client # is this the native client or browser? - user_agent = request.env["HTTP_USER_AGENT"] - @nativeClient = !user_agent.blank? && user_agent.downcase.include?("jamkazam") - - # allow override of the client type if configured to so, and if we find the override cookie in place - if Rails.application.config.allow_force_native_client - unless cookies[:act_as_native_client].nil? - @nativeClient = (cookies[:act_as_native_client] == "true") ? true : false - end - end + @nativeClient = is_native_client? # let javascript have access to the server's opinion if this is a native client gon.isNativeClient = @nativeClient diff --git a/web/app/controllers/users_controller.rb b/web/app/controllers/users_controller.rb index 6c98a031d..8e472e5be 100644 --- a/web/app/controllers/users_controller.rb +++ b/web/app/controllers/users_controller.rb @@ -3,10 +3,15 @@ require 'builder' class UsersController < ApplicationController + + include ClientHelper + before_filter :signed_in_user, only: [:index, :edit, :update, :destroy] before_filter :correct_user, only: [:edit, :update] before_filter :admin_user, only: :destroy + before_filter :is_native_client + rescue_from 'JamRuby::PermissionError' do |exception| @exception = exception @@ -326,6 +331,10 @@ class UsersController < ApplicationController private + def is_native_client + @nativeClient = is_native_client? + end + def correct_user @user = User.find(params[:id]) redirect_to(root_url) unless current_user?(@user) diff --git a/web/app/helpers/client_helper.rb b/web/app/helpers/client_helper.rb new file mode 100644 index 000000000..319b1456b --- /dev/null +++ b/web/app/helpers/client_helper.rb @@ -0,0 +1,18 @@ +module ClientHelper + + # is this the native client (or browser emulating native client with CTRL+SHIFT+0), or browser? + def is_native_client? + # is this the native client or browser? + user_agent = request.env["HTTP_USER_AGENT"] + is_native_client = !user_agent.blank? && user_agent.downcase.include?("jamkazam") + + # allow override of the client type if configured to so, and if we find the override cookie in place + if Rails.application.config.allow_force_native_client + unless cookies[:act_as_native_client].nil? + is_native_client = (cookies[:act_as_native_client] == "true") ? true : false + end + end + + is_native_client + end +end \ No newline at end of file diff --git a/web/app/views/users/_downloads.html.erb b/web/app/views/users/_downloads.html.erb index c44d4941a..0fe47521a 100644 --- a/web/app/views/users/_downloads.html.erb +++ b/web/app/views/users/_downloads.html.erb @@ -3,7 +3,7 @@
- < +
diff --git a/web/app/views/users/congratulations_fan.html.erb b/web/app/views/users/congratulations_fan.html.erb index 69cb626c2..5d94567bd 100644 --- a/web/app/views/users/congratulations_fan.html.erb +++ b/web/app/views/users/congratulations_fan.html.erb @@ -4,7 +4,7 @@

You have successfully registered as a JamKazam fan.

-
<%= link_to "PROCEED TO JAMKAZAM SITE", root_path, :class =>"button-orange m0" %>
+
<%= link_to "PROCEED TO JAMKAZAM SITE", client_path, :class =>"button-orange m0" %>