]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5440'
authorTom Hughes <tom@compton.nu>
Mon, 30 Dec 2024 12:40:11 +0000 (12:40 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 30 Dec 2024 12:40:11 +0000 (12:40 +0000)
30 files changed:
app/assets/javascripts/diary_entry.js
app/controllers/api/messages_controller.rb
app/controllers/messages/inboxes_controller.rb [new file with mode: 0644]
app/controllers/messages/mailboxes_controller.rb [new file with mode: 0644]
app/controllers/messages/muted_inboxes_controller.rb [new file with mode: 0644]
app/controllers/messages/outboxes_controller.rb [new file with mode: 0644]
app/controllers/messages_controller.rb
app/controllers/users_controller.rb
app/views/confirmations/confirm.html.erb
app/views/layouts/_header.html.erb
app/views/messages/inboxes/show.html.erb [moved from app/views/messages/inbox.html.erb with 52% similarity]
app/views/messages/mailboxes/_heading.html.erb [moved from app/views/messages/_heading.html.erb with 60% similarity]
app/views/messages/mailboxes/_message.html.erb [moved from app/views/messages/_message_summary.html.erb with 100% similarity]
app/views/messages/mailboxes/_messages_table.html.erb [moved from app/views/messages/_messages_table.html.erb with 75% similarity]
app/views/messages/muted_inboxes/show.html.erb [moved from app/views/messages/muted.html.erb with 82% similarity]
app/views/messages/new.html.erb
app/views/messages/outboxes/_message.html.erb [moved from app/views/messages/_sent_message_summary.html.erb with 100% similarity]
app/views/messages/outboxes/show.html.erb [moved from app/views/messages/outbox.html.erb with 87% similarity]
config/locales/en.yml
config/routes.rb
test/application_system_test_case.rb
test/controllers/confirmations_controller_test.rb
test/controllers/messages/inboxes_controller_test.rb [new file with mode: 0644]
test/controllers/messages/muted_inboxes_controller_test.rb [new file with mode: 0644]
test/controllers/messages/outboxes_controller_test.rb [new file with mode: 0644]
test/controllers/messages_controller_test.rb
test/system/confirmation_resend_test.rb [deleted file]
test/system/messages_test.rb
test/system/user_signup_test.rb
vendor/assets/leaflet/leaflet.osm.js

index 625d43a5228f0b07a391f988a43cae3327364e67..bd5fd4dd62f359ecd0b163e555c87bd6420bd0f3 100644 (file)
@@ -2,8 +2,10 @@ $(document).ready(function () {
   var marker, map;
 
   function setLocation(e) {
-    $("#latitude").val(e.latlng.lat);
-    $("#longitude").val(e.latlng.lng);
+    const latlng = e.latlng.wrap();
+
+    $("#latitude").val(latlng.lat);
+    $("#longitude").val(latlng.lng);
 
     if (marker) {
       map.removeLayer(marker);
index cbbd8539cc76e7333437615341a8a2f9b45ba06f..ea5abe8dfc57a2afcab4638ae390dcd61163af15 100644 (file)
@@ -5,7 +5,6 @@ module Api
     before_action :authorize
 
     before_action :check_api_writable, :only => [:create, :update, :destroy]
-    before_action :check_api_readable, :except => [:create, :update, :destroy]
 
     authorize_resource
 
diff --git a/app/controllers/messages/inboxes_controller.rb b/app/controllers/messages/inboxes_controller.rb
new file mode 100644 (file)
index 0000000..96ec27c
--- /dev/null
@@ -0,0 +1,8 @@
+module Messages
+  class InboxesController < MailboxesController
+    # Display the list of messages that have been sent to the user.
+    def show
+      @title = t ".title"
+    end
+  end
+end
diff --git a/app/controllers/messages/mailboxes_controller.rb b/app/controllers/messages/mailboxes_controller.rb
new file mode 100644 (file)
index 0000000..a0da9f5
--- /dev/null
@@ -0,0 +1,12 @@
+module Messages
+  class MailboxesController < ApplicationController
+    layout "site"
+
+    before_action :authorize_web
+    before_action :set_locale
+
+    authorize_resource :class => Message
+
+    before_action :check_database_readable
+  end
+end
diff --git a/app/controllers/messages/muted_inboxes_controller.rb b/app/controllers/messages/muted_inboxes_controller.rb
new file mode 100644 (file)
index 0000000..2d025cc
--- /dev/null
@@ -0,0 +1,10 @@
+module Messages
+  class MutedInboxesController < MailboxesController
+    # Display the list of muted messages received by the user.
+    def show
+      @title = t ".title"
+
+      redirect_to messages_inbox_path if current_user.muted_messages.none?
+    end
+  end
+end
diff --git a/app/controllers/messages/outboxes_controller.rb b/app/controllers/messages/outboxes_controller.rb
new file mode 100644 (file)
index 0000000..f4d0a50
--- /dev/null
@@ -0,0 +1,8 @@
+module Messages
+  class OutboxesController < MailboxesController
+    # Display the list of messages that the user has sent to other users.
+    def show
+      @title = t ".title"
+    end
+  end
+end
index 7d86796b1ff18f0a62303851cf2457238817e987..7162b900a011c4719c18a212f96691d3e68e26b8 100644 (file)
@@ -49,7 +49,7 @@ class MessagesController < ApplicationController
     elsif @message.save
       flash[:notice] = t ".message_sent"
       UserMailer.message_notification(@message).deliver_later if @message.notify_recipient?
-      redirect_to :action => :inbox
+      redirect_to messages_inbox_path
     else
       @title = t "messages.new.title"
       render :action => "new"
@@ -66,7 +66,7 @@ class MessagesController < ApplicationController
 
       referer = safe_referer(params[:referer]) if params[:referer]
 
-      redirect_to referer || { :action => :inbox }, :status => :see_other
+      redirect_to referer || messages_inbox_path, :status => :see_other
     end
   rescue ActiveRecord::RecordNotFound
     @title = t "messages.no_such_message.title"
@@ -108,23 +108,6 @@ class MessagesController < ApplicationController
     render :action => "no_such_message", :status => :not_found
   end
 
-  # Display the list of messages that have been sent to the user.
-  def inbox
-    @title = t ".title"
-  end
-
-  # Display the list of messages that the user has sent to other users.
-  def outbox
-    @title = t ".title"
-  end
-
-  # Display the list of muted messages received by the user.
-  def muted
-    @title = t ".title"
-
-    redirect_to inbox_messages_path if current_user.muted_messages.none?
-  end
-
   # Set the message as being read or unread.
   def mark
     @message = current_user.messages.unscope(:where => :muted).find(params[:message_id])
@@ -139,9 +122,9 @@ class MessagesController < ApplicationController
     if @message.save
       flash[:notice] = notice
       if @message.muted?
-        redirect_to muted_messages_path, :status => :see_other
+        redirect_to messages_muted_inbox_path, :status => :see_other
       else
-        redirect_to inbox_messages_path, :status => :see_other
+        redirect_to messages_inbox_path, :status => :see_other
       end
     end
   rescue ActiveRecord::RecordNotFound
@@ -160,9 +143,9 @@ class MessagesController < ApplicationController
     end
 
     if current_user.muted_messages.none?
-      redirect_to inbox_messages_path
+      redirect_to messages_inbox_path
     else
-      redirect_to muted_messages_path
+      redirect_to messages_muted_inbox_path
     end
   end
 
index 471215c92234f8535cd459dad4b44e52b5f929f4..fa311ab39e0d302a241f0023c4b89795828641c5 100644 (file)
@@ -77,7 +77,24 @@ class UsersController < ApplicationController
         render :action => "new"
       else
         # Save the user record
-        save_new_user params[:email_hmac], params[:referer]
+        if save_new_user params[:email_hmac]
+          SIGNUP_IP_LIMITER&.update(request.remote_ip)
+          SIGNUP_EMAIL_LIMITER&.update(canonical_email(current_user.email))
+
+          flash[:matomo_goal] = Settings.matomo["goals"]["signup"] if defined?(Settings.matomo)
+
+          referer = welcome_path(welcome_options(params[:referer]))
+
+          if current_user.status == "active"
+            successful_login(current_user, referer)
+          else
+            session[:pending_user] = current_user.id
+            UserMailer.signup_confirm(current_user, current_user.generate_token_for(:new_user), referer).deliver_later
+            redirect_to :controller => :confirmations, :action => :confirm, :display_name => current_user.display_name
+          end
+        else
+          render :action => "new", :referer => params[:referer]
+        end
       end
     end
   end
@@ -238,7 +255,7 @@ class UsersController < ApplicationController
 
   private
 
-  def save_new_user(email_hmac, referer = nil)
+  def save_new_user(email_hmac)
     current_user.data_public = true
     current_user.description = "" if current_user.description.nil?
     current_user.creation_address = request.remote_ip
@@ -254,24 +271,7 @@ class UsersController < ApplicationController
       current_user.activate
     end
 
-    if current_user.save
-      SIGNUP_IP_LIMITER&.update(request.remote_ip)
-      SIGNUP_EMAIL_LIMITER&.update(canonical_email(current_user.email))
-
-      flash[:matomo_goal] = Settings.matomo["goals"]["signup"] if defined?(Settings.matomo)
-
-      referer = welcome_path(welcome_options(referer))
-
-      if current_user.status == "active"
-        successful_login(current_user, referer)
-      else
-        session[:pending_user] = current_user.id
-        UserMailer.signup_confirm(current_user, current_user.generate_token_for(:new_user), referer).deliver_later
-        redirect_to :controller => :confirmations, :action => :confirm, :display_name => current_user.display_name
-      end
-    else
-      render :action => "new", :referer => params[:referer]
-    end
+    current_user.save
   end
 
   def welcome_options(referer = nil)
index 4f98a85399a206d93f0be0dca30d3a9d49676e40..08dea27b633e7b14a823d80fa26db567aa4e0356 100644 (file)
@@ -28,7 +28,9 @@
   </h1>
 
   <p class='text-body-secondary'>
-    <%= t ".resend_html",
-          :reconfirm_link => link_to(t(".click_here"), url_for(:action => "confirm_resend")) %>
+    <%= t ".if_need_resend" %>
   </p>
+  <%= bootstrap_form_tag :url => url_for(:action => "confirm_resend") do |f| %>
+    <%= f.submit t(".resend_button"), :class => "btn btn-outline-primary" %>
+  <% end %>
 <% end %>
index 190ea44e5654b53b63af24f070ad8b0130609f9a..322b738ec45f2fc61897f022e3a4b441ac019cb0 100644 (file)
@@ -96,7 +96,7 @@
         </button>
         <div class='dropdown-menu dropdown-menu-end'>
           <%= link_to t("users.show.my_dashboard"), dashboard_path, :class => "dropdown-item" %>
-          <%= link_to inbox_messages_path, :class => "dropdown-item" do %>
+          <%= link_to messages_inbox_path, :class => "dropdown-item" do %>
             <%= t("users.show.my messages") %>
             <span class='badge count-number'><%= number_with_delimiter(current_user.new_messages.size) %></span>
           <% end %>
similarity index 52%
rename from app/views/messages/inbox.html.erb
rename to app/views/messages/inboxes/show.html.erb
index 835d70a74cd8ee1f7d4c4af4c0ddf381b156f89b..4e74dbe1fc1152f8410f15ad23eb5b6cfb712791 100644 (file)
@@ -2,12 +2,12 @@
   <%= javascript_include_tag "messages" %>
 <% end %>
 
-<%= render :partial => "heading", :locals => { :active_link_path => inbox_messages_path } %>
+<%= render :partial => "heading", :locals => { :active_link_path => messages_inbox_path } %>
 
-<h4><%= t "messages.inbox.messages", :new_messages => t(".new_messages", :count => current_user.new_messages.size), :old_messages => t(".old_messages", :count => current_user.messages.size - current_user.new_messages.size) %></h4>
+<h4><%= t ".messages", :new_messages => t(".new_messages", :count => current_user.new_messages.size), :old_messages => t(".old_messages", :count => current_user.messages.size - current_user.new_messages.size) %></h4>
 
 <% if current_user.messages.size > 0 %>
-  <%= render :partial => "messages_table", :locals => { :columns => %w[from subject date], :messages => current_user.messages, :inner_partial => "message_summary" } %>
+  <%= render :partial => "messages_table", :locals => { :columns => %w[from subject date], :messages => current_user.messages } %>
 <% else %>
   <div><%= t(".no_messages_yet_html", :people_mapping_nearby_link => link_to(t(".people_mapping_nearby"), dashboard_path)) %></div>
 <% end %>
similarity index 60%
rename from app/views/messages/_heading.html.erb
rename to app/views/messages/mailboxes/_heading.html.erb
index c3b4792021c211040e04ae95d7d5d50b72d7c9a2..ff69f0a386047ff6672e7c8dd570ccde76750e66 100644 (file)
@@ -3,8 +3,8 @@
 <% content_for :heading do %>
   <h1><%= t("users.show.my messages") %></h1>
   <ul class="nav nav-tabs">
-    <% { t(".my_inbox") => inbox_messages_path, t(".my_outbox") => outbox_messages_path, t(".muted_messages") => muted_messages_path }.each do |label, path| %>
-    <% next if path == muted_messages_path && current_user.muted_messages.none? %>
+    <% { t(".my_inbox") => messages_inbox_path, t(".my_outbox") => messages_outbox_path, t(".muted_messages") => messages_muted_inbox_path }.each do |label, path| %>
+    <% next if path == messages_muted_inbox_path && current_user.muted_messages.none? %>
 
     <li class="nav-item">
       <% if path == active_link_path %>
similarity index 75%
rename from app/views/messages/_messages_table.html.erb
rename to app/views/messages/mailboxes/_messages_table.html.erb
index 567b5e8283ab4b5a60a62071f75cfa3216050dce..f9c00c71427dfff2950e740b9968d9192fd14d88 100644 (file)
@@ -8,6 +8,6 @@
     </tr>
   </thead>
   <tbody>
-    <%= render :partial => inner_partial, :collection => messages, :as => "message" %>
+    <%= render :partial => "message", :collection => messages %>
   </tbody>
 </table>
similarity index 82%
rename from app/views/messages/muted.html.erb
rename to app/views/messages/muted_inboxes/show.html.erb
index 40c74e915762cb918a76233ff6faec6943528cdd..b94e80115d901be7c82d93179b51c502d8f41641 100644 (file)
@@ -2,8 +2,8 @@
   <%= javascript_include_tag "messages" %>
 <% end %>
 
-<%= render :partial => "heading", :locals => { :active_link_path => muted_messages_path } %>
+<%= render :partial => "heading", :locals => { :active_link_path => messages_muted_inbox_path } %>
 
 <h4><%= t ".messages", :count => current_user.muted_messages.size %></h4>
 
-<%= render :partial => "messages_table", :locals => { :columns => %w[from subject date], :messages => current_user.muted_messages, :inner_partial => "message_summary" } %>
+<%= render :partial => "messages_table", :locals => { :columns => %w[from subject date], :messages => current_user.muted_messages } %>
index 2838a5dab1c93ca9ba866e9451f049e0e7ca5eab..fb1bc48e7148c9ee6e1e7e74b319d7e5b507d51b 100644 (file)
@@ -8,5 +8,5 @@
   <%= f.richtext_field :body, :cols => 80, :rows => 20 %>
 
   <%= f.primary %>
-  <%= link_to t(".back_to_inbox"), inbox_messages_path, :class => "btn btn-link" %>
+  <%= link_to t(".back_to_inbox"), messages_inbox_path, :class => "btn btn-link" %>
 <% end %>
similarity index 87%
rename from app/views/messages/outbox.html.erb
rename to app/views/messages/outboxes/show.html.erb
index 5cb357f6fa19c899e88eb4970ca7caeb0844816e..c82ee585e41eb78065f9522c5db2338cf6844088 100644 (file)
@@ -2,12 +2,12 @@
   <%= javascript_include_tag "messages" %>
 <% end %>
 
-<%= render :partial => "heading", :locals => { :active_link_path => outbox_messages_path } %>
+<%= render :partial => "heading", :locals => { :active_link_path => messages_outbox_path } %>
 
 <h4><%= t ".messages", :count => current_user.sent_messages.size %></h4>
 
 <% if current_user.sent_messages.size > 0 %>
-  <%= render :partial => "messages_table", :locals => { :columns => %w[to subject date], :messages => current_user.sent_messages, :inner_partial => "sent_message_summary" } %>
+  <%= render :partial => "messages_table", :locals => { :columns => %w[to subject date], :messages => current_user.sent_messages } %>
 <% else %>
   <div class="messages"><%= t(".no_sent_messages_html", :people_mapping_nearby_link => link_to(t(".people_mapping_nearby"), dashboard_path)) %></div>
 <% end %>
index 6504f58561f85f75116374776200b7642059c8d0..4f2174206548e2f5267daf6ad4c39a896c9e710d 100644 (file)
@@ -1726,8 +1726,8 @@ en:
       success: "Confirmed your account, thanks for signing up!"
       already active: "This account has already been confirmed."
       unknown token: "That confirmation code has expired or does not exist."
-      resend_html: "If you need us to resend the confirmation email, %{reconfirm_link}."
-      click_here: click here
+      if_need_resend: "If you need us to resend the confirmation email, click the button below."
+      resend_button: Resend the confirmation email
     confirm_resend:
       failure: "User %{name} not found."
     confirm_email:
@@ -1741,28 +1741,6 @@ en:
       confirmation_sent: We've sent a new confirmation note to %{email} and as soon as you confirm your account you'll be able to get mapping.
       whitelist: If you use an antispam system which sends confirmation requests then please make sure you whitelist %{sender} as we are unable to reply to any confirmation requests.
   messages:
-    inbox:
-      title: "Inbox"
-      messages: "You have %{new_messages} and %{old_messages}"
-      new_messages:
-        one: "%{count} new message"
-        other: "%{count} new messages"
-      old_messages:
-        one: "%{count} old message"
-        other: "%{count} old messages"
-      no_messages_yet_html: "You have no messages yet. Why not get in touch with some of the %{people_mapping_nearby_link}?"
-      people_mapping_nearby: "people mapping nearby"
-    messages_table:
-      from: "From"
-      to: "To"
-      subject: "Subject"
-      date: "Date"
-      actions: "Actions"
-    message_summary:
-      unread_button: "Mark as unread"
-      read_button: "Mark as read"
-      destroy_button: "Delete"
-      unmute_button: "Move to Inbox"
     new:
       title: "Send message"
       send_message_to_html: "Send a new message to %{name}"
@@ -1774,18 +1752,6 @@ en:
       title: "No such message"
       heading: "No such message"
       body: "Sorry there is no message with that id."
-    outbox:
-      title: "Outbox"
-      messages:
-        one: "You have %{count} sent message"
-        other: "You have %{count} sent messages"
-      no_sent_messages_html: "You have no sent messages yet. Why not get in touch with some of the %{people_mapping_nearby_link}?"
-      people_mapping_nearby: "people mapping nearby"
-    muted:
-      title: "Muted Messages"
-      messages:
-        one: "%{count} muted message"
-        other: "You have %{count} muted messages"
     reply:
       wrong_user: "You are logged in as '%{user}' but the message you have asked to reply to was not sent to that user. Please log in as the correct user in order to reply."
     show:
@@ -1795,12 +1761,6 @@ en:
       destroy_button: "Delete"
       back: "Back"
       wrong_user: "You are logged in as '%{user}' but the message you have asked to read was not sent by or to that user. Please log in as the correct user in order to read it."
-    sent_message_summary:
-      destroy_button: "Delete"
-    heading:
-      my_inbox: "My Inbox"
-      my_outbox: "My Outbox"
-      muted_messages: "Muted messages"
     mark:
       as_read: "Message marked as read"
       as_unread: "Message marked as unread"
@@ -1809,6 +1769,50 @@ en:
       error: "The message could not be moved to the Inbox."
     destroy:
       destroyed: "Message deleted"
+    mailboxes:
+      heading:
+        my_inbox: "My Inbox"
+        my_outbox: "My Outbox"
+        muted_messages: "Muted messages"
+      messages_table:
+        from: "From"
+        to: "To"
+        subject: "Subject"
+        date: "Date"
+        actions: "Actions"
+      message:
+        unread_button: "Mark as unread"
+        read_button: "Mark as read"
+        destroy_button: "Delete"
+        unmute_button: "Move to Inbox"
+    inboxes:
+      show:
+        title: "Inbox"
+        messages: "You have %{new_messages} and %{old_messages}"
+        new_messages:
+          one: "%{count} new message"
+          other: "%{count} new messages"
+        old_messages:
+          one: "%{count} old message"
+          other: "%{count} old messages"
+        no_messages_yet_html: "You have no messages yet. Why not get in touch with some of the %{people_mapping_nearby_link}?"
+        people_mapping_nearby: "people mapping nearby"
+    muted_inboxes:
+      show:
+        title: "Muted Messages"
+        messages:
+          one: "%{count} muted message"
+          other: "You have %{count} muted messages"
+    outboxes:
+      show:
+        title: "Outbox"
+        messages:
+          one: "You have %{count} sent message"
+          other: "You have %{count} sent messages"
+        no_sent_messages_html: "You have no sent messages yet. Why not get in touch with some of the %{people_mapping_nearby_link}?"
+        people_mapping_nearby: "people mapping nearby"
+      message:
+        destroy_button: "Delete"
   passwords:
     new:
       title: "Lost password"
index e6a1aacda82090a3713f88a3e403f38f8d35ae3d..3ede0d33d521385a64210802b54fd8023cbd4c28 100644 (file)
@@ -186,7 +186,7 @@ OpenStreetMap::Application.routes.draw do
   post "/user/new" => "users#create"
   get "/user/terms" => "users#terms"
   post "/user/save" => "users#save"
-  get "/user/:display_name/confirm/resend" => "confirmations#confirm_resend", :as => :user_confirm_resend
+  post "/user/:display_name/confirm/resend" => "confirmations#confirm_resend", :as => :user_confirm_resend
   match "/user/:display_name/confirm" => "confirmations#confirm", :via => [:get, :post]
   match "/user/confirm" => "confirmations#confirm", :via => [:get, :post]
   match "/user/confirm-email" => "confirmations#confirm_email", :via => [:get, :post]
@@ -311,16 +311,16 @@ OpenStreetMap::Application.routes.draw do
   get "/export/embed" => "export#embed"
 
   # messages
-  resources :messages, :only => [:create, :show, :destroy] do
+  resources :messages, :id => /\d+/, :only => [:create, :show, :destroy] do
     post :mark
     patch :unmute
 
     match :reply, :via => [:get, :post]
-    collection do
-      get :inbox
-      get :muted
-      get :outbox
-    end
+  end
+  namespace :messages, :path => "/messages" do
+    resource :inbox, :only => :show
+    resource :muted_inbox, :path => "muted", :only => :show
+    resource :outbox, :only => :show
   end
   get "/user/:display_name/inbox", :to => redirect(:path => "/messages/inbox")
   get "/user/:display_name/outbox", :to => redirect(:path => "/messages/outbox")
index d2c3d5196ab9b5ccbcae32aaaed086e03650d7f5..0ddb8a87ad73f91606df90af224df851c9919c06 100644 (file)
@@ -41,4 +41,8 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
   def within_sidebar(&)
     within("#sidebar_content", &)
   end
+
+  def within_content_body(&)
+    within("#content > .content-body", &)
+  end
 end
index 79213441f19a2e8cf757429e91ab2205b0020e12..c8926eb7552485d59e2da95241f24c9a0318b515 100644 (file)
@@ -13,7 +13,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
       { :controller => "confirmations", :action => "confirm", :display_name => "username" }
     )
     assert_routing(
-      { :path => "/user/username/confirm/resend", :method => :get },
+      { :path => "/user/username/confirm/resend", :method => :post },
       { :controller => "confirmations", :action => "confirm_resend", :display_name => "username" }
     )
 
@@ -193,7 +193,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
 
     assert_difference "ActionMailer::Base.deliveries.size", 1 do
       perform_enqueued_jobs do
-        get user_confirm_resend_path(user)
+        post user_confirm_resend_path(user)
       end
     end
 
@@ -216,7 +216,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
 
     assert_no_difference "ActionMailer::Base.deliveries.size" do
       perform_enqueued_jobs do
-        get user_confirm_resend_path(user)
+        post user_confirm_resend_path(user)
       end
     end
 
@@ -227,7 +227,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
   def test_confirm_resend_unknown_user
     assert_no_difference "ActionMailer::Base.deliveries.size" do
       perform_enqueued_jobs do
-        get user_confirm_resend_path(:display_name => "No Such User")
+        post user_confirm_resend_path(:display_name => "No Such User")
       end
     end
 
diff --git a/test/controllers/messages/inboxes_controller_test.rb b/test/controllers/messages/inboxes_controller_test.rb
new file mode 100644 (file)
index 0000000..b5cc869
--- /dev/null
@@ -0,0 +1,36 @@
+require "test_helper"
+
+module Messages
+  class InboxesControllerTest < ActionDispatch::IntegrationTest
+    ##
+    # test all routes which lead to this controller
+    def test_routes
+      assert_routing(
+        { :path => "/messages/inbox", :method => :get },
+        { :controller => "messages/inboxes", :action => "show" }
+      )
+    end
+
+    def test_show
+      user = create(:user)
+      read_message = create(:message, :read, :recipient => user)
+
+      session_for(user)
+
+      get messages_inbox_path
+      assert_response :success
+      assert_select ".content-inner > table.messages-table > tbody", :count => 1 do
+        assert_select "tr", :count => 1
+        assert_select "tr#inbox-#{read_message.id}", :count => 1 do
+          assert_select "a[href='#{user_path read_message.sender}']", :text => read_message.sender.display_name
+          assert_select "a[href='#{message_path read_message}']", :text => read_message.title
+        end
+      end
+    end
+
+    def test_show_requires_login
+      get messages_inbox_path
+      assert_redirected_to login_path(:referer => messages_inbox_path)
+    end
+  end
+end
diff --git a/test/controllers/messages/muted_inboxes_controller_test.rb b/test/controllers/messages/muted_inboxes_controller_test.rb
new file mode 100644 (file)
index 0000000..ce84b65
--- /dev/null
@@ -0,0 +1,14 @@
+require "test_helper"
+
+module Messages
+  class MutedInboxesControllerTest < ActionDispatch::IntegrationTest
+    ##
+    # test all routes which lead to this controller
+    def test_routes
+      assert_routing(
+        { :path => "/messages/muted", :method => :get },
+        { :controller => "messages/muted_inboxes", :action => "show" }
+      )
+    end
+  end
+end
diff --git a/test/controllers/messages/outboxes_controller_test.rb b/test/controllers/messages/outboxes_controller_test.rb
new file mode 100644 (file)
index 0000000..befb810
--- /dev/null
@@ -0,0 +1,36 @@
+require "test_helper"
+
+module Messages
+  class OutboxesControllerTest < ActionDispatch::IntegrationTest
+    ##
+    # test all routes which lead to this controller
+    def test_routes
+      assert_routing(
+        { :path => "/messages/outbox", :method => :get },
+        { :controller => "messages/outboxes", :action => "show" }
+      )
+    end
+
+    def test_show
+      user = create(:user)
+      message = create(:message, :sender => user)
+
+      session_for(user)
+
+      get messages_outbox_path
+      assert_response :success
+      assert_select ".content-inner > table.messages-table > tbody", :count => 1 do
+        assert_select "tr", :count => 1
+        assert_select "tr#outbox-#{message.id}", :count => 1 do
+          assert_select "a[href='#{user_path message.recipient}']", :text => message.recipient.display_name
+          assert_select "a[href='#{message_path message}']", :text => message.title
+        end
+      end
+    end
+
+    def test_show_requires_login
+      get messages_outbox_path
+      assert_redirected_to login_path(:referer => messages_outbox_path)
+    end
+  end
+end
index 70d1beb18317b362d3dfd137023b406003646ac7..ac7ca9a0614273b68f0d30321eedc3a1aaf2c081 100644 (file)
@@ -4,14 +4,6 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest
   ##
   # test all routes which lead to this controller
   def test_routes
-    assert_routing(
-      { :path => "/messages/inbox", :method => :get },
-      { :controller => "messages", :action => "inbox" }
-    )
-    assert_routing(
-      { :path => "/messages/outbox", :method => :get },
-      { :controller => "messages", :action => "outbox" }
-    )
     assert_routing(
       { :path => "/message/new/username", :method => :get },
       { :controller => "messages", :action => "new", :display_name => "username" }
@@ -179,7 +171,7 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest
         end
       end
     end
-    assert_redirected_to inbox_messages_path
+    assert_redirected_to messages_inbox_path
     assert_equal "Message sent", flash[:notice]
     e = ActionMailer::Base.deliveries.first
     assert_equal [recipient_user.email], e.to
@@ -332,57 +324,6 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest
     assert_template "no_such_message"
   end
 
-  ##
-  # test the inbox action
-  def test_inbox
-    user = create(:user)
-    read_message = create(:message, :read, :recipient => user)
-    # Check that the inbox page requires us to login
-    get inbox_messages_path
-    assert_redirected_to login_path(:referer => inbox_messages_path)
-
-    # Login
-    session_for(user)
-
-    # Check that we can view our inbox when logged in
-    get inbox_messages_path
-    assert_response :success
-    assert_template "inbox"
-    assert_select ".content-inner > table.messages-table > tbody", :count => 1 do
-      assert_select "tr", :count => 1
-      assert_select "tr#inbox-#{read_message.id}", :count => 1 do
-        assert_select "a[href='#{user_path read_message.sender}']", :text => read_message.sender.display_name
-        assert_select "a[href='#{message_path read_message}']", :text => read_message.title
-      end
-    end
-  end
-
-  ##
-  # test the outbox action
-  def test_outbox
-    user = create(:user)
-    message = create(:message, :sender => user)
-
-    # Check that the outbox page requires us to login
-    get outbox_messages_path
-    assert_redirected_to login_path(:referer => outbox_messages_path)
-
-    # Login
-    session_for(user)
-
-    # Check that we can view our outbox when logged in
-    get outbox_messages_path
-    assert_response :success
-    assert_template "outbox"
-    assert_select ".content-inner > table.messages-table > tbody", :count => 1 do
-      assert_select "tr", :count => 1
-      assert_select "tr#outbox-#{message.id}", :count => 1 do
-        assert_select "a[href='#{user_path message.recipient}']", :text => message.recipient.display_name
-        assert_select "a[href='#{message_path message}']", :text => message.title
-      end
-    end
-  end
-
   ##
   # test the mark action
   def test_mark
@@ -416,22 +357,22 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest
 
     # Check that the marking a message read works
     post message_mark_path(message, :mark => "read")
-    assert_redirected_to inbox_messages_path
+    assert_redirected_to messages_inbox_path
     assert Message.find(message.id).message_read
 
     # Check that the marking a message unread works
     post message_mark_path(message, :mark => "unread")
-    assert_redirected_to inbox_messages_path
+    assert_redirected_to messages_inbox_path
     assert_not Message.find(message.id).message_read
 
     # Check that the marking a message read works and redirects to inbox from the message page
     post message_mark_path(message, :mark => "read"), :headers => { :referer => message_path(message) }
-    assert_redirected_to inbox_messages_path
+    assert_redirected_to messages_inbox_path
     assert Message.find(message.id).message_read
 
     # Check that the marking a message unread works and redirects to inbox from the message page
     post message_mark_path(message, :mark => "unread"), :headers => { :referer => message_path(message) }
-    assert_redirected_to inbox_messages_path
+    assert_redirected_to messages_inbox_path
     assert_not Message.find(message.id).message_read
 
     # Asking to mark a message with a bogus ID should fail
@@ -452,12 +393,12 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest
 
     # Check that the marking a message read works
     post message_mark_path(message, :mark => "read")
-    assert_redirected_to muted_messages_path
+    assert_redirected_to messages_muted_inbox_path
     assert Message.find(message.id).message_read
 
     # Check that the marking a message unread works
     post message_mark_path(message, :mark => "unread")
-    assert_redirected_to muted_messages_path
+    assert_redirected_to messages_muted_inbox_path
     assert_not Message.find(message.id).message_read
   end
 
@@ -487,15 +428,15 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest
 
     # Check that the destroy a received message works
     delete message_path(read_message)
-    assert_redirected_to inbox_messages_path
+    assert_redirected_to messages_inbox_path
     assert_equal "Message deleted", flash[:notice]
     m = Message.find(read_message.id)
     assert m.from_user_visible
     assert_not m.to_user_visible
 
     # Check that the destroying a sent message works
-    delete message_path(sent_message, :referer => outbox_messages_path)
-    assert_redirected_to outbox_messages_path
+    delete message_path(sent_message, :referer => messages_outbox_path)
+    assert_redirected_to messages_outbox_path
     assert_equal "Message deleted", flash[:notice]
     m = Message.find(sent_message.id)
     assert_not m.from_user_visible
diff --git a/test/system/confirmation_resend_test.rb b/test/system/confirmation_resend_test.rb
deleted file mode 100644 (file)
index 6ef8581..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-require "application_system_test_case"
-
-class ConfirmationResendSystemTest < ApplicationSystemTestCase
-  def setup
-    @user = build(:user)
-    visit user_new_path
-
-    within ".new_user" do
-      fill_in "Email", :with => @user.email
-      fill_in "Display Name", :with => @user.display_name
-      fill_in "Password", :with => "testtest"
-      fill_in "Confirm Password", :with => "testtest"
-      click_on "Sign Up"
-    end
-  end
-
-  test "flash message should not contain raw html" do
-    visit user_confirm_resend_path(@user)
-
-    assert_content "sent a new confirmation"
-    assert_no_content "<p>"
-  end
-end
index b78568314166ab4e357f16841008a970848290ad..0b828971895ecacdefb4d3e11e508eaa692a7cf7 100644 (file)
@@ -6,7 +6,7 @@ class MessagesTest < ApplicationSystemTestCase
     create(:message, :recipient => user)
     sign_in_as(user)
 
-    visit inbox_messages_path
+    visit messages_inbox_path
     assert_text "You have 1 new message and 0 old messages"
 
     click_on "Delete"
@@ -18,7 +18,7 @@ class MessagesTest < ApplicationSystemTestCase
     create(:message, :sender => user)
     sign_in_as(user)
 
-    visit outbox_messages_path
+    visit messages_outbox_path
     assert_text "You have 1 sent message"
 
     click_on "Delete"
@@ -32,7 +32,7 @@ class MessagesTest < ApplicationSystemTestCase
     create(:message, :sender => muted_user, :recipient => user)
     sign_in_as(user)
 
-    visit muted_messages_path
+    visit messages_muted_inbox_path
     assert_text "1 muted message"
 
     click_on "Delete"
index 0e02b904f7f44a830fa5d2eba043fef1e7c70ba6..2fb90fc3a41acf81873d53ab3d640bc9b34e1771 100644 (file)
 require "application_system_test_case"
 
 class UserSignupTest < ApplicationSystemTestCase
+  include ActionMailer::TestHelper
+
+  def setup
+    stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
+  end
+
+  test "Sign up with confirmation email" do
+    visit root_path
+
+    click_on "Sign Up"
+
+    within_content_body do
+      fill_in "Email", :with => "new_user_account@example.com"
+      fill_in "Display Name", :with => "new_user_account"
+      fill_in "Password", :with => "new_user_password"
+      fill_in "Confirm Password", :with => "new_user_password"
+
+      assert_emails 1 do
+        click_on "Sign Up"
+
+        assert_content "We sent you a confirmation email"
+      end
+    end
+
+    email = ActionMailer::Base.deliveries.first
+    assert_equal 1, email.to.count
+    assert_equal "new_user_account@example.com", email.to.first
+    email_text = email.parts[0].parts[0].decoded
+    match = %r{/user/new_user_account/confirm\?confirm_string=\S+}.match(email_text)
+    assert_not_nil match
+
+    visit match[0]
+
+    assert_content "new_user_account"
+    assert_content "Welcome!"
+  end
+
+  test "Sign up with confirmation email resending" do
+    visit root_path
+
+    click_on "Sign Up"
+
+    within_content_body do
+      fill_in "Email", :with => "new_user_account@example.com"
+      fill_in "Display Name", :with => "new_user_account"
+      fill_in "Password", :with => "new_user_password"
+      fill_in "Confirm Password", :with => "new_user_password"
+
+      assert_emails 2 do
+        click_on "Sign Up"
+
+        assert_content "We sent you a confirmation email"
+
+        click_on "Resend the confirmation email"
+
+        assert_content "Email Address or Username"
+      end
+    end
+
+    assert_content "sent a new confirmation"
+    assert_no_content "<p>"
+
+    email = ActionMailer::Base.deliveries.last
+    assert_equal 1, email.to.count
+    assert_equal "new_user_account@example.com", email.to.first
+    email_text = email.parts[0].parts[0].decoded
+    match = %r{/user/new_user_account/confirm\?confirm_string=\S+}.match(email_text)
+    assert_not_nil match
+
+    visit match[0]
+
+    assert_content "new_user_account"
+    assert_content "Welcome!"
+  end
+
   test "Sign up from login page" do
     visit login_path
 
     click_on "Sign up"
 
-    assert_content "Confirm Password"
+    within_content_body do
+      assert_content "Confirm Password"
+    end
   end
 
   test "Show OpenID form when OpenID provider button is clicked" do
     visit login_path
 
-    assert_no_field "OpenID URL"
-    assert_no_button "Continue"
+    within_content_body do
+      assert_no_field "OpenID URL"
+      assert_no_button "Continue"
 
-    click_on "Log in with OpenID"
+      click_on "Log in with OpenID"
 
-    assert_field "OpenID URL"
-    assert_button "Continue"
+      assert_field "OpenID URL"
+      assert_button "Continue"
+    end
   end
 end
index 0e51f34086a974478e44550921495494ba9f5359..6a8fcde3da68f00a0e047c695bcf6d7d160ced81 100644 (file)
@@ -44,6 +44,14 @@ L.OSM.TransportMap = L.OSM.TileLayer.extend({
   }
 });
 
+L.OSM.TransportDarkMap = L.OSM.TileLayer.extend({
+  options: {
+    url: 'https://{s}.tile.thunderforest.com/transport-dark/{z}/{x}/{y}{r}.png?apikey={apikey}',
+    maxZoom: 21,
+    attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors. Tiles courtesy of <a href="http://www.thunderforest.com/" target="_blank">Andy Allan</a>'
+  }
+});
+
 L.OSM.OPNVKarte = L.OSM.TileLayer.extend({
   options: {
     url: 'https://tileserver.memomaps.de/tilegen/{z}/{x}/{y}.png',
@@ -82,7 +90,8 @@ L.OSM.DataLayer = L.FeatureGroup.extend({
   options: {
     areaTags: ['area', 'building', 'leisure', 'tourism', 'ruins', 'historic', 'landuse', 'military', 'natural', 'sport'],
     uninterestingTags: ['source', 'source_ref', 'source:ref', 'history', 'attribution', 'created_by', 'tiger:county', 'tiger:tlid', 'tiger:upload_uuid'],
-    styles: {}
+    styles: {},
+    asynchronous: false,
   },
 
   initialize: function (xml, options) {
@@ -101,7 +110,7 @@ L.OSM.DataLayer = L.FeatureGroup.extend({
     }
 
     for (var i = 0; i < features.length; i++) {
-      var feature = features[i], layer;
+      let feature = features[i], layer;
 
       if (feature.type === "changeset") {
         layer = L.rectangle(feature.latLngBounds, this.options.styles.changeset);
@@ -122,7 +131,12 @@ L.OSM.DataLayer = L.FeatureGroup.extend({
         }
       }
 
-      layer.addTo(this);
+      if (this.options.asynchronous) {
+        setTimeout(() => layer.addTo(this));
+      } else {
+        layer.addTo(this);
+      }
+
       layer.feature = feature;
     }
   },
@@ -188,7 +202,28 @@ L.OSM.DataLayer = L.FeatureGroup.extend({
     }
 
     return false;
-  }
+  },
+
+  onRemove: function(map) {
+    this.eachLayer(map.removeLayer, map, this.options.asynchronous);
+  },
+
+  onAdd: function(map) {
+    this.eachLayer(map.addLayer, map, this.options.asynchronous);
+  },
+
+  eachLayer: function (method, context, asynchronous = false) {
+    for (let i in this._layers) {
+      if (asynchronous) {
+        setTimeout(() => {
+          method.call(context, this._layers[i]);
+        });
+      } else {
+        method.call(context, this._layers[i]);
+      }
+    }
+    return this;
+  },
 });
 
 L.Util.extend(L.OSM, {