X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/17323257685bf5134d9286f5baefaddcae65478c..2b7a48029bff06c190544f91c5969b09aeae552b:/test/controllers/friendships_controller_test.rb 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")