ユーザ作成時に IP アドレス連携するやぅに (#323) #326

マージ済み
みてるぞ が 5 個のコミットを feature/323 から main へマージ 2026-04-25 21:00:23 +09:00
2個のファイルの変更3行の追加4行の削除
コミット 2cfe9fdc55 の変更だけを表示してゐます - すべてのコミットを表示
+1 -1
ファイルの表示
@@ -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
ファイルの表示
@@ -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")