Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/pull/5459'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Jan 7, 2025
2 parents 3c5e89e + 13994ca commit c20160d
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 62 deletions.
2 changes: 1 addition & 1 deletion app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<% else %>
<div class="d-inline-flex btn-group login-menu" role="">
<%= link_to t("layouts.log_in"), login_path(:referer => request.fullpath), :class => "geolink btn btn-outline-secondary" %>
<%= link_to t("layouts.sign_up"), user_new_path, :class => "btn btn-outline-secondary" %>
<%= link_to t("layouts.sign_up"), new_user_path, :class => "btn btn-outline-secondary" %>
</div>
<% end %>
</nav>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/map.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</p>
<div class="d-flex gap-2">
<a class="btn btn-primary w-100 d-flex align-items-center justify-content-center" href="<%= about_path %>"><%= t("layouts.learn_more") %></a>
<a class="btn btn-primary w-100 d-flex align-items-center justify-content-center" href="<%= user_new_path %>"><%= t("layouts.start_mapping") %></a>
<a class="btn btn-primary w-100 d-flex align-items-center justify-content-center" href="<%= new_user_path %>"><%= t("layouts.start_mapping") %></a>
</div>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/notes/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<% if !current_user %>
<p class="alert alert-warning"><%= 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) %></p>
:sign_up => link_to(t(".anonymous_warning_sign_up"), new_user_path) %></p>
<% end %>
<p class="alert alert-warning" id="new-note-zoom-warning" hidden><%= t "javascripts.site.createnote_disabled_tooltip" %></p>
<form action="#">
Expand Down
2 changes: 1 addition & 1 deletion app/views/site/fixthemap.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<h3 class='fs-5'><%= t ".how_to_help.join_the_community.title" %></h3>
<p><%= t ".how_to_help.join_the_community.explanation_html" %></p>
<p class='text-center'>
<a class="btn btn-primary" href="<%= user_new_path %>"><%= t("layouts.start_mapping") %></a>
<a class="btn btn-primary" href="<%= new_user_path %>"><%= t("layouts.start_mapping") %></a>
</p>
</div>
<div class='col-sm'>
Expand Down
4 changes: 1 addition & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@
get "/key" => "site#key"
get "/id" => "site#id"
get "/query" => "browse#query"
get "/user/new" => "users#new"
post "/user/new" => "users#create"
get "/user/terms" => "users#terms"
post "/user/save" => "users#save"
post "/user/:display_name/confirm/resend" => "confirmations#confirm_resend", :as => :user_confirm_resend
Expand Down Expand Up @@ -269,7 +267,7 @@
post "/diary_comments/:comment/unhide" => "diary_comments#unhide", :comment => /\d+/, :as => :unhide_diary_comment

# user pages
resources :users, :path => "user", :param => :display_name, :only => [:show, :destroy] do
resources :users, :path => "user", :param => :display_name, :only => [:new, :create, :show, :destroy] do
resource :role, :controller => "user_roles", :path => "roles/:role", :only => [:create, :destroy]
scope :module => :users do
resource :issued_blocks, :path => "blocks_by", :only => :show
Expand Down
26 changes: 13 additions & 13 deletions test/controllers/confirmations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_routes

def test_confirm_get
user = build(:user, :pending)
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)

get user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
Expand All @@ -48,7 +48,7 @@ def test_confirm_get
def test_confirm_get_already_confirmed
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)

# Get the confirmation page
Expand All @@ -68,7 +68,7 @@ def test_confirm_get_already_confirmed
def test_confirm_success_no_token_no_referer
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)

post logout_path
Expand All @@ -81,7 +81,7 @@ def test_confirm_success_no_token_no_referer
def test_confirm_success_good_token_no_referer
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)

post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
Expand All @@ -91,7 +91,7 @@ def test_confirm_success_good_token_no_referer
def test_confirm_success_bad_token_no_referer
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)

post logout_path
Expand All @@ -105,7 +105,7 @@ def test_confirm_success_bad_token_no_referer
def test_confirm_success_no_token_with_referer
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)

post logout_path
Expand All @@ -118,7 +118,7 @@ def test_confirm_success_no_token_with_referer
def test_confirm_success_good_token_with_referer
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)

post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string, :referer => new_diary_entry_path }
Expand All @@ -128,7 +128,7 @@ def test_confirm_success_good_token_with_referer
def test_confirm_success_bad_token_with_referer
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)

post logout_path
Expand All @@ -142,7 +142,7 @@ def test_confirm_success_bad_token_with_referer
def test_confirm_expired_token
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)

travel 2.weeks do
Expand All @@ -155,7 +155,7 @@ def test_confirm_expired_token
def test_confirm_already_confirmed
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)

post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string, :referer => new_diary_entry_path }
Expand All @@ -172,7 +172,7 @@ def test_confirm_already_confirmed
def test_confirm_deleted
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)

User.find_by(:display_name => user.display_name).hide!
Expand All @@ -189,7 +189,7 @@ def test_confirm_deleted

def test_confirm_resend_success
user = build(:user, :pending)
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }

assert_difference "ActionMailer::Base.deliveries.size", 1 do
perform_enqueued_jobs do
Expand All @@ -210,7 +210,7 @@ def test_confirm_resend_success

def test_confirm_resend_deleted
user = build(:user, :pending)
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }

User.find_by(:display_name => user.display_name).hide!

Expand Down
46 changes: 23 additions & 23 deletions test/controllers/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_routes
)

assert_routing(
{ :path => "/user/new", :method => :post },
{ :path => "/user", :method => :post },
{ :controller => "users", :action => "create" }
)

Expand Down Expand Up @@ -50,11 +50,11 @@ def test_routes
end

# The user creation page loads
def test_new_view
get user_new_path
assert_redirected_to user_new_path(:cookie_test => "true")
def test_new
get new_user_path
assert_redirected_to new_user_path(:cookie_test => "true")

get user_new_path, :params => { :cookie_test => "true" }
get new_user_path, :params => { :cookie_test => "true" }
assert_response :success

assert_no_match(/img-src \* data:;/, @response.headers["Content-Security-Policy-Report-Only"])
Expand All @@ -65,7 +65,7 @@ def test_new_view
end
assert_select "body", :count => 1 do
assert_select "div#content", :count => 1 do
assert_select "form[action='/user/new'][method='post']", :count => 1 do
assert_select "form[action='/user'][method='post']", :count => 1 do
assert_select "input[id='user_email']", :count => 1
assert_select "input[id='user_display_name']", :count => 1
assert_select "input[id='user_pass_crypt'][type='password']", :count => 1
Expand All @@ -77,23 +77,23 @@ def test_new_view
end
end

def test_new_view_logged_in
def test_new_logged_in
session_for(create(:user))

get user_new_path
get new_user_path
assert_redirected_to root_path

get user_new_path, :params => { :referer => "/test" }
get new_user_path, :params => { :referer => "/test" }
assert_redirected_to "/test"
end

def test_new_success
def test_create_success
user = build(:user, :pending)

assert_difference "User.count", 1 do
assert_difference "ActionMailer::Base.deliveries.size", 1 do
perform_enqueued_jobs do
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
end
end
end
Expand All @@ -110,14 +110,14 @@ def test_new_success
ActionMailer::Base.deliveries.clear
end

def test_new_duplicate_email
def test_create_duplicate_email
user = build(:user, :pending)
create(:user, :email => user.email)

assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
end
end
end
Expand All @@ -127,14 +127,14 @@ def test_new_duplicate_email
assert_select "form > div > input.is-invalid#user_email"
end

def test_new_duplicate_email_uppercase
def test_create_duplicate_email_uppercase
user = build(:user, :pending)
create(:user, :email => user.email.upcase)

assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
end
end
end
Expand All @@ -144,14 +144,14 @@ def test_new_duplicate_email_uppercase
assert_select "form > div > input.is-invalid#user_email"
end

def test_new_duplicate_name
def test_create_duplicate_name
user = build(:user, :pending)
create(:user, :display_name => user.display_name)

assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
end
end
end
Expand All @@ -161,14 +161,14 @@ def test_new_duplicate_name
assert_select "form > div > input.is-invalid#user_display_name"
end

def test_new_duplicate_name_uppercase
def test_create_duplicate_name_uppercase
user = build(:user, :pending)
create(:user, :display_name => user.display_name.upcase)

assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
end
end
end
Expand All @@ -178,7 +178,7 @@ def test_new_duplicate_name_uppercase
assert_select "form > div > input.is-invalid#user_display_name"
end

def test_new_blocked_domain
def test_create_blocked_domain
user = build(:user, :pending, :email => "user@example.net")

# Now block that domain
Expand All @@ -188,7 +188,7 @@ def test_new_blocked_domain
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_new_path, :params => { :user => user.attributes }
post users_path, :params => { :user => user.attributes }
end
end
end
Expand All @@ -197,12 +197,12 @@ def test_new_blocked_domain
assert_template "blocked"
end

def test_save_referer_params
def test_create_referer_params
user = build(:user, :pending)

assert_difference "User.count", 1 do
assert_difference "ActionMailer::Base.deliveries.size", 1 do
post user_new_path, :params => { :user => user.attributes, :referer => "/edit?editor=id#map=1/2/3" }
post users_path, :params => { :user => user.attributes, :referer => "/edit?editor=id#map=1/2/3" }
assert_enqueued_with :job => ActionMailer::MailDeliveryJob,
:args => proc { |args| args[3][:args][2] == welcome_path(:editor => "id", :zoom => 1, :lat => 2, :lon => 3) }
perform_enqueued_jobs
Expand Down
Loading

0 comments on commit c20160d

Please sign in to comment.