Compare commits
No commits in common. "ba0343f6cbb866518bc402b5a1f6df54b5125216" and "c23f58a6df1411ec9d28472435052b7c869099b1" have entirely different histories.
ba0343f6cb
...
c23f58a6df
21 changed files with 2 additions and 309 deletions
2
Gemfile
2
Gemfile
|
@ -24,7 +24,7 @@ gem "solid_queue"
|
||||||
# gem "kredis"
|
# gem "kredis"
|
||||||
|
|
||||||
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
|
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
|
||||||
gem "bcrypt"
|
# gem "bcrypt", "~> 3.1.7"
|
||||||
|
|
||||||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||||
gem "tzinfo-data", platforms: %i[ windows jruby ]
|
gem "tzinfo-data", platforms: %i[ windows jruby ]
|
||||||
|
|
|
@ -102,7 +102,6 @@ GEM
|
||||||
public_suffix (>= 2.0.2, < 7.0)
|
public_suffix (>= 2.0.2, < 7.0)
|
||||||
ast (2.4.2)
|
ast (2.4.2)
|
||||||
base64 (0.2.0)
|
base64 (0.2.0)
|
||||||
bcrypt (3.1.20)
|
|
||||||
bigdecimal (3.1.8)
|
bigdecimal (3.1.8)
|
||||||
bindex (0.8.1)
|
bindex (0.8.1)
|
||||||
bootsnap (1.18.3)
|
bootsnap (1.18.3)
|
||||||
|
@ -306,7 +305,6 @@ PLATFORMS
|
||||||
x86_64-linux
|
x86_64-linux
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
bcrypt
|
|
||||||
bootsnap
|
bootsnap
|
||||||
brakeman
|
brakeman
|
||||||
capybara
|
capybara
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
class UsersController < ApplicationController
|
|
||||||
before_action :set_user, only: %i[ show edit update destroy ]
|
|
||||||
|
|
||||||
# GET /users or /users.json
|
|
||||||
def index
|
|
||||||
@users = User.all
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /users/1 or /users/1.json
|
|
||||||
def show
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /users/new
|
|
||||||
def new
|
|
||||||
@user = User.new
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /users/1/edit
|
|
||||||
def edit
|
|
||||||
end
|
|
||||||
|
|
||||||
# POST /users or /users.json
|
|
||||||
def create
|
|
||||||
@user = User.new(user_params)
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
if @user.save
|
|
||||||
format.html { redirect_to user_url(@user), notice: "User was successfully created." }
|
|
||||||
format.json { render :show, status: :created, location: @user }
|
|
||||||
else
|
|
||||||
format.html { render :new, status: :unprocessable_entity }
|
|
||||||
format.json { render json: @user.errors, status: :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# PATCH/PUT /users/1 or /users/1.json
|
|
||||||
def update
|
|
||||||
respond_to do |format|
|
|
||||||
if @user.update(user_params)
|
|
||||||
format.html { redirect_to user_url(@user), notice: "User was successfully updated." }
|
|
||||||
format.json { render :show, status: :ok, location: @user }
|
|
||||||
else
|
|
||||||
format.html { render :edit, status: :unprocessable_entity }
|
|
||||||
format.json { render json: @user.errors, status: :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# DELETE /users/1 or /users/1.json
|
|
||||||
def destroy
|
|
||||||
@user.destroy!
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.html { redirect_to users_url, notice: "User was successfully destroyed." }
|
|
||||||
format.json { head :no_content }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
|
||||||
def set_user
|
|
||||||
@user = User.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
# Only allow a list of trusted parameters through.
|
|
||||||
def user_params
|
|
||||||
params.require(:user).permit(:email, :password, :password_confirmation)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,2 +0,0 @@
|
||||||
module UsersHelper
|
|
||||||
end
|
|
|
@ -1,3 +0,0 @@
|
||||||
class User < ApplicationRecord
|
|
||||||
has_secure_password
|
|
||||||
end
|
|
|
@ -1,32 +0,0 @@
|
||||||
<%= form_with(model: user, class: "contents") do |form| %>
|
|
||||||
<% if user.errors.any? %>
|
|
||||||
<div id="error_explanation" class="bg-red-50 text-red-500 px-3 py-2 font-medium rounded-lg mt-3">
|
|
||||||
<h2><%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<% user.errors.each do |error| %>
|
|
||||||
<li><%= error.full_message %></li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<div class="my-5">
|
|
||||||
<%= form.label :email %>
|
|
||||||
<%= form.text_field :email, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="my-5">
|
|
||||||
<%= form.label :password %>
|
|
||||||
<%= form.password_field :password, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="my-5">
|
|
||||||
<%= form.label :password_confirmation %>
|
|
||||||
<%= form.password_field :password_confirmation, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="inline">
|
|
||||||
<%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
|
@ -1,7 +0,0 @@
|
||||||
<div id="<%= dom_id user %>">
|
|
||||||
<p class="my-5">
|
|
||||||
<strong class="block font-medium mb-1">Email:</strong>
|
|
||||||
<%= user.email %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</div>
|
|
|
@ -1,2 +0,0 @@
|
||||||
json.extract! user, :id, :email, :created_at, :updated_at
|
|
||||||
json.url user_url(user, format: :json)
|
|
|
@ -1,8 +0,0 @@
|
||||||
<div class="mx-auto md:w-2/3 w-full">
|
|
||||||
<h1 class="font-bold text-4xl">Editing user</h1>
|
|
||||||
|
|
||||||
<%= render "form", user: @user %>
|
|
||||||
|
|
||||||
<%= link_to "Show this user", @user, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
|
||||||
<%= link_to "Back to users", users_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
|
||||||
</div>
|
|
|
@ -1,21 +0,0 @@
|
||||||
<div class="w-full">
|
|
||||||
<% if notice.present? %>
|
|
||||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% content_for :title, "Users" %>
|
|
||||||
|
|
||||||
<div class="flex justify-between items-center">
|
|
||||||
<h1 class="font-bold text-4xl">Users</h1>
|
|
||||||
<%= link_to "New user", new_user_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="users" class="min-w-full">
|
|
||||||
<% @users.each do |user| %>
|
|
||||||
<%= render user %>
|
|
||||||
<p>
|
|
||||||
<%= link_to "Show this user", user, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
|
||||||
</p>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
|
@ -1 +0,0 @@
|
||||||
json.array! @users, partial: "users/user", as: :user
|
|
|
@ -1,7 +0,0 @@
|
||||||
<div class="mx-auto md:w-2/3 w-full">
|
|
||||||
<h1 class="font-bold text-4xl">New user</h1>
|
|
||||||
|
|
||||||
<%= render "form", user: @user %>
|
|
||||||
|
|
||||||
<%= link_to "Back to users", users_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
|
||||||
</div>
|
|
|
@ -1,15 +0,0 @@
|
||||||
<div class="mx-auto md:w-2/3 w-full flex">
|
|
||||||
<div class="mx-auto">
|
|
||||||
<% if notice.present? %>
|
|
||||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= render @user %>
|
|
||||||
|
|
||||||
<%= link_to "Edit this user", edit_user_path(@user), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
|
||||||
<%= link_to "Back to users", users_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
|
||||||
<div class="inline-block ml-2">
|
|
||||||
<%= button_to "Destroy this user", @user, method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
|
@ -1 +0,0 @@
|
||||||
json.partial! "users/user", user: @user
|
|
|
@ -1,5 +1,4 @@
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
resources :users
|
|
||||||
resources :credit_card_bills
|
resources :credit_card_bills
|
||||||
resource :dashboard, only: :show
|
resource :dashboard, only: :show
|
||||||
resources :incomes
|
resources :incomes
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
class CreateUsers < ActiveRecord::Migration[8.0]
|
|
||||||
def change
|
|
||||||
create_table :users do |t|
|
|
||||||
t.string :email
|
|
||||||
t.string :password_digest
|
|
||||||
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
add_index :users, :email, unique: true
|
|
||||||
end
|
|
||||||
end
|
|
10
db/schema.rb
generated
10
db/schema.rb
generated
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.0].define(version: 2024_07_27_022931) do
|
ActiveRecord::Schema[8.0].define(version: 2024_07_27_002531) do
|
||||||
create_table "credit_card_bills", force: :cascade do |t|
|
create_table "credit_card_bills", force: :cascade do |t|
|
||||||
t.string "description"
|
t.string "description"
|
||||||
t.decimal "amount"
|
t.decimal "amount"
|
||||||
|
@ -148,14 +148,6 @@ ActiveRecord::Schema[8.0].define(version: 2024_07_27_022931) do
|
||||||
t.index ["key"], name: "index_solid_queue_semaphores_on_key", unique: true
|
t.index ["key"], name: "index_solid_queue_semaphores_on_key", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "users", force: :cascade do |t|
|
|
||||||
t.string "email"
|
|
||||||
t.string "password_digest"
|
|
||||||
t.datetime "created_at", null: false
|
|
||||||
t.datetime "updated_at", null: false
|
|
||||||
t.index ["email"], name: "index_users_on_email", unique: true
|
|
||||||
end
|
|
||||||
|
|
||||||
add_foreign_key "incomes", "members"
|
add_foreign_key "incomes", "members"
|
||||||
add_foreign_key "solid_queue_blocked_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
add_foreign_key "solid_queue_blocked_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||||
add_foreign_key "solid_queue_claimed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
add_foreign_key "solid_queue_claimed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
require "test_helper"
|
|
||||||
|
|
||||||
class UsersControllerTest < ActionDispatch::IntegrationTest
|
|
||||||
setup do
|
|
||||||
@user = users(:one)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should get index" do
|
|
||||||
get users_url
|
|
||||||
assert_response :success
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should get new" do
|
|
||||||
get new_user_url
|
|
||||||
assert_response :success
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should create user" do
|
|
||||||
assert_difference("User.count") do
|
|
||||||
params = {
|
|
||||||
user: {
|
|
||||||
email: "userthree@example.local",
|
|
||||||
password: "secret",
|
|
||||||
password_confirmation: "secret"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
post users_url, params: params
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_redirected_to user_url(User.last)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should show user" do
|
|
||||||
get user_url(@user)
|
|
||||||
assert_response :success
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should get edit" do
|
|
||||||
get edit_user_url(@user)
|
|
||||||
assert_response :success
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should update user" do
|
|
||||||
patch user_url(@user), params: { user: { email: @user.email, password: "secret", password_confirmation: "secret" } }
|
|
||||||
assert_redirected_to user_url(@user)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should destroy user" do
|
|
||||||
assert_difference("User.count", -1) do
|
|
||||||
delete user_url(@user)
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_redirected_to users_url
|
|
||||||
end
|
|
||||||
end
|
|
9
test/fixtures/users.yml
vendored
9
test/fixtures/users.yml
vendored
|
@ -1,9 +0,0 @@
|
||||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
|
||||||
|
|
||||||
one:
|
|
||||||
email: userone@example.local
|
|
||||||
password_digest: <%= BCrypt::Password.create("secret") %>
|
|
||||||
|
|
||||||
two:
|
|
||||||
email: usertwo@example.local
|
|
||||||
password_digest: <%= BCrypt::Password.create("secret") %>
|
|
|
@ -1,7 +0,0 @@
|
||||||
require "test_helper"
|
|
||||||
|
|
||||||
class UserTest < ActiveSupport::TestCase
|
|
||||||
# test "the truth" do
|
|
||||||
# assert true
|
|
||||||
# end
|
|
||||||
end
|
|
|
@ -1,45 +0,0 @@
|
||||||
require "application_system_test_case"
|
|
||||||
|
|
||||||
class UsersTest < ApplicationSystemTestCase
|
|
||||||
setup do
|
|
||||||
@user = users(:one)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "visiting the index" do
|
|
||||||
visit users_url
|
|
||||||
assert_selector "h1", text: "Users"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should create user" do
|
|
||||||
visit users_url
|
|
||||||
click_on "New user"
|
|
||||||
|
|
||||||
fill_in "Email", with: "userthree@example.local"
|
|
||||||
fill_in "Password", with: "secret"
|
|
||||||
fill_in "Password confirmation", with: "secret"
|
|
||||||
click_on "Create User"
|
|
||||||
|
|
||||||
assert_text "User was successfully created"
|
|
||||||
click_on "Back"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should update User" do
|
|
||||||
visit user_url(@user)
|
|
||||||
click_on "Edit this user", match: :first
|
|
||||||
|
|
||||||
fill_in "Email", with: "newemail@example.local"
|
|
||||||
fill_in "Password", with: "newpassword"
|
|
||||||
fill_in "Password confirmation", with: "newpassword"
|
|
||||||
click_on "Update User"
|
|
||||||
|
|
||||||
assert_text "User was successfully updated"
|
|
||||||
click_on "Back"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "should destroy User" do
|
|
||||||
visit user_url(@user)
|
|
||||||
click_on "Destroy this user", match: :first
|
|
||||||
|
|
||||||
assert_text "User was successfully destroyed"
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Add table
Reference in a new issue