From 822466c6c6737fef2fe8124e4cdd98126d42f76d Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Tue, 14 May 2024 19:42:59 +0300 Subject: [PATCH] Add warnings when creating notes anonymously --- app/views/notes/new.html.erb | 5 +++++ config/locales/en.yml | 3 +++ test/controllers/notes_controller_test.rb | 10 ++++++++++ 3 files changed, 18 insertions(+) diff --git a/app/views/notes/new.html.erb b/app/views/notes/new.html.erb index ee9837056..6728b32ff 100644 --- a/app/views/notes/new.html.erb +++ b/app/views/notes/new.html.erb @@ -4,6 +4,11 @@

<%= t(".intro") %>

+ <% if !current_user %> +

<%= t ".anonymous_warning_html", + :log_in => link_to(t(".anonymous_warning_log_in"), login_path(:referer => new_note_path)), + :sign_up => link_to(t(".anonymous_warning_sign_up"), user_new_path) %>

+ <% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 45c44765d..774be22d4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3081,6 +3081,9 @@ en: new: title: "New Note" intro: "Spotted a mistake or something missing? Let other mappers know so we can fix it. Move the marker to the correct position and type a note to explain the problem." + anonymous_warning_html: "You are not logged in. Please %{log_in} or %{sign_up} if you want to receive updates for your note." + anonymous_warning_log_in: "log in" + anonymous_warning_sign_up: "sign up" advice: "Your note is public and may be used to update the map, so don't enter personal information, or information from copyrighted maps or directory listings." add: Add Note javascripts: diff --git a/test/controllers/notes_controller_test.rb b/test/controllers/notes_controller_test.rb index 5ecece0f4..a54334269 100644 --- a/test/controllers/notes_controller_test.rb +++ b/test/controllers/notes_controller_test.rb @@ -160,9 +160,19 @@ class NotesControllerTest < ActionDispatch::IntegrationTest assert_select "div.details", /Resolved by deleted/ end + def test_new_note_anonymous + get new_note_path + assert_response :success + assert_template "notes/new" + assert_select "#sidebar_content a[href='#{login_path(:referer => new_note_path)}']", :count => 1 + end + def test_new_note + session_for(create(:user)) + get new_note_path assert_response :success assert_template "notes/new" + assert_select "#sidebar_content a[href='#{login_path(:referer => new_note_path)}']", :count => 0 end end -- 2.39.5