register_email = ActionMailer::Base.deliveries.first
assert_equal register_email.to[0], user.email
register_email = ActionMailer::Base.deliveries.first
assert_equal register_email.to[0], user.email
@request.cookies["_osm_session"] = user.display_name
post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
assert_redirected_to login_path
@request.cookies["_osm_session"] = user.display_name
post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
assert_redirected_to login_path
@request.cookies["_osm_session"] = user.display_name
post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }, :session => { :token => token }
assert_redirected_to login_path
@request.cookies["_osm_session"] = user.display_name
post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }, :session => { :token => token }
assert_redirected_to login_path
@request.cookies["_osm_session"] = user.display_name
post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
assert_redirected_to login_path(:referer => diary_new_path)
@request.cookies["_osm_session"] = user.display_name
post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
assert_redirected_to login_path(:referer => diary_new_path)
@request.cookies["_osm_session"] = user.display_name
post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }, :session => { :token => token }
assert_redirected_to login_path(:referer => diary_new_path)
@request.cookies["_osm_session"] = user.display_name
post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }, :session => { :token => token }
assert_redirected_to login_path(:referer => diary_new_path)
@request.cookies["_osm_session"] = user.display_name
post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
assert_redirected_to :action => "confirm"
@request.cookies["_osm_session"] = user.display_name
post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
assert_redirected_to :action => "confirm"
@request.cookies["_osm_session"] = user.display_name
post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
assert_redirected_to :action => "login"
@request.cookies["_osm_session"] = user.display_name
post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
assert_redirected_to :action => "login"
post :confirm_email, :params => { :confirm_string => confirm_string }
assert_response :redirect
assert_redirected_to :action => :account, :display_name => user.display_name
post :confirm_email, :params => { :confirm_string => confirm_string }
assert_response :redirect
assert_redirected_to :action => :account, :display_name => user.display_name
post :confirm_email, :params => { :confirm_string => confirm_string }
assert_response :redirect
assert_redirected_to :action => :account, :display_name => user.display_name
post :confirm_email, :params => { :confirm_string => confirm_string }
assert_response :redirect
assert_redirected_to :action => :account, :display_name => user.display_name
end
def test_confirm_email_bad_token
post :confirm_email, :params => { :confirm_string => "XXXXX" }
assert_response :success
assert_template :confirm_email
end
def test_confirm_email_bad_token
post :confirm_email, :params => { :confirm_string => "XXXXX" }
assert_response :success
assert_template :confirm_email
post :confirm_email, :params => { :confirm_string => confirm_string }
assert_response :redirect
assert_redirected_to :action => :account, :display_name => user.display_name
post :confirm_email, :params => { :confirm_string => confirm_string }
assert_response :redirect
assert_redirected_to :action => :account, :display_name => user.display_name
post :confirm_email, :params => { :confirm_string => confirm_string }
assert_response :redirect
assert_redirected_to :action => :account, :display_name => user.display_name
post :confirm_email, :params => { :confirm_string => confirm_string }
assert_response :redirect
assert_redirected_to :action => :account, :display_name => user.display_name
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_equal user.email, email.to.first
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_equal user.email, email.to.first
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_equal uppercase_user.email, email.to.first
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_equal uppercase_user.email, email.to.first
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_equal third_user.email, email.to.first
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_equal third_user.email, email.to.first
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_equal third_user.email, email.to.first
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_equal third_user.email, email.to.first
# Check that the user account page will display and contains some relevant
# information for the user
# Check that the user account page will display and contains some relevant
# information for the user
- get :view, :params => { :display_name => user.display_name }
+ create(:friend, :befriender => user)
+ 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
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)
# Test a user who has been blocked
blocked_user = create(:user)
create(:user_block, :user => blocked_user)
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(blocked_user.display_name)}/history']", 1
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)
# Test a moderator who has applied blocks
moderator_user = create(:moderator_user)
create(:user_block, :creator => moderator_user)
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(moderator_user.display_name)}/history']", 1
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(moderator_user.display_name)}/history']", 1
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
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)
seen_user = create(:user, :terms_seen => true)
not_seen_user = create(:user, :terms_seen => false)
assert_response :success
assert_select "div#userinformation" do
assert_select "p", :count => 0, :text => /Contributor terms/
end
assert_response :success
assert_select "div#userinformation" do
assert_select "p", :count => 0, :text => /Contributor terms/
end
assert_response :success
assert_select "div#userinformation" do
assert_select "p", :count => 1, :text => /Contributor terms/
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_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_match /is now your friend/, flash[:notice]
+ 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_equal 1, email.to.count
assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_no_difference "ActionMailer::Base.deliveries.size" do
post :make_friend, :params => { :display_name => friend.display_name }, :session => { :user => user }
end
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_match /You are already friends with/, flash[:warning]
+ assert_redirected_to user_path(friend)
+ assert_match(/You are already friends with/, flash[:warning])
post :make_friend, :params => { :display_name => friend.display_name, :referer => "/test" }, :session => { :user => user }
end
assert_redirected_to "/test"
post :make_friend, :params => { :display_name => friend.display_name, :referer => "/test" }, :session => { :user => user }
end
assert_redirected_to "/test"
assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
# When logged in a POST should remove the friendship
post :remove_friend, :params => { :display_name => friend.display_name }, :session => { :user => user }
# 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_match /was removed from your friends/, flash[:notice]
+ 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_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_match /is not one of your friends/, flash[:error]
+ assert_redirected_to user_path(friend)
+ assert_match(/is not one of your friends/, flash[:error])
# When logged in a POST should remove the friendship and refer
post :remove_friend, :params => { :display_name => friend.display_name, :referer => "/test" }, :session => { :user => user }
assert_redirected_to "/test"
# When logged in a POST should remove the friendship and refer
post :remove_friend, :params => { :display_name => friend.display_name, :referer => "/test" }, :session => { :user => user }
assert_redirected_to "/test"
# Now try as a normal user
get :set_status, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => user }
assert_response :redirect
# Now try as a normal user
get :set_status, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => user }
assert_response :redirect
# Finally try as an administrator
get :set_status, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => create(:administrator_user) }
assert_response :redirect
# Finally try as an administrator
get :set_status, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => create(:administrator_user) }
assert_response :redirect
# Now try as a normal user
get :delete, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => user }
assert_response :redirect
# Now try as a normal user
get :delete, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => user }
assert_response :redirect
# Finally try as an administrator
get :delete, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => create(:administrator_user) }
assert_response :redirect
# Finally try as an administrator
get :delete, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => create(:administrator_user) }
assert_response :redirect
assert_equal 7, User.count
# Shouldn't work when not logged in
assert_equal 7, User.count
# Shouldn't work when not logged in
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
session[:user] = user.id
# Shouldn't work when logged in as a normal user
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
session[:user] = user.id
# Shouldn't work when logged in as a normal user
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
session[:user] = moderator_user.id
# Shouldn't work when logged in as a moderator
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
session[:user] = moderator_user.id
# Shouldn't work when logged in as a moderator
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
# Note there is a header row, so all row counts are users + 1
# Should work when logged in as an administrator
# Note there is a header row, so all row counts are users + 1
# Should work when logged in as an administrator
assert_select "table#user_list tr", :count => 7 + 1
# Should be able to limit by status
assert_select "table#user_list tr", :count => 7 + 1
# Should be able to limit by status
assert_select "table#user_list tr", :count => 1 + 1
# Should be able to limit by IP address
assert_select "table#user_list tr", :count => 1 + 1
# Should be able to limit by IP address
1.upto(100).each do |n|
User.create(:display_name => "extra_#{n}",
:email => "extra#{n}@example.com",
1.upto(100).each do |n|
User.create(:display_name => "extra_#{n}",
:email => "extra#{n}@example.com",
# 100 examples, an administrator, and a granter for the admin.
assert_equal 102, User.count
# 100 examples, an administrator, and a granter for the admin.
assert_equal 102, User.count
inactive_user = create(:user, :pending)
suspended_user = create(:user, :suspended)
# Shouldn't work when not logged in
assert_no_difference "User.active.count" do
inactive_user = create(:user, :pending)
suspended_user = create(:user, :suspended)
# Shouldn't work when not logged in
assert_no_difference "User.active.count" do
- post :list, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
+ post :index, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
end
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
end
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
- post :list, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
+ post :index, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
end
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
end
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
- post :list, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
+ post :index, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
end
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
end
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
# Should work when logged in as an administrator
assert_difference "User.active.count", 2 do
# Should work when logged in as an administrator
assert_difference "User.active.count", 2 do
- post :list, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
+ post :index, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
assert_equal "confirmed", inactive_user.reload.status
assert_equal "confirmed", suspended_user.reload.status
end
assert_equal "confirmed", inactive_user.reload.status
assert_equal "confirmed", suspended_user.reload.status
end
normal_user = create(:user)
confirmed_user = create(:user, :confirmed)
# Shouldn't work when not logged in
assert_no_difference "User.active.count" do
normal_user = create(:user)
confirmed_user = create(:user, :confirmed)
# Shouldn't work when not logged in
assert_no_difference "User.active.count" do
- post :list, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
+ post :index, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
end
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
end
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
- post :list, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
+ post :index, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
end
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
end
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
- post :list, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
+ post :index, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
end
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
end
assert_response :redirect
assert_redirected_to :action => :login, :referer => users_path
# Should work when logged in as an administrator
assert_difference "User.active.count", -2 do
# Should work when logged in as an administrator
assert_difference "User.active.count", -2 do
- post :list, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
+ post :index, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
assert_equal "deleted", normal_user.reload.status
assert_equal "deleted", confirmed_user.reload.status
end
assert_equal "deleted", normal_user.reload.status
assert_equal "deleted", confirmed_user.reload.status
end