From 4d6c3e1dd4f0befff71eb9816a473ba0ce3c5509 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 22:30:09 +0000 Subject: [PATCH 01/22] Bump pghero from 3.5.0 to 3.6.0 Bumps [pghero](https://github.com/ankane/pghero) from 3.5.0 to 3.6.0. - [Changelog](https://github.com/ankane/pghero/blob/master/CHANGELOG.md) - [Commits](https://github.com/ankane/pghero/compare/v3.5.0...v3.6.0) --- updated-dependencies: - dependency-name: pghero dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 526cf4ae..eb6e03f0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -304,8 +304,8 @@ GEM ast (~> 2.4.1) racc pg (1.5.7) - pghero (3.5.0) - activerecord (>= 6) + pghero (3.6.0) + activerecord (>= 6.1) prometheus-client (4.2.3) base64 public_suffix (6.0.1) From 6cc8ebcba3814ae146b733f361530b331172ccfd Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Fri, 9 Aug 2024 05:53:37 +0200 Subject: [PATCH 02/22] Add ability to disable registrations --- .../user/registrations_controller.rb | 12 +++++- app/views/about/index.html.haml | 33 ++++++++++------- app/views/application/_questionbox.html.haml | 37 +++++++++++-------- app/views/navigation/_guest.html.haml | 3 +- config/justask.yml.example | 3 ++ config/locales/views.en.yml | 3 ++ config/routes.rb | 2 +- 7 files changed, 60 insertions(+), 33 deletions(-) diff --git a/app/controllers/user/registrations_controller.rb b/app/controllers/user/registrations_controller.rb index e4f2e906..fbfe1f81 100644 --- a/app/controllers/user/registrations_controller.rb +++ b/app/controllers/user/registrations_controller.rb @@ -1,9 +1,13 @@ +# frozen_string_literal: true + class User::RegistrationsController < Devise::RegistrationsController + before_action :redirect_if_registrations_disabled!, only: %w[create new] + def create if captcha_valid? super else - respond_with_navigational(resource){ redirect_to new_user_registration_path } + respond_with_navigational(resource) { redirect_to new_user_registration_path } end end @@ -18,7 +22,7 @@ class User::RegistrationsController < Devise::RegistrationsController resource.destroy set_flash_message :notice, :destroyed if is_flashing_format? yield resource if block_given? - respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) } + respond_with_navigational(resource) { redirect_to after_sign_out_path_for(resource_name) } end private @@ -29,4 +33,8 @@ class User::RegistrationsController < Devise::RegistrationsController verify_hcaptcha end + + def redirect_if_registrations_disabled! + redirect_to root_path unless APP_CONFIG.dig(:features, :registration, :enabled) + end end diff --git a/app/views/about/index.html.haml b/app/views/about/index.html.haml index 87bf9d14..f35cb2c9 100644 --- a/app/views/about/index.html.haml +++ b/app/views/about/index.html.haml @@ -5,12 +5,18 @@ = render "layouts/messages" %h1= APP_CONFIG["site_name"] %p= t(".subtitle") - %p - %a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_registration_path) } - = t(".register") - %small - = t(".already_member") - = link_to t("voc.login"), new_user_session_path + - if APP_CONFIG.dig(:features, :registration, :enabled) + %p + %a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_registration_path) } + = t(".register") + %small + = t(".already_member") + = link_to t("voc.login"), new_user_session_path + - else + %p + %a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_session_path) } + = t("voc.login") + .row.my-5.my-sm-10 .col-sm-6.order-5.order-sm-1.text-center.text-sm-right %h2.mb-4= t(".questions.header") @@ -77,12 +83,13 @@ = t(".your_data.header") %p= t(".your_data.body", app_name: APP_CONFIG["site_name"]) - .card - .card-body - %h2= t(".prompt.header") - %p= t(".prompt.body") - %p - %a.btn.btn-primary.btn-lg{ href: url_for(new_user_registration_path) } - = t(".register") + - if APP_CONFIG.dig(:features, :registration, :enabled) + .card + .card-body + %h2= t(".prompt.header") + %p= t(".prompt.body") + %p + %a.btn.btn-primary.btn-lg{ href: url_for(new_user_registration_path) } + = t(".register") = render "shared/links" diff --git a/app/views/application/_questionbox.html.haml b/app/views/application/_questionbox.html.haml index c6bfee72..33ecf06f 100644 --- a/app/views/application/_questionbox.html.haml +++ b/app/views/application/_questionbox.html.haml @@ -40,24 +40,29 @@ %input{ name: "qb-to", type: "hidden", value: user.id }/ %button.btn.btn-primary{ name: "qb-ask", type: :button, - data: { loading_text: t(".load"), promote: user_signed_in? ? "false" : "true", "character-count-target": "action" } } + data: { loading_text: t(".load"), promote: user_signed_in? || !user_signed_in? && !APP_CONFIG.dig(:features, :registration, :enabled) ? "false" : "true", "character-count-target": "action" } } Ask - unless user_signed_in? - if user.privacy_allow_anonymous_questions? - .d-none#question-box-promote - .row - .col-12.text-center - %strong= t(".promote.message") - .row - .col-sm-5.offset-sm-1 - .d-grid - %button.btn.btn-primary#create-account= t(".promote.create") - .col-sm-5 - .d-grid - %button.btn.btn-default#new-question= t(".promote.another") - .row - .col-xs-12.col-sm-10.offset-sm-1.text-center - %small= t(".promote.join", app_title: APP_CONFIG["site_name"]) + - if APP_CONFIG.dig(:features, :registration, :enabled) + .d-none#question-box-promote + .row + .col-12.text-center + %strong= t(".promote.message") + .row + .col-sm-5.offset-sm-1 + .d-grid + %button.btn.btn-primary#create-account= t(".promote.create") + .col-sm-5 + .d-grid + %button.btn.btn-default#new-question= t(".promote.another") + .row + .col-xs-12.col-sm-10.offset-sm-1.text-center + %small= t(".promote.join", app_title: APP_CONFIG["site_name"]) - else .text-center - %strong= t(".status.non_anonymous_html", sign_in: link_to(t("voc.login"), new_user_session_path), sign_up: link_to(t("voc.register"), new_user_registration_path)) + - if APP_CONFIG.dig(:features, :registration, :enabled) + %strong= t(".status.non_anonymous_html", sign_in: link_to(t("voc.login"), new_user_session_path), sign_up: link_to(t("voc.register"), new_user_registration_path)) + - else + %strong= t(".status.non_anonymous_no_registration_html", sign_in: link_to(t("voc.login"), new_user_session_path)) + diff --git a/app/views/navigation/_guest.html.haml b/app/views/navigation/_guest.html.haml index 4d9c330d..a06fab83 100644 --- a/app/views/navigation/_guest.html.haml +++ b/app/views/navigation/_guest.html.haml @@ -14,4 +14,5 @@ .collapse.navbar-collapse#j2-main-navbar-collapse %ul.nav.navbar-nav.ms-auto = nav_entry t("voc.login"), new_user_session_path - = nav_entry t("voc.register"), new_user_registration_path + - if APP_CONFIG.dig(:features, :registration, :enabled) + = nav_entry t("voc.register"), new_user_registration_path diff --git a/config/justask.yml.example b/config/justask.yml.example index 22f309a4..f27c3089 100644 --- a/config/justask.yml.example +++ b/config/justask.yml.example @@ -52,6 +52,9 @@ features: # Public timeline public: enabled: true + # Registrations + registration: + enabled: true # Redis redis_url: "redis://localhost:6379" diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index f918d3e4..c938bf06 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -146,6 +146,9 @@ en: non_anonymous_html: | This user does not want to receive anonymous questions.
(%{sign_in} or %{sign_up}) + non_anonymous_no_registration_html: | + This user does not want to receive anonymous questions.
+ (%{sign_in}) comment: show_reactions: title: "People who smiled this comment" diff --git a/config/routes.rb b/config/routes.rb index 52d1f53b..9790212f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -63,7 +63,7 @@ Rails.application.routes.draw do # :registrations get "settings/delete_account" => "devise/registrations#cancel", :as => :cancel_user_registration post "/user/create" => "user/registrations#create", :as => :user_registration - get "/sign_up" => "devise/registrations#new", :as => :new_user_registration + get "/sign_up" => "user/registrations#new", :as => :new_user_registration get "/settings/account" => "devise/registrations#edit", :as => :edit_user_registration patch "/settings/account" => "devise/registrations#update", :as => :update_user_registration put "/settings/account" => "devise/registrations#update" From 4e5b0a85624505e1c25893c5a033dc4bc1988b1f Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Fri, 9 Aug 2024 05:54:04 +0200 Subject: [PATCH 03/22] Add specs to check for dis/enabled registrations --- .../user/registration_controller_spec.rb | 50 +++++++++++++++---- spec/views/about/index.html.haml_spec.rb | 35 +++++++++++++ .../views/navigation/_guest.html.haml_spec.rb | 29 +++++++++++ 3 files changed, 104 insertions(+), 10 deletions(-) create mode 100644 spec/views/about/index.html.haml_spec.rb create mode 100644 spec/views/navigation/_guest.html.haml_spec.rb diff --git a/spec/controllers/user/registration_controller_spec.rb b/spec/controllers/user/registration_controller_spec.rb index c31f5670..59f10468 100644 --- a/spec/controllers/user/registration_controller_spec.rb +++ b/spec/controllers/user/registration_controller_spec.rb @@ -15,14 +15,15 @@ describe User::RegistrationsController, type: :controller do justask_admin retrospring_admin admin justask retrospring moderation moderator mod administrator siteadmin site_admin help retro_spring retroospring retrosprlng - ] - }) + ], + },) end describe "#create" do context "valid user sign up" do before do allow(APP_CONFIG).to receive(:dig).with(:hcaptcha, :enabled).and_return(true) + allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(true) allow(controller).to receive(:verify_hcaptcha).and_return(captcha_successful) end @@ -32,8 +33,8 @@ describe User::RegistrationsController, type: :controller do screen_name: "dio", email: "the-world-21@somewhere.everywhere.now", password: "AReallySecurePassword456!", - password_confirmation: "AReallySecurePassword456!" - } + password_confirmation: "AReallySecurePassword456!", + }, } end @@ -59,6 +60,7 @@ describe User::RegistrationsController, type: :controller do context "invalid user sign up" do before do allow(APP_CONFIG).to receive(:dig).with(:hcaptcha, :enabled).and_return(false) + allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(true) end subject { post :create, params: registration_params } @@ -70,8 +72,8 @@ describe User::RegistrationsController, type: :controller do screen_name: "", email: "", password: "", - password_confirmation: "" - } + password_confirmation: "", + }, } end @@ -87,8 +89,8 @@ describe User::RegistrationsController, type: :controller do screen_name: "Dio Brando", email: "the-world-21@somewhere.everywhere.now", password: "AReallySecurePassword456!", - password_confirmation: "AReallySecurePassword456!" - } + password_confirmation: "AReallySecurePassword456!", + }, } end @@ -104,8 +106,8 @@ describe User::RegistrationsController, type: :controller do screen_name: "moderator", email: "the-world-21@somewhere.everywhere.now", password: "AReallySecurePassword456!", - password_confirmation: "AReallySecurePassword456!" - } + password_confirmation: "AReallySecurePassword456!", + }, } end @@ -114,5 +116,33 @@ describe User::RegistrationsController, type: :controller do end end end + + context "when registrations are disabled" do + before do + allow(APP_CONFIG).to receive(:dig).with(:hcaptcha, :enabled).and_return(false) + allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(false) + end + + it "redirects to the root page" do + subject + expect(response).to redirect_to(root_path) + end + end + end + + describe "#new" do + subject { get :new } + + context "when registrations are disabled" do + before do + allow(APP_CONFIG).to receive(:dig).with(:hcaptcha, :enabled).and_return(false) + allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(false) + end + + it "redirects to the root page" do + subject + expect(response).to redirect_to(root_path) + end + end end end diff --git a/spec/views/about/index.html.haml_spec.rb b/spec/views/about/index.html.haml_spec.rb new file mode 100644 index 00000000..0551a9c8 --- /dev/null +++ b/spec/views/about/index.html.haml_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe "about/index.html.haml", type: :view do + before do + stub_const("APP_CONFIG", { + "hostname" => "example.com", + "https" => true, + "sitename" => "yastask", + },) + end + + subject(:rendered) { render } + + context "registrations are enabled" do + before do + allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(true) + end + + it "has references to registering now" do + expect(rendered).to match(/Register now/) + end + end + + context "registrations are disabled" do + before do + allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(false) + end + + it "has no references to registering now" do + expect(rendered).to_not match(/Register now/) + end + end +end diff --git a/spec/views/navigation/_guest.html.haml_spec.rb b/spec/views/navigation/_guest.html.haml_spec.rb new file mode 100644 index 00000000..8f60c87d --- /dev/null +++ b/spec/views/navigation/_guest.html.haml_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe "navigation/_guest.html.haml", type: :view do + subject(:rendered) do + render partial: "navigation/guest" + end + + context "registrations are enabled" do + before do + allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(true) + end + + it "has a sign up link" do + expect(rendered).to match(/Sign up/) + end + end + + context "registrations are disabled" do + before do + allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(false) + end + + it "has no sign up link" do + expect(rendered).to_not match(/Sign up/) + end + end +end From 5cee6e3e3c7548016b23f411f9c2406c09f53a3d Mon Sep 17 00:00:00 2001 From: Jyrki Gadinger Date: Fri, 9 Aug 2024 10:57:08 +0200 Subject: [PATCH 04/22] fix registration controller spec --- .../user/registration_controller_spec.rb | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/spec/controllers/user/registration_controller_spec.rb b/spec/controllers/user/registration_controller_spec.rb index 59f10468..66484123 100644 --- a/spec/controllers/user/registration_controller_spec.rb +++ b/spec/controllers/user/registration_controller_spec.rb @@ -24,7 +24,6 @@ describe User::RegistrationsController, type: :controller do before do allow(APP_CONFIG).to receive(:dig).with(:hcaptcha, :enabled).and_return(true) allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(true) - allow(controller).to receive(:verify_hcaptcha).and_return(captcha_successful) end let :registration_params do @@ -41,7 +40,10 @@ describe User::RegistrationsController, type: :controller do subject { post :create, params: registration_params } context "when captcha is invalid" do - let(:captcha_successful) { false } + before do + allow(controller).to receive(:verify_hcaptcha).and_return(false) + end + it "doesn't allow a registration with an invalid captcha" do expect { subject }.not_to(change { User.count }) expect(response).to redirect_to :new_user_registration @@ -49,12 +51,33 @@ describe User::RegistrationsController, type: :controller do end context "when captcha is valid" do - let(:captcha_successful) { true } + before do + allow(controller).to receive(:verify_hcaptcha).and_return(true) + end + it "creates a user" do allow(controller).to receive(:verify_hcaptcha).and_return(true) expect { subject }.to change { User.count }.by(1) end end + + context "when registrations are disabled" do + before do + allow(APP_CONFIG).to receive(:dig).with(:hcaptcha, :enabled).and_return(false) + allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(false) + end + + it "redirects to the root page" do + allow(controller).to receive(:verify_hcaptcha).and_return(true) + subject + expect(response).to redirect_to(root_path) + end + + it "does not create a user" do + allow(controller).to receive(:verify_hcaptcha).and_return(true) + expect { subject }.not_to(change { User.count }) + end + end end context "invalid user sign up" do @@ -116,18 +139,6 @@ describe User::RegistrationsController, type: :controller do end end end - - context "when registrations are disabled" do - before do - allow(APP_CONFIG).to receive(:dig).with(:hcaptcha, :enabled).and_return(false) - allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(false) - end - - it "redirects to the root page" do - subject - expect(response).to redirect_to(root_path) - end - end end describe "#new" do From 076f71860fd0f914db408751854d7265db0e9778 Mon Sep 17 00:00:00 2001 From: Jyrki Gadinger Date: Fri, 9 Aug 2024 11:12:27 +0200 Subject: [PATCH 05/22] herr inspektor, bei allem respekt, gusch herst --- app/controllers/user/registrations_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/user/registrations_controller.rb b/app/controllers/user/registrations_controller.rb index fbfe1f81..721225dc 100644 --- a/app/controllers/user/registrations_controller.rb +++ b/app/controllers/user/registrations_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class User::RegistrationsController < Devise::RegistrationsController - before_action :redirect_if_registrations_disabled!, only: %w[create new] + before_action :redirect_if_registrations_disabled!, only: %w[create new] # rubocop:disable Rails/LexicallyScopedActionFilter def create if captcha_valid? From ca98b9dd7f96690b99914496259961808f7643d7 Mon Sep 17 00:00:00 2001 From: Jyrki Gadinger Date: Fri, 9 Aug 2024 11:12:38 +0200 Subject: [PATCH 06/22] move site config from initialiser to own module for potential improvements in how to access common configs when needed ... way better than using `.dig` by hand everywhere i'd say --- .../user/registrations_controller.rb | 2 +- app/views/about/index.html.haml | 2 +- app/views/application/_questionbox.html.haml | 6 ++-- app/views/navigation/_guest.html.haml | 2 +- config/initializers/10_config.rb | 21 +------------- lib/retrospring/config.rb | 29 +++++++++++++++++++ 6 files changed, 36 insertions(+), 26 deletions(-) create mode 100644 lib/retrospring/config.rb diff --git a/app/controllers/user/registrations_controller.rb b/app/controllers/user/registrations_controller.rb index 721225dc..b7b633b8 100644 --- a/app/controllers/user/registrations_controller.rb +++ b/app/controllers/user/registrations_controller.rb @@ -35,6 +35,6 @@ class User::RegistrationsController < Devise::RegistrationsController end def redirect_if_registrations_disabled! - redirect_to root_path unless APP_CONFIG.dig(:features, :registration, :enabled) + redirect_to root_path unless Retrospring::Config.registrations_enabled? end end diff --git a/app/views/about/index.html.haml b/app/views/about/index.html.haml index f35cb2c9..93e9a195 100644 --- a/app/views/about/index.html.haml +++ b/app/views/about/index.html.haml @@ -5,7 +5,7 @@ = render "layouts/messages" %h1= APP_CONFIG["site_name"] %p= t(".subtitle") - - if APP_CONFIG.dig(:features, :registration, :enabled) + - if Retrospring::Config.registrations_enabled? %p %a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_registration_path) } = t(".register") diff --git a/app/views/application/_questionbox.html.haml b/app/views/application/_questionbox.html.haml index 33ecf06f..ba51deaf 100644 --- a/app/views/application/_questionbox.html.haml +++ b/app/views/application/_questionbox.html.haml @@ -40,11 +40,11 @@ %input{ name: "qb-to", type: "hidden", value: user.id }/ %button.btn.btn-primary{ name: "qb-ask", type: :button, - data: { loading_text: t(".load"), promote: user_signed_in? || !user_signed_in? && !APP_CONFIG.dig(:features, :registration, :enabled) ? "false" : "true", "character-count-target": "action" } } + data: { loading_text: t(".load"), promote: user_signed_in? || !user_signed_in? && !Retrospring::Config.registrations_enabled ? "false" : "true", "character-count-target": "action" } } Ask - unless user_signed_in? - if user.privacy_allow_anonymous_questions? - - if APP_CONFIG.dig(:features, :registration, :enabled) + - if Retrospring::Config.registrations_enabled? .d-none#question-box-promote .row .col-12.text-center @@ -61,7 +61,7 @@ %small= t(".promote.join", app_title: APP_CONFIG["site_name"]) - else .text-center - - if APP_CONFIG.dig(:features, :registration, :enabled) + - if Retrospring::Config.registrations_enabled? %strong= t(".status.non_anonymous_html", sign_in: link_to(t("voc.login"), new_user_session_path), sign_up: link_to(t("voc.register"), new_user_registration_path)) - else %strong= t(".status.non_anonymous_no_registration_html", sign_in: link_to(t("voc.login"), new_user_session_path)) diff --git a/app/views/navigation/_guest.html.haml b/app/views/navigation/_guest.html.haml index a06fab83..69bf3a62 100644 --- a/app/views/navigation/_guest.html.haml +++ b/app/views/navigation/_guest.html.haml @@ -14,5 +14,5 @@ .collapse.navbar-collapse#j2-main-navbar-collapse %ul.nav.navbar-nav.ms-auto = nav_entry t("voc.login"), new_user_session_path - - if APP_CONFIG.dig(:features, :registration, :enabled) + - if Retrospring::Config.registrations_enabled? = nav_entry t("voc.register"), new_user_registration_path diff --git a/config/initializers/10_config.rb b/config/initializers/10_config.rb index deba98c4..6a366cef 100644 --- a/config/initializers/10_config.rb +++ b/config/initializers/10_config.rb @@ -1,23 +1,4 @@ # frozen_string_literal: true # Auxiliary config - -APP_CONFIG = {}.with_indifferent_access - -# load yml config if it's present -justask_yml_path = Rails.root.join("config/justask.yml") -APP_CONFIG.merge!(YAML.load_file(justask_yml_path)) if File.exist?(justask_yml_path) - -# load config from ENV where possible -env_config = { - # The site name, shown everywhere - site_name: ENV.fetch("SITE_NAME", nil), - - hostname: ENV.fetch("HOSTNAME", nil), -}.compact -APP_CONFIG.merge!(env_config) - -# Update rails config for mail -Rails.application.config.action_mailer.default_url_options = { - host: APP_CONFIG["hostname"], -} +APP_CONFIG = Retrospring::Config.config_hash diff --git a/lib/retrospring/config.rb b/lib/retrospring/config.rb new file mode 100644 index 00000000..a4c7fbd4 --- /dev/null +++ b/lib/retrospring/config.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module Retrospring + module Config + module_function + + def config_hash = {}.with_indifferent_access.tap do |hash| + # load yml config if it's present + justask_yml_path = Rails.root.join("config/justask.yml") + hash.merge!(YAML.load_file(justask_yml_path)) if File.exist?(justask_yml_path) + + # load config from ENV where possible + env_config = { + # The site name, shown everywhere + site_name: ENV.fetch("SITE_NAME", nil), + + hostname: ENV.fetch("HOSTNAME", nil), + }.compact + hash.merge!(env_config) + + # Update rails config for mail + Rails.application.config.action_mailer.default_url_options = { + host: hash["hostname"], + } + end + + def registrations_enabled? = APP_CONFIG.dig(:features, :registration, :enabled) + end +end From da0570164afe6bd901830b873ddb4f54d8f1d976 Mon Sep 17 00:00:00 2001 From: Jyrki Gadinger Date: Fri, 9 Aug 2024 11:13:54 +0200 Subject: [PATCH 07/22] remove sign up link on devise views when registrations are disabled --- app/views/devise/shared/_links.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/devise/shared/_links.html.haml b/app/views/devise/shared/_links.html.haml index 18ff87cc..8512a6e1 100644 --- a/app/views/devise/shared/_links.html.haml +++ b/app/views/devise/shared/_links.html.haml @@ -2,7 +2,7 @@ = link_to 'Sign in', new_session_path(resource_name) %br/ -- if devise_mapping.registerable? && controller_name != 'registrations' +- if devise_mapping.registerable? && controller_name != 'registrations' && Retrospring::Config.registrations_enabled? = link_to 'Sign up', new_registration_path(resource_name) %br/ From f19f7c9da512c78062802135b3042470b129d19f Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 10 Aug 2024 01:28:29 +0200 Subject: [PATCH 08/22] Fix haml-lint nits --- app/views/application/_questionbox.html.haml | 23 +++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/app/views/application/_questionbox.html.haml b/app/views/application/_questionbox.html.haml index ba51deaf..447c123c 100644 --- a/app/views/application/_questionbox.html.haml +++ b/app/views/application/_questionbox.html.haml @@ -19,10 +19,14 @@ %strong= t(".status.locked") - elsif !user_signed_in? && user.privacy_require_user? .text-center - %strong= t(".status.require_user_html", sign_in: link_to(t("voc.login"), new_user_session_path), sign_up: link_to(t("voc.register"), new_user_registration_path)) + %strong= t(".status.require_user_html", + sign_in: link_to(t("voc.login"), new_user_session_path), + sign_up: link_to(t("voc.register"), new_user_registration_path)) - else - if user_signed_in? || user.privacy_allow_anonymous_questions? - #question-box{ data: user.profile.allow_long_questions ? {} : { controller: "character-count", "character-count-max-value": user.profile.question_length_limit }} + #question-box{ + data: user.profile.allow_long_questions ? {} : { controller: "character-count", "character-count-max-value": user.profile.question_length_limit } + } %textarea.form-control{ name: "qb-question", placeholder: t(".placeholder"), data: { "character-count-target": "input" } } .row{ style: "padding-top: 5px;" } .col-6 @@ -36,11 +40,17 @@ %input{ name: "qb-anonymous", type: :hidden, value: false }/ .col-6 %p.pull-right - %span.text-muted.me-1{ class: user.profile.allow_long_questions ? "d-none" : "", data: { "character-count-target": "counter" } }= Question::SHORT_QUESTION_MAX_LENGTH + %span.text-muted.me-1{ class: user.profile.allow_long_questions ? "d-none" : "", + data: { "character-count-target": "counter" } }= Question::SHORT_QUESTION_MAX_LENGTH %input{ name: "qb-to", type: "hidden", value: user.id }/ %button.btn.btn-primary{ name: "qb-ask", type: :button, - data: { loading_text: t(".load"), promote: user_signed_in? || !user_signed_in? && !Retrospring::Config.registrations_enabled ? "false" : "true", "character-count-target": "action" } } + data: { + loading_text: t(".load"), + promote: user_signed_in? || !user_signed_in? && !Retrospring::Config.registrations_enabled ? "false" : "true", + "character-count-target": "action" + } + } Ask - unless user_signed_in? - if user.privacy_allow_anonymous_questions? @@ -62,7 +72,8 @@ - else .text-center - if Retrospring::Config.registrations_enabled? - %strong= t(".status.non_anonymous_html", sign_in: link_to(t("voc.login"), new_user_session_path), sign_up: link_to(t("voc.register"), new_user_registration_path)) + %strong= t(".status.non_anonymous_html", + sign_in: link_to(t("voc.login"), new_user_session_path), + sign_up: link_to(t("voc.register"), new_user_registration_path)) - else %strong= t(".status.non_anonymous_no_registration_html", sign_in: link_to(t("voc.login"), new_user_session_path)) - From 1e267c80313a650b5bb715975a629e5f62649d39 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 10 Aug 2024 01:44:53 +0200 Subject: [PATCH 09/22] Add no sign-up locale variant for "require user" option --- app/views/application/_questionbox.html.haml | 10 +++++++--- config/locales/views.en.yml | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/views/application/_questionbox.html.haml b/app/views/application/_questionbox.html.haml index 447c123c..a5a9089b 100644 --- a/app/views/application/_questionbox.html.haml +++ b/app/views/application/_questionbox.html.haml @@ -19,9 +19,13 @@ %strong= t(".status.locked") - elsif !user_signed_in? && user.privacy_require_user? .text-center - %strong= t(".status.require_user_html", - sign_in: link_to(t("voc.login"), new_user_session_path), - sign_up: link_to(t("voc.register"), new_user_registration_path)) + - if Retrospring::Config.registrations_enabled? + %strong= t(".status.require_user_html", + sign_in: link_to(t("voc.login"), new_user_session_path), + sign_up: link_to(t("voc.register"), new_user_registration_path)) + - else + %strong= t(".status.require_user_no_registration_html", + sign_in: link_to(t("voc.login"), new_user_session_path)) - else - if user_signed_in? || user.privacy_allow_anonymous_questions? #question-box{ diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index c938bf06..ecdf11aa 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -143,6 +143,9 @@ en: require_user_html: | This user requires others to be logged in to ask questions.
(%{sign_in} or %{sign_up}) + require_user_no_registration_html: | + This user requires others to be logged in to ask questions.
+ (%{sign_in}) non_anonymous_html: | This user does not want to receive anonymous questions.
(%{sign_in} or %{sign_up}) From 629a9e5326d3e668f11dec00e6562d9d6e1c1efe Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 10 Aug 2024 02:08:37 +0200 Subject: [PATCH 10/22] Removing fetching of `HOSTNAME` env variable --- lib/retrospring/config.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/retrospring/config.rb b/lib/retrospring/config.rb index a4c7fbd4..3138e762 100644 --- a/lib/retrospring/config.rb +++ b/lib/retrospring/config.rb @@ -13,8 +13,6 @@ module Retrospring env_config = { # The site name, shown everywhere site_name: ENV.fetch("SITE_NAME", nil), - - hostname: ENV.fetch("HOSTNAME", nil), }.compact hash.merge!(env_config) From 66a19989575cf58cdd63860f004c8218b360ce52 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 10 Aug 2024 03:01:40 +0200 Subject: [PATCH 11/22] Make site tagline configurable --- app/views/about/index.html.haml | 2 +- config/justask.yml.example | 3 +++ config/locales/views.en.yml | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/about/index.html.haml b/app/views/about/index.html.haml index 93e9a195..65536828 100644 --- a/app/views/about/index.html.haml +++ b/app/views/about/index.html.haml @@ -4,7 +4,7 @@ .card-body.py-4 = render "layouts/messages" %h1= APP_CONFIG["site_name"] - %p= t(".subtitle") + %p= APP_CONFIG["site_tagline"] - if Retrospring::Config.registrations_enabled? %p %a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_registration_path) } diff --git a/config/justask.yml.example b/config/justask.yml.example index f27c3089..86f00197 100644 --- a/config/justask.yml.example +++ b/config/justask.yml.example @@ -1,6 +1,9 @@ # The site name, shown everywhere. site_name: "justask" +# The sites tagline, shown on the start page +site_tagline: "Ask questions, give answers and learn more about your friends." + # Use the SVG logo from `/public/logo.svg` use_svg_logo: false diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index ecdf11aa..cb144620 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -2,7 +2,6 @@ en: language: "English" about: index: - subtitle: "Ask questions, give answers and learn more about your friends." register: "Register now" already_member: "Already a member?" more_features: "But wait, there's more!" From 7c475b5ff38dbde353366f3af9562d81640a738e Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 11 Aug 2024 04:52:21 +0200 Subject: [PATCH 12/22] Add advanced frontpage layout config option --- app/controllers/about_controller.rb | 6 +- app/views/about/index.html.haml | 119 ++++++----------------- app/views/about/index_advanced.html.haml | 95 ++++++++++++++++++ config/justask.yml.example | 3 + config/locales/views.en.yml | 3 +- config/locales/voc.en.yml | 1 + lib/retrospring/config.rb | 2 + 7 files changed, 136 insertions(+), 93 deletions(-) create mode 100644 app/views/about/index_advanced.html.haml diff --git a/app/controllers/about_controller.rb b/app/controllers/about_controller.rb index 0b20d1b2..45cd7669 100644 --- a/app/controllers/about_controller.rb +++ b/app/controllers/about_controller.rb @@ -1,7 +1,11 @@ # frozen_string_literal: true class AboutController < ApplicationController - def index; end + def index + if Retrospring::Config.advanced_frontpage_enabled? + render template: "about/index_advanced" + end + end def about @users = Rails.cache.fetch("about_count_users", expires_in: 1.hour) { user_count - current_ban_count } diff --git a/app/views/about/index.html.haml b/app/views/about/index.html.haml index 65536828..7925968e 100644 --- a/app/views/about/index.html.haml +++ b/app/views/about/index.html.haml @@ -1,95 +1,32 @@ -- provide(:title, APP_CONFIG["site_name"]) .container - .card.bg-primary.my-3.text-bg-primary.text-center - .card-body.py-4 - = render "layouts/messages" - %h1= APP_CONFIG["site_name"] - %p= APP_CONFIG["site_tagline"] - - if Retrospring::Config.registrations_enabled? - %p - %a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_registration_path) } - = t(".register") - %small - = t(".already_member") - = link_to t("voc.login"), new_user_session_path - - else - %p - %a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_session_path) } - = t("voc.login") + .py-3.py-sm-5 + .row.d-sm-flex + .col-md-8.align-self-center.text-center.text-md-start + %h1 + - if APP_CONFIG["use_svg_logo"] + .d-inline-block.w-50 + = render inline: Rails.application.config.justask_svg_logo + - else + = APP_CONFIG["site_name"] + - if Rails.env.development? + %span.badge.rounded-pill.bg-warning.text-bg-warning + DEV + %p.lead= APP_CONFIG["site_tagline"] + .col-md-4 + %a.btn.btn-primary.d-grid{ href: url_for(new_user_registration_path) } + = t("voc.register_now") + .d-block.text-center.py-2.text-secondary + = t(".or") + .card + .card-body + = bootstrap_form_for(User.new, as: :user, url: session_path(:user), data: { turbo: false }) do |f| - .row.my-5.my-sm-10 - .col-sm-6.order-5.order-sm-1.text-center.text-sm-right - %h2.mb-4= t(".questions.header") - = t(".questions.body_html", app_name: APP_CONFIG["site_name"]) - .col-sm-6.order-1.order-sm-5 - .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 - %i.fa.fa-envelope.align-self-center.mb-5.mb-sm-0 + = f.text_field :login, autofocus: true, autocomplete: :username + = f.password_field :password, autocomplete: "current-password" - .row.my-5.my-sm-10 - .col-sm-6 - .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 - %i.fa.fa-comments.align-self-center.mb-5.mb-sm-0 - .col-sm-6.text-center.text-sm-left - %h2.mb-4= t(".discussions.header") - = t(".discussions.body_html", app_name: APP_CONFIG["site_name"]) + - if Devise.mappings[:user].rememberable? + = f.check_box :remember_me - .row.my-5.my-sm-10 - .col-sm-6.order-5.order-sm-1.text-center.text-sm-right - %h2.mb-4= t(".share.header") - = t(".share.body_html", app_name: APP_CONFIG["site_name"]) - .col-sm-6.order-1.order-sm-5 - .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 - %i.fa.fa-share.align-self-center.mb-5.mb-sm-0 - - .row.my-5.my-sm-10 - .col-sm-6 - .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 - %i.fa.fa-paint-brush.align-self-center.mb-5.mb-sm-0 - .col-sm-6.text-center.text-sm-left - %h2.mb-4= t(".customize.header") - = t(".customize.body_html", app_name: APP_CONFIG["site_name"]) - .card - .card-body - .row.mx-n2 - .col.px-2 - .d-grid - %button.btn.btn-success.js-theme-button{ data: { theme: "theme-success" } }= t(".customize.themes.green") - .col.px-2 - .d-grid - %button.btn.btn-warning.js-theme-button{ data: { theme: "theme-warning" } }= t(".customize.themes.orange") - .col.px-2 - .d-grid - %button.btn.btn-danger.js-theme-button{ data: { theme: "theme-danger" } }= t(".customize.themes.red") - .col.px-2 - .d-grid - %button.btn.btn-default.js-theme-button{ data: { theme: "reset" } }= t(".customize.themes.reset") - -.container.text-center - %h2.mb-4= t(".more_features") - .row.my-5 - .col-sm-4 - %h3.mb-3 - %i.fa.fa-fw.fa-globe.text-primary - = t(".open_source.header") - %p= t(".open_source.body", app_name: APP_CONFIG["site_name"]) - .col-sm-4 - %h3.mb-3 - %i.fa.fa-fw.fa-eye-slash.text-primary - = t(".no_ads.header") - %p= t(".no_ads.body") - .col-sm-4 - %h3.mb-3 - %i.fa.fa-fw.fa-user-secret.text-primary - = t(".your_data.header") - %p= t(".your_data.body", app_name: APP_CONFIG["site_name"]) - - - if APP_CONFIG.dig(:features, :registration, :enabled) - .card - .card-body - %h2= t(".prompt.header") - %p= t(".prompt.body") - %p - %a.btn.btn-primary.btn-lg{ href: url_for(new_user_registration_path) } - = t(".register") - -= render "shared/links" + = f.primary t("voc.login"), class: "btn btn-primary d-grid w-100" + + = render "shared/links" diff --git a/app/views/about/index_advanced.html.haml b/app/views/about/index_advanced.html.haml new file mode 100644 index 00000000..b8a6b852 --- /dev/null +++ b/app/views/about/index_advanced.html.haml @@ -0,0 +1,95 @@ +- provide(:title, APP_CONFIG["site_name"]) +.container + .card.bg-primary.my-3.text-bg-primary.text-center + .card-body.py-4 + = render "layouts/messages" + %h1= APP_CONFIG["site_name"] + %p= APP_CONFIG["site_tagline"] + - if Retrospring::Config.registrations_enabled? + %p + %a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_registration_path) } + = t("voc.register_now") + %small + = t(".already_member") + = link_to t("voc.login"), new_user_session_path + - else + %p + %a.btn.btn-outline-light.btn-lg{ href: url_for(new_user_session_path) } + = t("voc.login") + + .row.my-5.my-sm-10 + .col-sm-6.order-5.order-sm-1.text-center.text-sm-right + %h2.mb-4= t(".questions.header") + = t(".questions.body_html", app_name: APP_CONFIG["site_name"]) + .col-sm-6.order-1.order-sm-5 + .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 + %i.fa.fa-envelope.align-self-center.mb-5.mb-sm-0 + + .row.my-5.my-sm-10 + .col-sm-6 + .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 + %i.fa.fa-comments.align-self-center.mb-5.mb-sm-0 + .col-sm-6.text-center.text-sm-left + %h2.mb-4= t(".discussions.header") + = t(".discussions.body_html", app_name: APP_CONFIG["site_name"]) + + .row.my-5.my-sm-10 + .col-sm-6.order-5.order-sm-1.text-center.text-sm-right + %h2.mb-4= t(".share.header") + = t(".share.body_html", app_name: APP_CONFIG["site_name"]) + .col-sm-6.order-1.order-sm-5 + .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 + %i.fa.fa-share.align-self-center.mb-5.mb-sm-0 + + .row.my-5.my-sm-10 + .col-sm-6 + .text-center.text-primary.d-flex.h-100.justify-content-center.fs-10 + %i.fa.fa-paint-brush.align-self-center.mb-5.mb-sm-0 + .col-sm-6.text-center.text-sm-left + %h2.mb-4= t(".customize.header") + = t(".customize.body_html", app_name: APP_CONFIG["site_name"]) + .card + .card-body + .row.mx-n2 + .col.px-2 + .d-grid + %button.btn.btn-success.js-theme-button{ data: { theme: "theme-success" } }= t(".customize.themes.green") + .col.px-2 + .d-grid + %button.btn.btn-warning.js-theme-button{ data: { theme: "theme-warning" } }= t(".customize.themes.orange") + .col.px-2 + .d-grid + %button.btn.btn-danger.js-theme-button{ data: { theme: "theme-danger" } }= t(".customize.themes.red") + .col.px-2 + .d-grid + %button.btn.btn-default.js-theme-button{ data: { theme: "reset" } }= t(".customize.themes.reset") + +.container.text-center + %h2.mb-4= t(".more_features") + .row.my-5 + .col-sm-4 + %h3.mb-3 + %i.fa.fa-fw.fa-globe.text-primary + = t(".open_source.header") + %p= t(".open_source.body", app_name: APP_CONFIG["site_name"]) + .col-sm-4 + %h3.mb-3 + %i.fa.fa-fw.fa-eye-slash.text-primary + = t(".no_ads.header") + %p= t(".no_ads.body") + .col-sm-4 + %h3.mb-3 + %i.fa.fa-fw.fa-user-secret.text-primary + = t(".your_data.header") + %p= t(".your_data.body", app_name: APP_CONFIG["site_name"]) + + - if APP_CONFIG.dig(:features, :registration, :enabled) + .card + .card-body + %h2= t(".prompt.header") + %p= t(".prompt.body") + %p + %a.btn.btn-primary.btn-lg{ href: url_for(new_user_registration_path) } + = t(".register") + += render "shared/links" diff --git a/config/justask.yml.example b/config/justask.yml.example index 86f00197..f6c4fa80 100644 --- a/config/justask.yml.example +++ b/config/justask.yml.example @@ -58,6 +58,9 @@ features: # Registrations registration: enabled: true + # Advanced (marketing) frontpage layout + advanced_frontpage: + enabled: false # Redis redis_url: "redis://localhost:6379" diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index cb144620..27044c0b 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -2,7 +2,8 @@ en: language: "English" about: index: - register: "Register now" + or: "or" + index_advanced: already_member: "Already a member?" more_features: "But wait, there's more!" questions: diff --git a/config/locales/voc.en.yml b/config/locales/voc.en.yml index 0603cf05..54af769e 100644 --- a/config/locales/voc.en.yml +++ b/config/locales/voc.en.yml @@ -24,6 +24,7 @@ en: subscribe: "Subscribe" unsubscribe: "Unsubscribe" register: "Sign up" + register_now: "Register now" remove: "Remove" report: "Report" terms: "Terms of Service" diff --git a/lib/retrospring/config.rb b/lib/retrospring/config.rb index 3138e762..9ed9dd74 100644 --- a/lib/retrospring/config.rb +++ b/lib/retrospring/config.rb @@ -23,5 +23,7 @@ module Retrospring end def registrations_enabled? = APP_CONFIG.dig(:features, :registration, :enabled) + + def advanced_frontpage_enabled? = APP_CONFIG.dig(:features, :advanced_frontpage, :enabled) end end From 8ad12c33a8a46a17e76696da687b0da43078bfde Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 11 Aug 2024 05:02:03 +0200 Subject: [PATCH 13/22] Fix lint nits --- app/controllers/about_controller.rb | 6 +++--- app/views/about/index.html.haml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/about_controller.rb b/app/controllers/about_controller.rb index 45cd7669..06b59b9d 100644 --- a/app/controllers/about_controller.rb +++ b/app/controllers/about_controller.rb @@ -2,9 +2,9 @@ class AboutController < ApplicationController def index - if Retrospring::Config.advanced_frontpage_enabled? - render template: "about/index_advanced" - end + return unless Retrospring::Config.advanced_frontpage_enabled? + + render template: "about/index_advanced" end def about diff --git a/app/views/about/index.html.haml b/app/views/about/index.html.haml index 7925968e..5ddf24c1 100644 --- a/app/views/about/index.html.haml +++ b/app/views/about/index.html.haml @@ -28,5 +28,5 @@ = f.check_box :remember_me = f.primary t("voc.login"), class: "btn btn-primary d-grid w-100" - + = render "shared/links" From 8180fe683c2ab11d076df307a05ff43ff5f2de2e Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 11 Aug 2024 05:12:26 +0200 Subject: [PATCH 14/22] Rename about/index view spec --- ...index.html.haml_spec.rb => index_advanced.html.haml_spec.rb} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename spec/views/about/{index.html.haml_spec.rb => index_advanced.html.haml_spec.rb} (93%) diff --git a/spec/views/about/index.html.haml_spec.rb b/spec/views/about/index_advanced.html.haml_spec.rb similarity index 93% rename from spec/views/about/index.html.haml_spec.rb rename to spec/views/about/index_advanced.html.haml_spec.rb index 0551a9c8..000e028d 100644 --- a/spec/views/about/index.html.haml_spec.rb +++ b/spec/views/about/index_advanced.html.haml_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -describe "about/index.html.haml", type: :view do +describe "about/index_advanced.html.haml", type: :view do before do stub_const("APP_CONFIG", { "hostname" => "example.com", From a07c5b962a9f6c609d72ce1a05c4a59ce57c9d2d Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 11 Aug 2024 05:17:49 +0200 Subject: [PATCH 15/22] Hide register button in simple layout when registrations are disabled --- app/views/about/index.html.haml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/views/about/index.html.haml b/app/views/about/index.html.haml index 5ddf24c1..9af47130 100644 --- a/app/views/about/index.html.haml +++ b/app/views/about/index.html.haml @@ -13,10 +13,11 @@ DEV %p.lead= APP_CONFIG["site_tagline"] .col-md-4 - %a.btn.btn-primary.d-grid{ href: url_for(new_user_registration_path) } - = t("voc.register_now") - .d-block.text-center.py-2.text-secondary - = t(".or") + - if Retrospring::Config.registrations_enabled? + %a.btn.btn-primary.d-grid{ href: url_for(new_user_registration_path) } + = t("voc.register_now") + .d-block.text-center.py-2.text-secondary + = t(".or") .card .card-body = bootstrap_form_for(User.new, as: :user, url: session_path(:user), data: { turbo: false }) do |f| From 63ca38ccbcce7e28e6d654ac193f3ef9a76f89d0 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 11 Aug 2024 05:25:07 +0200 Subject: [PATCH 16/22] Add specs for correct template in about controller --- spec/controllers/about_controller_spec.rb | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/controllers/about_controller_spec.rb b/spec/controllers/about_controller_spec.rb index f9fecf7b..79a30785 100644 --- a/spec/controllers/about_controller_spec.rb +++ b/spec/controllers/about_controller_spec.rb @@ -3,6 +3,32 @@ require "rails_helper" describe AboutController, type: :controller do + describe "#index" do + subject { get :index } + + context "advanced layout is enabled" do + before do + allow(APP_CONFIG).to receive(:dig).with(:features, :advanced_frontpage, :enabled).and_return(true) + end + + it "renders the correct template" do + subject + expect(response).to render_template("about/index_advanced") + end + end + + context "advanced layout is disabled" do + before do + allow(APP_CONFIG).to receive(:dig).with(:features, :advanced_frontpage, :enabled).and_return(false) + end + + it "renders the correct template" do + subject + expect(response).to render_template("about/index") + end + end + end + describe "#about" do subject { get :about } From 854a5062442198fd3c8e4ef0324b234d145849b4 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 11 Aug 2024 23:26:55 +0200 Subject: [PATCH 17/22] Bump version to 2024.0811.0 --- lib/retrospring/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/retrospring/version.rb b/lib/retrospring/version.rb index 950dca6a..d076fd35 100644 --- a/lib/retrospring/version.rb +++ b/lib/retrospring/version.rb @@ -17,7 +17,7 @@ module Retrospring def month = 8 - def day = 6 + def day = 11 def patch = 0 From 9be01a2a2d39cd253f3272950e719a858d377041 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Mon, 12 Aug 2024 00:02:53 +0200 Subject: [PATCH 18/22] Fix missing question mark in registrations_enabled? method call --- app/views/application/_questionbox.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/application/_questionbox.html.haml b/app/views/application/_questionbox.html.haml index a5a9089b..394f07f9 100644 --- a/app/views/application/_questionbox.html.haml +++ b/app/views/application/_questionbox.html.haml @@ -51,7 +51,7 @@ type: :button, data: { loading_text: t(".load"), - promote: user_signed_in? || !user_signed_in? && !Retrospring::Config.registrations_enabled ? "false" : "true", + promote: user_signed_in? || !user_signed_in? && !Retrospring::Config.registrations_enabled? ? "false" : "true", "character-count-target": "action" } } From 931f88c47e4a33137a3ff07e29d08074cb7ab3d0 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Mon, 12 Aug 2024 00:10:28 +0200 Subject: [PATCH 19/22] Bump version to 2024.0811.1 --- lib/retrospring/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/retrospring/version.rb b/lib/retrospring/version.rb index d076fd35..accff044 100644 --- a/lib/retrospring/version.rb +++ b/lib/retrospring/version.rb @@ -19,7 +19,7 @@ module Retrospring def day = 11 - def patch = 0 + def patch = 1 def suffix = "" From 7b273a5958aed23b11bf8d838a8e4347795dfdf6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 09:16:17 +0000 Subject: [PATCH 20/22] Bump shoulda-matchers from 6.2.0 to 6.3.0 Bumps [shoulda-matchers](https://github.com/thoughtbot/shoulda-matchers) from 6.2.0 to 6.3.0. - [Release notes](https://github.com/thoughtbot/shoulda-matchers/releases) - [Changelog](https://github.com/thoughtbot/shoulda-matchers/blob/main/CHANGELOG.md) - [Commits](https://github.com/thoughtbot/shoulda-matchers/compare/v6.2.0...v6.3.0) --- updated-dependencies: - dependency-name: shoulda-matchers dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 5abd3f8b..c0db91a5 100644 --- a/Gemfile +++ b/Gemfile @@ -96,7 +96,7 @@ group :development, :test do gem "rspec-sidekiq", "~> 5.0", require: false gem "rubocop", "~> 1.65" gem "rubocop-rails", "~> 2.25" - gem "shoulda-matchers", "~> 6.2" + gem "shoulda-matchers", "~> 6.3" gem "simplecov", require: false gem "simplecov-cobertura", require: false gem "simplecov-json", require: false diff --git a/Gemfile.lock b/Gemfile.lock index eb6e03f0..accfff90 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -115,7 +115,7 @@ GEM childprocess (5.0.0) chunky_png (1.4.0) colorize (1.1.0) - concurrent-ruby (1.3.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crass (1.0.6) cssbundling-rails (1.4.1) @@ -458,7 +458,7 @@ GEM sentry-sidekiq (5.18.2) sentry-ruby (~> 5.18.2) sidekiq (>= 3.0) - shoulda-matchers (6.2.0) + shoulda-matchers (6.3.0) activesupport (>= 5.2.0) sidekiq (6.5.12) connection_pool (>= 2.2.5, < 3) @@ -602,7 +602,7 @@ DEPENDENCIES sentry-rails sentry-ruby sentry-sidekiq - shoulda-matchers (~> 6.2) + shoulda-matchers (~> 6.3) sidekiq (< 7) sidekiq-scheduler simplecov From 0217beb28336f0c039810acda065b9db971f1ca1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 09:16:31 +0000 Subject: [PATCH 21/22] Bump bootsnap from 1.18.3 to 1.18.4 Bumps [bootsnap](https://github.com/Shopify/bootsnap) from 1.18.3 to 1.18.4. - [Changelog](https://github.com/Shopify/bootsnap/blob/main/CHANGELOG.md) - [Commits](https://github.com/Shopify/bootsnap/compare/v1.18.3...v1.18.4) --- updated-dependencies: - dependency-name: bootsnap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index eb6e03f0..1fde29c0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -93,7 +93,7 @@ GEM bigdecimal (3.1.8) binding_of_caller (1.0.1) debug_inspector (>= 1.2.0) - bootsnap (1.18.3) + bootsnap (1.18.4) msgpack (~> 1.2) bootstrap_form (5.3.2) actionpack (>= 6.1) From 843a3013525d97e82d1e3ad4e6b179b9495e8bda Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 09:16:48 +0000 Subject: [PATCH 22/22] Bump oj from 3.16.4 to 3.16.5 Bumps [oj](https://github.com/ohler55/oj) from 3.16.4 to 3.16.5. - [Release notes](https://github.com/ohler55/oj/releases) - [Changelog](https://github.com/ohler55/oj/blob/develop/CHANGELOG.md) - [Commits](https://github.com/ohler55/oj/compare/v3.16.4...v3.16.5) --- updated-dependencies: - dependency-name: oj dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index eb6e03f0..eadae39d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -295,10 +295,12 @@ GEM nokogiri (1.16.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) - oj (3.16.4) + oj (3.16.5) bigdecimal (>= 3.0) + ostruct (>= 0.2) openssl (3.2.0) orm_adapter (0.5.0) + ostruct (0.6.0) parallel (1.25.1) parser (3.3.4.0) ast (~> 2.4.1)