This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user