songtianlun
a54ebdbf23
- Implement AccountActivationsController for activation logic - Create UserMailer for sending activation emails - Update SessionsController to handle unactivated users - Modify UsersController to restrict access to activated users - Add activation fields to User model and database migration - Create views for account activation emails - Add tests for account activation functionality
30 lines
762 B
Ruby
30 lines
762 B
Ruby
require "test_helper"
|
|
|
|
class UsersIndexTest < ActionDispatch::IntegrationTest
|
|
def setup
|
|
@admin = users(:michael)
|
|
@non_admin = users(:archer)
|
|
end
|
|
|
|
test "index including pagination and delete links" do
|
|
log_in_as(@admin)
|
|
get users_path
|
|
assert_template "users/index"
|
|
assert_select "ul.pagination"
|
|
|
|
first_page_of_users = User.page(1)
|
|
first_page_of_users.first.toggle!(:activated)
|
|
first_page_of_users.each do |user|
|
|
# assert_not user.activated?
|
|
assert_select "a[href=?]", user_path(user), text: user.name
|
|
unless user == @admin
|
|
assert_select "a[href=?]", user_path(user), text: "delete"
|
|
end
|
|
end
|
|
|
|
assert_difference "User.count", -1 do
|
|
delete user_path(@non_admin)
|
|
end
|
|
end
|
|
end
|