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);
before_action :authorize
before_action :check_api_writable, :only => [:create, :update, :destroy]
- before_action :check_api_readable, :except => [:create, :update, :destroy]
authorize_resource
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
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"
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"
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])
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
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
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
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
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)
</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 %>
</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 %>
<%= 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 %>
<% 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 %>
</tr>
</thead>
<tbody>
- <%= render :partial => inner_partial, :collection => messages, :as => "message" %>
+ <%= render :partial => "message", :collection => messages %>
</tbody>
</table>
<%= 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 } %>
<%= 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 %>
<%= 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 %>
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:
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}"
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:
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"
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"
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]
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")
def within_sidebar(&)
within("#sidebar_content", &)
end
+
+ def within_content_body(&)
+ within("#content > .content-body", &)
+ end
end
{ :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" }
)
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
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
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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
##
# 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" }
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
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
# 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
# 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
# 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
+++ /dev/null
-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
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"
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"
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"
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
}
});
+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',
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) {
}
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);
}
}
- layer.addTo(this);
+ if (this.options.asynchronous) {
+ setTimeout(() => layer.addTo(this));
+ } else {
+ layer.addTo(this);
+ }
+
layer.feature = feature;
}
},
}
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, {