From 0e320362ffdbd54b1917d9ae99ca88f12fe0f8e7 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 6 Aug 2026 18:33:14 +0100 Subject: [PATCH] Restore terms partial removed in 606b5c1b6a3b The partial is used when rendering the terms on their own as part of an XHR request to update the page. --- app/controllers/accounts/terms_controller.rb | 2 +- app/views/accounts/terms/_terms.html.erb | 46 +++++++++++++++++++ app/views/accounts/terms/show.html.erb | 45 +----------------- .../accounts/terms_controller_test.rb | 8 ++++ 4 files changed, 56 insertions(+), 45 deletions(-) create mode 100644 app/views/accounts/terms/_terms.html.erb diff --git a/app/controllers/accounts/terms_controller.rb b/app/controllers/accounts/terms_controller.rb index 957ca8ab1..9043004d3 100644 --- a/app/controllers/accounts/terms_controller.rb +++ b/app/controllers/accounts/terms_controller.rb @@ -21,7 +21,7 @@ module Accounts @text_legale = "GB" unless @legale == "FR" || @legale == "IT" if request.xhr? - render :partial => "terms" + render :partial => "terms", :locals => { :text => @text } else @title = t ".title" end diff --git a/app/views/accounts/terms/_terms.html.erb b/app/views/accounts/terms/_terms.html.erb new file mode 100644 index 000000000..6a31ba5a5 --- /dev/null +++ b/app/views/accounts/terms/_terms.html.erb @@ -0,0 +1,46 @@ +<%# locals: (text:) %> + +

+ <%= text["intro"] %> + <%= text["next_with_decline"] %> +

+

<%= text["introduction"] %>

+
    +
  1. +

    <%= text["section_1"] %>

    + <% unless text['section_1a'].nil? %> +
      +
    1. <%= text["section_1a"] %>
    2. +
    3. <%= text["section_1b"] %>
    4. +
    + <% end %> +
  2. +
+

<%= text["rights_granted"] %>

+
    +
  1. +

    <%= text["section_2"] %>

    +
  2. +
  3. +

    <%= text["section_3"] %>

    +

    <%= text["active_defn_1"] %>

    +

    <%= text["active_defn_2"] %>

    +
  4. +
  5. +

    <%= text["section_4"] %>

    +
  6. +
  7. +

    <%= text["section_5"] %>

    +
  8. +
+

<%= text["limitation_of_liability"] %>

+
    +
  1. <%= text["section_6"] %>

  2. +
  3. <%= text["section_7"] %>

  4. +
+

<%= text["miscellaneous"] %>

+
    +
  1. +

    <%= text["section_8"] %>

    +
  2. +
diff --git a/app/views/accounts/terms/show.html.erb b/app/views/accounts/terms/show.html.erb index e4e96947d..98f940892 100644 --- a/app/views/accounts/terms/show.html.erb +++ b/app/views/accounts/terms/show.html.erb @@ -31,50 +31,7 @@
-

- <%= @text["intro"] %> - <%= @text["next_with_decline"] %> -

-

<%= @text["introduction"] %>

-
    -
  1. -

    <%= @text["section_1"] %>

    - <% unless @text['section_1a'].nil? %> -
      -
    1. <%= @text["section_1a"] %>
    2. -
    3. <%= @text["section_1b"] %>
    4. -
    - <% end %> -
  2. -
-

<%= @text["rights_granted"] %>

-
    -
  1. -

    <%= @text["section_2"] %>

    -
  2. -
  3. -

    <%= @text["section_3"] %>

    -

    <%= @text["active_defn_1"] %>

    -

    <%= @text["active_defn_2"] %>

    -
  4. -
  5. -

    <%= @text["section_4"] %>

    -
  6. -
  7. -

    <%= @text["section_5"] %>

    -
  8. -
-

<%= @text["limitation_of_liability"] %>

-
    -
  1. <%= @text["section_6"] %>

  2. -
  3. <%= @text["section_7"] %>

  4. -
-

<%= @text["miscellaneous"] %>

-
    -
  1. -

    <%= @text["section_8"] %>

    -
  2. -
+ <%= render :partial => "terms", :locals => { :text => @text } %>
diff --git a/test/controllers/accounts/terms_controller_test.rb b/test/controllers/accounts/terms_controller_test.rb index 8b53be8e8..3f8509c9c 100644 --- a/test/controllers/accounts/terms_controller_test.rb +++ b/test/controllers/accounts/terms_controller_test.rb @@ -76,6 +76,14 @@ module Accounts assert_redirected_to :controller => "/errors", :action => :bad_request end + def test_show_xhr + user = create(:user, :terms_seen => true, :terms_agreed => Date.yesterday) + session_for(user) + + get account_terms_path(:legale => "FR"), :xhr => true + assert_response :success + end + def test_update_decline_by_not_checking_the_boxes freeze_time do user = create(:user, :terms_seen => false, :terms_agreed => nil, :tou_agreed => nil) -- 2.47.3