From 2b7a48029bff06c190544f91c5969b09aeae552b Mon Sep 17 00:00:00 2001 From: nertc Date: Tue, 14 Jan 2025 11:32:54 +0400 Subject: [PATCH] Modify the way Friends are added --- app/controllers/diary_entries_controller.rb | 2 +- app/controllers/friendships_controller.rb | 4 +- app/helpers/changesets_helper.rb | 2 +- app/mailers/user_mailer.rb | 2 +- app/views/dashboards/_contact.html.erb | 6 +-- app/views/dashboards/show.html.erb | 10 ++-- .../friendship_notification.html.erb | 4 +- .../friendship_notification.text.erb | 4 +- app/views/users/show.html.erb | 4 +- config/locales/en.yml | 50 +++++++++---------- .../friendships_controller_test.rb | 48 +++++++++--------- ...authorized_applications_controller_test.rb | 2 +- test/system/dashboard_test.rb | 8 +-- test/system/friendships_test.rb | 8 +-- 14 files changed, 77 insertions(+), 77 deletions(-) diff --git a/app/controllers/diary_entries_controller.rb b/app/controllers/diary_entries_controller.rb index 27099cd9c..5f39a0886 100644 --- a/app/controllers/diary_entries_controller.rb +++ b/app/controllers/diary_entries_controller.rb @@ -28,7 +28,7 @@ class DiaryEntriesController < ApplicationController end elsif params[:friends] if current_user - @title = t ".title_friends" + @title = t ".title_followed" entries = DiaryEntry.where(:user => current_user.friends) else require_user diff --git a/app/controllers/friendships_controller.rb b/app/controllers/friendships_controller.rb index 8f0c1ad85..8de438fd2 100644 --- a/app/controllers/friendships_controller.rb +++ b/app/controllers/friendships_controller.rb @@ -18,7 +18,7 @@ class FriendshipsController < ApplicationController friendship.befriender = current_user friendship.befriendee = @friend if current_user.friends_with?(@friend) - flash[:warning] = t ".already_a_friend", :name => @friend.display_name + flash[:warning] = t ".already_followed", :name => @friend.display_name elsif current_user.friendships.where(:created_at => Time.now.utc - 1.hour..).count >= current_user.max_friends_per_hour flash[:error] = t ".limit_exceeded" elsif friendship.save @@ -40,7 +40,7 @@ class FriendshipsController < ApplicationController Friendship.where(:befriender => current_user, :befriendee => @friend).delete_all flash[:notice] = t ".success", :name => @friend.display_name else - flash[:error] = t ".not_a_friend", :name => @friend.display_name + flash[:error] = t ".not_followed", :name => @friend.display_name end referer = safe_referer(params[:referer]) if params[:referer] diff --git a/app/helpers/changesets_helper.rb b/app/helpers/changesets_helper.rb index 4605658f6..d3bc5ed9a 100644 --- a/app/helpers/changesets_helper.rb +++ b/app/helpers/changesets_helper.rb @@ -32,7 +32,7 @@ module ChangesetsHelper def changeset_index_title(params, user) if params[:friends] && user - t "changesets.index.title_friend" + t "changesets.index.title_followed" elsif params[:nearby] && user t "changesets.index.title_nearby" elsif params[:display_name] diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 1dd13fb2d..fc1b10551 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -123,7 +123,7 @@ class UserMailer < ApplicationMailer with_recipient_locale friendship.befriendee do @friendship = friendship @viewurl = user_url(@friendship.befriender) - @friendurl = make_friend_url(@friendship.befriender) + @followurl = follow_url(@friendship.befriender) @author = @friendship.befriender.display_name attach_user_avatar(@friendship.befriender) diff --git a/app/views/dashboards/_contact.html.erb b/app/views/dashboards/_contact.html.erb index 759faab8f..41d0a24f2 100644 --- a/app/views/dashboards/_contact.html.erb +++ b/app/views/dashboards/_contact.html.erb @@ -1,7 +1,7 @@ <% user_data = { :lon => contact.home_lon, :lat => contact.home_lat, - :icon => image_path(type == "friend" ? "marker-blue.png" : "marker-green.png"), + :icon => image_path(type == "following" ? "marker-blue.png" : "marker-green.png"), :description => render(:partial => "popup", :object => contact, :locals => { :type => type }) } %> <%= tag.div :class => "clearfix row", :data => { :user => user_data } do %> @@ -36,9 +36,9 @@
  • <%= link_to t("users.show.send message"), new_message_path(contact) %>
  • <% if current_user.friends_with?(contact) %> - <%= link_to t("users.show.remove as friend"), remove_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %> + <%= link_to t("users.show.unfollow"), remove_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %> <% else %> - <%= link_to t("users.show.add as friend"), make_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %> + <%= link_to t("users.follow"), make_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %> <% end %>
  • diff --git a/app/views/dashboards/show.html.erb b/app/views/dashboards/show.html.erb index c4b595e9b..b1ca90e85 100644 --- a/app/views/dashboards/show.html.erb +++ b/app/views/dashboards/show.html.erb @@ -27,19 +27,19 @@
    -

    <%= t ".my friends" %>

    +

    <%= t ".followings" %>

    <% if friends.empty? %> - <%= t ".no friends" %> + <%= t ".no followings" %> <% else %>
    - <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %> + <%= render :partial => "contact", :collection => friends, :locals => { :type => "following" } %>
    <% end %> diff --git a/app/views/user_mailer/friendship_notification.html.erb b/app/views/user_mailer/friendship_notification.html.erb index 40af762d7..fffad9fa2 100644 --- a/app/views/user_mailer/friendship_notification.html.erb +++ b/app/views/user_mailer/friendship_notification.html.erb @@ -1,11 +1,11 @@

    <%= t ".hi", :to_user => @friendship.befriendee.display_name %>

    -

    <%= t ".had_added_you", :user => @friendship.befriender.display_name %>

    +

    <%= t ".followed_you", :user => @friendship.befriender.display_name %>

    <%= message_body do %>

    <%= t ".see_their_profile_html", :userurl => link_to(@viewurl, @viewurl) %>

    <% unless @friendship.befriendee.friends_with?(@friendship.befriender) -%> -

    <%= t ".befriend_them_html", :befriendurl => link_to(@friendurl, @friendurl) %>

    +

    <%= t ".follow_them_html", :followurl => link_to(@followurl, @followurl) %>

    <% end -%> <% end %> diff --git a/app/views/user_mailer/friendship_notification.text.erb b/app/views/user_mailer/friendship_notification.text.erb index 104b0f1c9..593bc765a 100644 --- a/app/views/user_mailer/friendship_notification.text.erb +++ b/app/views/user_mailer/friendship_notification.text.erb @@ -1,9 +1,9 @@ <%= t ".hi", :to_user => @friendship.befriendee.display_name %> -<%= t '.had_added_you', :user => @friendship.befriender.display_name %> +<%= t '.followed_you', :user => @friendship.befriender.display_name %> <%= t '.see_their_profile', :userurl => @viewurl %> <% unless @friendship.befriendee.friends_with?(@friendship.befriender) -%> -<%= t '.befriend_them', :befriendurl => @friendurl %> +<%= t '.follow_them', :followurl => @followurl %> <% end -%> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index c168972aa..efeac90bc 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -84,9 +84,9 @@ <% if current_user %>
  • <% if current_user.friends_with?(@user) %> - <%= link_to t(".remove as friend"), remove_friend_path(:display_name => @user.display_name), :method => :post %> + <%= link_to t(".unfollow"), remove_friend_path(:display_name => @user.display_name), :method => :post %> <% else %> - <%= link_to t(".add as friend"), make_friend_path(:display_name => @user.display_name), :method => :post %> + <%= link_to t(".follow"), make_friend_path(:display_name => @user.display_name), :method => :post %> <% end %>
  • <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index d1faa7a50..f9fe33041 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -92,7 +92,7 @@ en: support_url: Support URL allow_read_prefs: read their user preferences allow_write_prefs: modify their user preferences - allow_write_diary: create diary entries, comments and make friends + allow_write_diary: create diary entries and comments allow_write_api: modify the map allow_read_gpx: read their private GPS traces allow_write_gpx: upload GPS traces @@ -478,7 +478,7 @@ en: title: "Changesets" title_user: "Changesets by %{user}" title_user_link_html: "Changesets by %{user_link}" - title_friend: "Changesets by my friends" + title_followed: "Changesets by followings" title_nearby: "Changesets by nearby users" empty: "No changesets found." empty_area: "No changesets in this area." @@ -544,17 +544,17 @@ en: popup: your location: "Your location" nearby mapper: "Nearby mapper" - friend: "Friend" + following: "Following" show: title: My Dashboard no_home_location_html: "%{edit_profile_link} and set your home location to see nearby users." edit_your_profile: Edit your profile - my friends: My friends - no friends: You have not added any friends yet. + followings: Followings + no followings: You have not followed any user yet. nearby users: "Other nearby users" no nearby users: "There are no other users who admit to mapping nearby yet." - friends_changesets: "friends' changesets" - friends_diaries: "friends' diary entries" + followed_changesets: "changesets" + followed_diaries: "diary entries" nearby_changesets: "nearby user changesets" nearby_diaries: "nearby user diary entries" diary_entries: @@ -565,7 +565,7 @@ en: use_map_link: Use Map index: title: "Users' Diaries" - title_friends: "Friends' Diaries" + title_followed: "Followings' Diaries" title_nearby: "Nearby Users' Diaries" user_title: "%{user}'s Diary" in_language_title: "Diary Entries in %{language}" @@ -688,17 +688,17 @@ en: description: Couldn't find a file/directory/API operation by that name on the OpenStreetMap server (HTTP 404) friendships: make_friend: - heading: "Add %{user} as a friend?" - button: "Add as friend" - success: "%{name} is now your friend!" - failed: "Sorry, failed to add %{name} as a friend." - already_a_friend: "You are already friends with %{name}." - limit_exceeded: "You have friended a lot of users recently. Please wait a while before trying to friend any more." + heading: "Do you want to follow %{user}?" + button: "Follow User" + success: "You are now following %{name}!" + failed: "Sorry, your request to follow %{name} has failed." + already_followed: "You already follow %{name}." + limit_exceeded: "You have followed a lot of users recently. Please wait a while before trying to follow any more." remove_friend: - heading: "Unfriend %{user}?" - button: "Unfriend" - success: "%{name} was removed from your friends." - not_a_friend: "%{name} is not one of your friends." + heading: "Do you want to unfollow %{user}?" + button: "Unfollow" + success: "You successfully unfollowed %{name}." + not_followed: "You are not following %{name}." geocoder: search: title: @@ -1662,12 +1662,12 @@ en: footer_html: "You can also read the message at %{readurl} and you can send a message to the author at %{replyurl}" friendship_notification: hi: "Hi %{to_user}," - subject: "[OpenStreetMap] %{user} added you as a friend" - had_added_you: "%{user} has added you as a friend on OpenStreetMap." + subject: "[OpenStreetMap] %{user} followed you" + followed_you: "%{user} is now following you on OpenStreetMap." see_their_profile: "You can see their profile at %{userurl}." see_their_profile_html: "You can see their profile at %{userurl}." - befriend_them: "You can also add them as a friend at %{befriendurl}." - befriend_them_html: "You can also add them as a friend at %{befriendurl}." + follow_them: "You can also follow them at %{followurl}." + follow_them_html: "You can also follow them at %{followurl}." gpx_details: details: "Your file details:" filename: Filename @@ -2698,7 +2698,7 @@ en: openid: Sign-in using OpenStreetMap read_prefs: Read user preferences write_prefs: Modify user preferences - write_diary: Create diary entries, comments and make friends + write_diary: Create diary entries and comments write_api: Modify the map read_gpx: Read private GPS traces write_gpx: Upload GPS traces @@ -2818,8 +2818,8 @@ en: edits: Edits traces: Traces notes: Map Notes - remove as friend: Unfriend - add as friend: Add Friend + unfollow: Unfollow + follow: Follow mapper since: "Mapper since:" last map edit: "Last map edit:" no activity yet: "No activity yet" diff --git a/test/controllers/friendships_controller_test.rb b/test/controllers/friendships_controller_test.rb index f63a8e449..5e5cf1344 100644 --- a/test/controllers/friendships_controller_test.rb +++ b/test/controllers/friendships_controller_test.rb @@ -5,24 +5,24 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest # test all routes which lead to this controller def test_routes assert_routing( - { :path => "/user/username/make_friend", :method => :get }, - { :controller => "friendships", :action => "make_friend", :display_name => "username" } + { :path => "/user/username/follow", :method => :get }, + { :controller => "friendships", :action => "follow", :display_name => "username" } ) assert_routing( - { :path => "/user/username/make_friend", :method => :post }, - { :controller => "friendships", :action => "make_friend", :display_name => "username" } + { :path => "/user/username/follow", :method => :post }, + { :controller => "friendships", :action => "follow", :display_name => "username" } ) assert_routing( - { :path => "/user/username/remove_friend", :method => :get }, - { :controller => "friendships", :action => "remove_friend", :display_name => "username" } + { :path => "/user/username/unfollow", :method => :get }, + { :controller => "friendships", :action => "unfollow", :display_name => "username" } ) assert_routing( - { :path => "/user/username/remove_friend", :method => :post }, - { :controller => "friendships", :action => "remove_friend", :display_name => "username" } + { :path => "/user/username/unfollow", :method => :post }, + { :controller => "friendships", :action => "unfollow", :display_name => "username" } ) end - def test_make_friend + def test_follow # Get users to work with user = create(:user) friend = create(:user) @@ -44,7 +44,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest # When logged in a GET should get a confirmation page get make_friend_path(friend) assert_response :success - assert_template :make_friend + assert_template :follow assert_select "form" do assert_select "input[type='hidden'][name='referer']", 0 assert_select "input[type='submit']", 1 @@ -58,7 +58,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest end end assert_redirected_to user_path(friend) - assert_match(/is now your friend/, flash[:notice]) + assert_match(/You are now following/, flash[:notice]) assert Friendship.find_by(:befriender => user, :befriendee => friend) email = ActionMailer::Base.deliveries.first assert_equal 1, email.to.count @@ -72,11 +72,11 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest end end assert_redirected_to user_path(friend) - assert_match(/You are already friends with/, flash[:warning]) + assert_match(/You already follow/, flash[:warning]) assert Friendship.find_by(:befriender => user, :befriendee => friend) end - def test_make_friend_with_referer + def test_follow_with_referer # Get users to work with user = create(:user) friend = create(:user) @@ -88,7 +88,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest # The GET should preserve any referer get make_friend_path(friend), :params => { :referer => "/test" } assert_response :success - assert_template :make_friend + assert_template :follow assert_select "form" do assert_select "input[type='hidden'][name='referer'][value='/test']", 1 assert_select "input[type='submit']", 1 @@ -102,7 +102,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest end end assert_redirected_to "/test" - assert_match(/is now your friend/, flash[:notice]) + assert_match(/You are now following/, flash[:notice]) assert Friendship.find_by(:befriender => user, :befriendee => friend) email = ActionMailer::Base.deliveries.first assert_equal 1, email.to.count @@ -110,7 +110,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest ActionMailer::Base.deliveries.clear end - def test_make_friend_unknown_user + def test_follow_unknown_user # Should error when a bogus user is specified session_for(create(:user)) get make_friend_path("No Such User") @@ -118,7 +118,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest assert_template :no_such_user end - def test_remove_friend + def test_unfollow # Get users to work with user = create(:user) friend = create(:user) @@ -141,7 +141,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest # When logged in a GET should get a confirmation page get remove_friend_path(friend) assert_response :success - assert_template :remove_friend + assert_template :unfollow assert_select "form" do assert_select "input[type='hidden'][name='referer']", 0 assert_select "input[type='submit']", 1 @@ -151,17 +151,17 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest # When logged in a POST should remove the friendship post remove_friend_path(friend) assert_redirected_to user_path(friend) - assert_match(/was removed from your friends/, flash[:notice]) + assert_match(/You successfully unfollowed/, flash[:notice]) assert_nil Friendship.find_by(:befriender => user, :befriendee => friend) # A second POST should report that the friendship does not exist post remove_friend_path(friend) assert_redirected_to user_path(friend) - assert_match(/is not one of your friends/, flash[:error]) + assert_match(/You are not following/, flash[:error]) assert_nil Friendship.find_by(:befriender => user, :befriendee => friend) end - def test_remove_friend_with_referer + def test_unfollow_with_referer # Get users to work with user = create(:user) friend = create(:user) @@ -174,7 +174,7 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest # The GET should preserve any referer get remove_friend_path(friend), :params => { :referer => "/test" } assert_response :success - assert_template :remove_friend + assert_template :unfollow assert_select "form" do assert_select "input[type='hidden'][name='referer'][value='/test']", 1 assert_select "input[type='submit']", 1 @@ -184,11 +184,11 @@ class FriendshipsControllerTest < ActionDispatch::IntegrationTest # When logged in a POST should remove the friendship and refer post remove_friend_path(friend), :params => { :referer => "/test" } assert_redirected_to "/test" - assert_match(/was removed from your friends/, flash[:notice]) + assert_match(/You successfully unfollowed/, flash[:notice]) assert_nil Friendship.find_by(:befriender => user, :befriendee => friend) end - def test_remove_friend_unknown_user + def test_unfollow_unknown_user # Should error when a bogus user is specified session_for(create(:user)) get remove_friend_path("No Such User") diff --git a/test/controllers/oauth2_authorized_applications_controller_test.rb b/test/controllers/oauth2_authorized_applications_controller_test.rb index 3a9088401..584d00ce8 100644 --- a/test/controllers/oauth2_authorized_applications_controller_test.rb +++ b/test/controllers/oauth2_authorized_applications_controller_test.rb @@ -56,7 +56,7 @@ class Oauth2AuthorizedApplicationsControllerTest < ActionDispatch::IntegrationTe assert_select "li", :count => 3 assert_select "li", :text => "Read user preferences" assert_select "li", :text => "Modify user preferences" - assert_select "li", :text => "Create diary entries, comments and make friends" + assert_select "li", :text => "Create diary entries and comments" end end diff --git a/test/system/dashboard_test.rb b/test/system/dashboard_test.rb index bc2e3b4e9..ef1b952dc 100644 --- a/test/system/dashboard_test.rb +++ b/test/system/dashboard_test.rb @@ -1,12 +1,12 @@ require "application_system_test_case" class DashboardSystemTest < ApplicationSystemTestCase - test "show no users if have no friends" do + test "show no users if have no followings" do user = create(:user) sign_in_as(user) visit dashboard_path - assert_text "You have not added any friends yet." + assert_text "You have not followed any user yet." end test "show users if have friends" do @@ -17,9 +17,9 @@ class DashboardSystemTest < ApplicationSystemTestCase sign_in_as(user) visit dashboard_path - assert_no_text "You have not added any friends yet." + assert_no_text "You have not followed any user yet." - friends_heading = find :element, "h2", :text => "My friends" + friends_heading = find :element, "h2", :text => "Followings" others_heading = find :element, "h2", :text => "Other nearby users" assert_link friend_user.display_name, :below => friends_heading, :above => others_heading diff --git a/test/system/friendships_test.rb b/test/system/friendships_test.rb index 1db4d3c25..25b627f53 100644 --- a/test/system/friendships_test.rb +++ b/test/system/friendships_test.rb @@ -8,11 +8,11 @@ class FriendshipsTest < ApplicationSystemTestCase with_settings(:max_friends_per_hour => 0) do visit user_path(befriendee) - assert_link "Add Friend" + assert_link "Follow" - click_on "Add Friend" - assert_text "You have friended a lot of users recently" - assert_link "Add Friend" + click_on "Follow" + assert_text "You have followed a lot of users recently" + assert_link "Follow" end end end -- 2.39.5