# The user creation page loads
def test_new_view
get user_new_path
- assert_response :redirect
assert_redirected_to user_new_path(:cookie_test => "true")
get user_new_path, :params => { :cookie_test => "true" }
session_for(create(:user))
get user_new_path
- assert_response :redirect
assert_redirected_to root_path
get user_new_path, :params => { :referer => "/test" }
- assert_response :redirect
assert_redirected_to "/test"
end
assert_response :success
assert_template "new"
- assert_select "form > div.form-group > input.is-invalid#user_email"
+ assert_select "form > div > input.is-invalid#user_email"
end
def test_save_duplicate_email
assert_response :success
assert_template "new"
- assert_select "form > div.form-group > input.is-invalid#user_email"
+ assert_select "form > div > input.is-invalid#user_email"
end
def test_save_duplicate_email_uppercase
assert_response :success
assert_template "new"
- assert_select "form > div.form-group > input.is-invalid#user_email"
+ assert_select "form > div > input.is-invalid#user_email"
end
def test_save_duplicate_name
assert_response :success
assert_template "new"
- assert_select "form > div.form-group > input.is-invalid#user_display_name"
+ assert_select "form > div > input.is-invalid#user_display_name"
end
def test_save_duplicate_name_uppercase
assert_response :success
assert_template "new"
- assert_select "form > div.form-group > input.is-invalid#user_display_name"
+ assert_select "form > div > input.is-invalid#user_display_name"
end
def test_save_blocked_domain
assert_difference "User.count", 1 do
assert_difference "ActionMailer::Base.deliveries.size", 1 do
- perform_enqueued_jobs do
- post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
- end
+ post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
+ assert_enqueued_with :job => ActionMailer::MailDeliveryJob,
+ :args => proc { |args| args[3][:args][2] == welcome_path(:editor => "id", :zoom => 1, :lat => 2, :lon => 3) }
+ perform_enqueued_jobs
end
end
- assert_equal welcome_path(:editor => "id", :zoom => 1, :lat => 2, :lon => 3),
- User.find_by(:email => user.email).tokens.order("id DESC").first.referer
-
ActionMailer::Base.deliveries.clear
end
session_for(user)
get user_terms_path
- assert_response :redirect
assert_redirected_to edit_account_path
end
assert_template :terms
post user_save_path, :params => { :user => { :consider_pd => true }, :read_ct => 1, :read_tou => 1 }
- assert_response :redirect
assert_redirected_to edit_account_path
assert_equal "Thanks for accepting the new contributor terms!", flash[:notice]
assert_template :terms
post user_save_path, :params => { :user => { :consider_pd => true }, :referer => "/test", :read_ct => 1, :read_tou => 1 }
- assert_response :redirect
assert_redirected_to "/test"
assert_equal "Thanks for accepting the new contributor terms!", flash[:notice]
session_for(user)
get edit_account_path
- assert_response :redirect
assert_redirected_to :controller => :users, :action => :terms, :referer => "/account/edit"
end
post user_go_public_path
- assert_response :redirect
assert_redirected_to edit_account_path
assert User.find(user.id).data_public
end
assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0
assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0
assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0
+ assert_select "a[href='/api/0.6/user/#{ERB::Util.u(user.id)}']", 0
end
# Login as a moderator
assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0
assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0
assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 1
+ assert_select "a[href='/api/0.6/user/#{ERB::Util.u(user.id)}']", 1
end
end
get user_path(seen_user)
assert_response :success
- # put @response.body
assert_select "div.content-heading" do
assert_select "dt", :count => 1, :text => /Contributor terms/
assert_select "dd", /Declined/
user = create(:user)
# Try without logging in
- post set_status_user_path(user), :params => { :status => "suspended" }
+ post set_status_user_path(user), :params => { :event => "confirm" }
assert_response :forbidden
# Now try as a normal user
session_for(user)
- post set_status_user_path(user), :params => { :status => "suspended" }
- assert_response :redirect
+ post set_status_user_path(user), :params => { :event => "confirm" }
assert_redirected_to :controller => :errors, :action => :forbidden
# Finally try as an administrator
session_for(create(:administrator_user))
- post set_status_user_path(user), :params => { :status => "suspended" }
- assert_response :redirect
+ post set_status_user_path(user), :params => { :event => "confirm" }
assert_redirected_to :action => :show, :display_name => user.display_name
- assert_equal "suspended", User.find(user.id).status
+ assert_equal "confirmed", User.find(user.id).status
end
def test_destroy
user = create(:user, :home_lat => 12.1, :home_lon => 12.1, :description => "test")
# Try without logging in
- delete user_path(user), :params => { :status => "suspended" }
+ delete user_path(user)
assert_response :forbidden
# Now try as a normal user
session_for(user)
- delete user_path(user), :params => { :status => "suspended" }
- assert_response :redirect
+ delete user_path(user)
assert_redirected_to :controller => :errors, :action => :forbidden
# Finally try as an administrator
session_for(create(:administrator_user))
- delete user_path(user), :params => { :status => "suspended" }
- assert_response :redirect
+ delete user_path(user)
assert_redirected_to :action => :show, :display_name => user.display_name
# Check that the user was deleted properly
# Shouldn't work when not logged in
get users_path
- assert_response :redirect
assert_redirected_to login_path(:referer => users_path)
session_for(user)
# Shouldn't work when logged in as a normal user
get users_path
- assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
session_for(moderator_user)
# Shouldn't work when logged in as a moderator
get users_path
- assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
session_for(administrator_user)
assert_no_difference "User.active.count" do
post users_path, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
end
- assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
assert_equal "pending", inactive_user.reload.status
assert_equal "suspended", suspended_user.reload.status
assert_no_difference "User.active.count" do
post users_path, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
end
- assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
assert_equal "pending", inactive_user.reload.status
assert_equal "suspended", suspended_user.reload.status
assert_difference "User.active.count", 2 do
post users_path, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
end
- assert_response :redirect
assert_redirected_to :action => :index
assert_equal "confirmed", inactive_user.reload.status
assert_equal "confirmed", suspended_user.reload.status
assert_no_difference "User.active.count" do
post users_path, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
end
- assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
assert_equal "active", normal_user.reload.status
assert_equal "confirmed", confirmed_user.reload.status
assert_no_difference "User.active.count" do
post users_path, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
end
- assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
assert_equal "active", normal_user.reload.status
assert_equal "confirmed", confirmed_user.reload.status
assert_difference "User.active.count", -2 do
post users_path, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
end
- assert_response :redirect
assert_redirected_to :action => :index
assert_equal "deleted", normal_user.reload.status
assert_equal "deleted", confirmed_user.reload.status
def test_auth_failure_callback
get auth_failure_path
- assert_response :redirect
assert_redirected_to login_path
get auth_failure_path, :params => { :origin => "/" }
- assert_response :redirect
assert_redirected_to root_path
get auth_failure_path, :params => { :origin => "http://www.google.com" }
- assert_response :redirect
assert_redirected_to login_path
end
end