Skip to content

Commit

Permalink
Add test for User#login special case.
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed May 17, 2024
1 parent d7db7e9 commit 2fbc2a2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 2 additions & 6 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ RAILS_ENV=production
RAILS_LOG_TO_STDOUT=true

# [Database Config]
# DATABASE_URL=postgres://localhost:5432/homeland
DATABASE_URL=postgres://localhost:54321/homeland
DATABASE_POOL=64
REDIS_URL=redis://localhost:6379/1
REDIS_URL=redis://localhost:63791/1

# [Application Config]
# Configuration Document:
Expand Down Expand Up @@ -58,7 +58,3 @@ upload_bucket=
upload_aliyun_internal=
upload_aliyun_area=
upload_url=




16 changes: 16 additions & 0 deletions test/models/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -498,4 +498,20 @@ def assert_valid_login(valid, logins)
assert_nil user.github_repos_path
assert_nil User.fetch_github_repositories(user.id)
end

test "login unique with case insensitive" do
u = create(:user, login: "Huacnlee")
assert_raise ActiveRecord::RecordInvalid do
create(:user, login: "huacnlee")
end

u.update!(name: "New Name")
assert_equal "New Name", u.reload.name
end

test "github user to update name" do
u = create(:user, login: "GitHub-User", email: "github+12345@example.com")
u.update!(name: "New Name")
assert_equal "GitHub-User", u.reload.login
end
end

0 comments on commit 2fbc2a2

Please sign in to comment.