This commit is contained in:
2026-04-20 23:31:33 +09:00
parent 63dcc9b266
commit 2cfe9fdc55
2 changed files with 3 additions and 4 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ class UsersController < ApplicationController
def attach_ip_address! user
ip_bin = IPAddr.new(request.remote_ip).hton
ip_address = IpAddress.find_or_create_by!(ip_address: ip_bin)
ip_address = IpAddress.create_or_find_by!(ip_address: ip_bin)
UserIp.create_or_find_by!(user:, ip_address:)
end
+2 -3
View File
@@ -1,11 +1,10 @@
require "rails_helper"
RSpec.describe "Users", type: :request do
describe "POST /users" do
it "creates guest user and returns code" do
post "/users"
expect(response).to have_http_status(:ok)
expect(response).to have_http_status(:created)
expect(json["code"]).to be_present
expect(json["user"]["role"]).to eq("guest")
end
@@ -38,7 +37,7 @@ RSpec.describe "Users", type: :request do
sign_in_as(user)
put "/users/#{user.id}", params: { name: "new-name" }
expect(response).to have_http_status(:created)
expect(response).to have_http_status(:ok)
expect(json["id"]).to eq(user.id)
expect(json["name"]).to eq("new-name")