From: Tom Hughes Date: Fri, 23 Aug 2024 17:01:27 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/pull/5111' X-Git-Tag: live~333 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/dd1c07f609e4ebfb5398e84a007264c4ee8cf66d?hp=52324cba89a3f4d211535119a20f967593813c09 Merge remote-tracking branch 'upstream/pull/5111' --- diff --git a/app/views/dashboards/show.html.erb b/app/views/dashboards/show.html.erb index a65597fef..c4b595e9b 100644 --- a/app/views/dashboards/show.html.erb +++ b/app/views/dashboards/show.html.erb @@ -27,7 +27,7 @@
-

<%= t ".my friends" %>

+

<%= t ".my friends" %>

<% if friends.empty? %> <%= t ".no friends" %> @@ -38,14 +38,14 @@
  • <%= link_to t(".friends_diaries"), friends_diary_entries_path %>
  • -
    +
    <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %>
    <% end %>
    -

    <%= t ".nearby users" %>

    +

    <%= t ".nearby users" %>

    <% if nearby.empty? %> <%= t ".no nearby users" %> diff --git a/test/controllers/dashboards_controller_test.rb b/test/controllers/dashboards_controller_test.rb index 84f9610e5..0adf58a9e 100644 --- a/test/controllers/dashboards_controller_test.rb +++ b/test/controllers/dashboards_controller_test.rb @@ -9,28 +9,4 @@ class DashboardsControllerTest < ActionDispatch::IntegrationTest { :controller => "dashboards", :action => "show" } ) end - - def test_show_no_friends - user = create(:user) - session_for(user) - - get dashboard_path - end - - def test_show_with_friends - user = create(:user, :home_lon => 1.1, :home_lat => 1.1) - friend_user = create(:user, :home_lon => 1.2, :home_lat => 1.2) - create(:friendship, :befriender => user, :befriendee => friend_user) - create(:changeset, :user => friend_user) - session_for(user) - - get dashboard_path - - # Friends should be visible as we're now logged in - assert_select "div#friends-container" do - assert_select "div" do - assert_select "a[href='/user/#{ERB::Util.u(friend_user.display_name)}']", :count => 1 - end - end - end end diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index cff52cff2..4f4edf10b 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -325,9 +325,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0 end - # Friends shouldn't be visible as we're not logged in - assert_select "div#friends-container", :count => 0 - # Test a user who has been blocked blocked_user = create(:user) create(:user_block, :user => blocked_user) diff --git a/test/system/dashboard_test.rb b/test/system/dashboard_test.rb new file mode 100644 index 000000000..bc2e3b4e9 --- /dev/null +++ b/test/system/dashboard_test.rb @@ -0,0 +1,27 @@ +require "application_system_test_case" + +class DashboardSystemTest < ApplicationSystemTestCase + test "show no users if have no friends" do + user = create(:user) + sign_in_as(user) + + visit dashboard_path + assert_text "You have not added any friends yet." + end + + test "show users if have friends" do + user = create(:user, :home_lon => 1.1, :home_lat => 1.1) + friend_user = create(:user, :home_lon => 1.2, :home_lat => 1.2) + create(:friendship, :befriender => user, :befriendee => friend_user) + create(:changeset, :user => friend_user) + sign_in_as(user) + + visit dashboard_path + assert_no_text "You have not added any friends yet." + + friends_heading = find :element, "h2", :text => "My friends" + others_heading = find :element, "h2", :text => "Other nearby users" + + assert_link friend_user.display_name, :below => friends_heading, :above => others_heading + end +end