assert_routing(
{ :path => "/user/username", :method => :get },
- { :controller => "user", :action => "view", :display_name => "username" }
+ { :controller => "user", :action => "show", :display_name => "username" }
)
assert_routing(
# Check that the user account page will display and contains some relevant
# information for the user
- def test_view
+ def test_show
# Test a non-existent user
- get :view, :params => { :display_name => "unknown" }
+ get :show, :params => { :display_name => "unknown" }
assert_response :not_found
# Test a normal user
user = create(:user)
- get :view, :params => { :display_name => user.display_name }
+ get :show, :params => { :display_name => user.display_name }
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
# Test a user who has been blocked
blocked_user = create(:user)
create(:user_block, :user => blocked_user)
- get :view, :params => { :display_name => blocked_user.display_name }
+ get :show, :params => { :display_name => blocked_user.display_name }
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(blocked_user.display_name)}/history']", 1
# Test a moderator who has applied blocks
moderator_user = create(:moderator_user)
create(:user_block, :creator => moderator_user)
- get :view, :params => { :display_name => moderator_user.display_name }
+ get :show, :params => { :display_name => moderator_user.display_name }
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(moderator_user.display_name)}/history']", 1
session[:user] = user.id
# Test the normal user
- get :view, :params => { :display_name => user.display_name }
+ get :show, :params => { :display_name => user.display_name }
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
session[:user] = create(:moderator_user).id
# Test the normal user
- get :view, :params => { :display_name => user.display_name }
+ get :show, :params => { :display_name => user.display_name }
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
seen_user = create(:user, :terms_seen => true)
not_seen_user = create(:user, :terms_seen => false)
- get :view, :params => { :display_name => agreed_user.display_name }
+ get :show, :params => { :display_name => agreed_user.display_name }
assert_response :success
assert_select "div#userinformation" do
assert_select "p", :count => 0, :text => /Contributor terms/
end
- get :view, :params => { :display_name => seen_user.display_name }
+ get :show, :params => { :display_name => seen_user.display_name }
assert_response :success
# put @response.body
assert_select "div#userinformation" do
assert_select "p", /Declined/
end
- get :view, :params => { :display_name => not_seen_user.display_name }
+ get :show, :params => { :display_name => not_seen_user.display_name }
assert_response :success
assert_select "div#userinformation" do
assert_select "p", :count => 1, :text => /Contributor terms/
assert_difference "ActionMailer::Base.deliveries.size", 1 do
post :make_friend, :params => { :display_name => friend.display_name }, :session => { :user => user }
end
- assert_redirected_to user_path(:display_name => friend.display_name)
+ assert_redirected_to user_path(friend)
assert_match /is now your friend/, flash[:notice]
assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
email = ActionMailer::Base.deliveries.first
assert_no_difference "ActionMailer::Base.deliveries.size" do
post :make_friend, :params => { :display_name => friend.display_name }, :session => { :user => user }
end
- assert_redirected_to user_path(:display_name => friend.display_name)
+ assert_redirected_to user_path(friend)
assert_match /You are already friends with/, flash[:warning]
assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
end
# When logged in a POST should remove the friendship
post :remove_friend, :params => { :display_name => friend.display_name }, :session => { :user => user }
- assert_redirected_to user_path(:display_name => friend.display_name)
+ assert_redirected_to user_path(friend)
assert_match /was removed from your friends/, flash[:notice]
assert_nil Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
# A second POST should report that the friendship does not exist
post :remove_friend, :params => { :display_name => friend.display_name }, :session => { :user => user }
- assert_redirected_to user_path(:display_name => friend.display_name)
+ assert_redirected_to user_path(friend)
assert_match /is not one of your friends/, flash[:error]
assert_nil Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
end
# Now try as a normal user
get :set_status, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => user }
assert_response :redirect
- assert_redirected_to :action => :view, :display_name => user.display_name
+ assert_redirected_to :action => :show, :display_name => user.display_name
# Finally try as an administrator
get :set_status, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => create(:administrator_user) }
assert_response :redirect
- assert_redirected_to :action => :view, :display_name => user.display_name
+ assert_redirected_to :action => :show, :display_name => user.display_name
assert_equal "suspended", User.find(user.id).status
end
# Now try as a normal user
get :delete, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => user }
assert_response :redirect
- assert_redirected_to :action => :view, :display_name => user.display_name
+ assert_redirected_to :action => :show, :display_name => user.display_name
# Finally try as an administrator
get :delete, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => create(:administrator_user) }
assert_response :redirect
- assert_redirected_to :action => :view, :display_name => user.display_name
+ assert_redirected_to :action => :show, :display_name => user.display_name
# Check that the user was deleted properly
user.reload