From 02b342b157f0aaa91e658e2cddf6245cd9cbc0e8 Mon Sep 17 00:00:00 2001 From: farhatahmad <35435341+farhatahmad@users.noreply.github.com> Date: Wed, 31 Jul 2019 11:45:15 -0400 Subject: [PATCH] GRN2-217: Fixes issues with recording rows and localization (fixed #703-#705) (#707) * Fixes issues with recording rows * Fixed small typo related to logs --- app/controllers/users_controller.rb | 2 +- app/helpers/recordings_helper.rb | 4 ++-- .../shared/components/_public_recording_row.html.erb | 8 +------- app/views/shared/components/_recording_row.html.erb | 2 +- config/environments/production.rb | 11 ++++------- config/locales/en.yml | 2 ++ spec/controllers/users_controller_spec.rb | 10 ++++++++++ spec/helpers/recordings_helper_spec.rb | 4 ++-- 8 files changed, 23 insertions(+), 20 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7303788a..779ed6f3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -24,7 +24,7 @@ class UsersController < ApplicationController include Recorder before_action :find_user, only: [:edit, :update, :destroy] - before_action :ensure_unauthenticated, only: [:new, :create] + before_action :ensure_unauthenticated, only: [:new, :create, :signin] # POST /u def create diff --git a/app/helpers/recordings_helper.rb b/app/helpers/recordings_helper.rb index e96fcd2f..0ab14306 100644 --- a/app/helpers/recordings_helper.rb +++ b/app/helpers/recordings_helper.rb @@ -21,7 +21,7 @@ module RecordingsHelper # Helper for converting BigBlueButton dates into the desired format. def recording_date(date) - date.strftime("%B #{date.day.ordinalize}, %Y.") + I18n.l date, format: "%B %d, %Y" end # Helper for converting BigBlueButton dates into a nice length string. @@ -32,7 +32,7 @@ module RecordingsHelper len = valid_playbacks.first[:length] if len > 60 - "#{(len / 60).to_i} hrs #{len % 60} mins" + "#{(len / 60).to_i} h #{len % 60} min" elsif len.zero? "< 1 min" else diff --git a/app/views/shared/components/_public_recording_row.html.erb b/app/views/shared/components/_public_recording_row.html.erb index baec07b7..4c1536f1 100644 --- a/app/views/shared/components/_public_recording_row.html.erb +++ b/app/views/shared/components/_public_recording_row.html.erb @@ -29,7 +29,7 @@ <% if recording_thumbnails? %> - + <% p = recording[:playbacks].find do |p| p.key?(:preview) end %> <% if p %> <% p[:preview][:images][:image].each do |img| %> @@ -39,15 +39,9 @@ <% end %> -
- <%= t("recording.table.length") %> -
<%= recording_length(recording[:playbacks]) %> -
- <%= t("recording.table.users") %> -
<%= recording[:participants] %> diff --git a/app/views/shared/components/_recording_row.html.erb b/app/views/shared/components/_recording_row.html.erb index 0a65bed2..deb79088 100644 --- a/app/views/shared/components/_recording_row.html.erb +++ b/app/views/shared/components/_recording_row.html.erb @@ -30,7 +30,7 @@ <% if recording_thumbnails? %> - + <% p = recording[:playbacks].find do |p| p.key?(:preview) end %> <% if p %> <% safe_recording_images(p[:preview][:images][:image]).each do |img| %> diff --git a/config/environments/production.rb b/config/environments/production.rb index 4b050c67..e309a9a8 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -51,13 +51,6 @@ Rails.application.configure do # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = (ENV["ENABLE_SSL"] == "true") - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug - - # Prepend all log lines with the following tags. - config.log_tags = [:request_id] - # Don't wrap form components in field_with_error divs ActionView::Base.field_error_proc = proc do |html_tag| html_tag.html_safe @@ -107,8 +100,12 @@ Rails.application.configure do config.log_formatter = proc do |severity, _time, _progname, msg| "#{severity}: #{msg} \n" end + config.log_level = :info + # Prepend all log lines with the following tags. + config.log_tags = [:request_id] + if ENV["RAILS_LOG_TO_STDOUT"] == "true" logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter diff --git a/config/locales/en.yml b/config/locales/en.yml index 542123ea..2fa42b00 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -113,6 +113,8 @@ en: cookie_button: I Agree copied: Copied copy: Copy + date: + month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December] default_admin: You are still using the default password for this account. Please click here to change it delete: Delete delivery_error: An error occured during email delivery. Please contact an administrator! diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 4bcbdfb7..b0af1bfa 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -62,6 +62,16 @@ describe UsersController, type: :controller do end end + describe "GET #signin" do + it "redirects to main room if already authenticated" do + user = create(:user) + @request.session[:user_id] = user.id + + post :signin + expect(response).to redirect_to(room_path(user.main_room)) + end + end + describe "GET #edit" do it "renders the edit template" do user = create(:user) diff --git a/spec/helpers/recordings_helper_spec.rb b/spec/helpers/recordings_helper_spec.rb index 795eeed6..ac8690c8 100644 --- a/spec/helpers/recordings_helper_spec.rb +++ b/spec/helpers/recordings_helper_spec.rb @@ -22,14 +22,14 @@ describe RecordingsHelper do describe "#recording_date" do it "formats the date" do date = DateTime.parse("2019-03-28 19:35:15 UTC") - expect(helper.recording_date(date)).to eql("March 28th, 2019.") + expect(helper.recording_date(date)).to eql("March 28, 2019") end end describe "#recording_length" do it "returns the time if length > 60" do playbacks = [{ type: "test", length: 85 }] - expect(helper.recording_length(playbacks)).to eql("1 hrs 25 mins") + expect(helper.recording_length(playbacks)).to eql("1 h 25 min") end it "returns the time if length == 0" do