Someone has requested a link to change your password. You can do this through the link below.
4 |
5 |
<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>
6 |
7 |
If you didn't request this, please ignore this email.
8 |
Your password won't change until you access the link above and create a new one.
9 |
--------------------------------------------------------------------------------
/config/credentials.yml.enc:
--------------------------------------------------------------------------------
1 | neLfErHYYXnGGy1Q6FkxN3xBwoAsJygTNFRrC4Yp+r7N6/U9d2O/XY65F8EbPLS/b1CJUZ6Ol+oXEJQB54uSUo6XLgx7ruv7cYA9DYVAXkUHswikxef6eQIeaYoZUBDcVjxEj8C03YtfukYDBjMMrdCC+iX1RIfpRG5HTm9JqqUg3mq8k1gPhQTgH2wShrryoOuI36HrziIlQcLVU3UxO1u3BmwRkE1qNj+6b+JonqIJy4lxTm5/sH92J3tcBp7strLBgQqK3U6nI+060mN+Gs/hUdRB0ssNZCWzYwYOeX3SCGf0tdFcz0JKtITQXHulOqbM8j1kdk7cV+/A6MBzwbp7w7U2TvQyrFsFhsqfBAELETHxt7ol7KQ80DBzbQfZAJd2VMZtA8gtcpp+ll3jLM7uh/nlXW4WU2MP--qgJLn3iQ2J+pZIOD--1ZMtmLUvUT2EjIsE72FKXQ==
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Be sure to restart your server when you modify this file.
4 |
5 | # Configure parameters to be filtered from the log file. Use this to limit dissemination of
6 | # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
7 | # notations and behaviors.
8 | Rails.application.config.filter_parameters += %i[
9 | passw secret token _key crypt salt certificate otp ssn
10 | ]
11 |
--------------------------------------------------------------------------------
/app/views/splashes/index.html.erb:
--------------------------------------------------------------------------------
1 |
16 |
--------------------------------------------------------------------------------
/app/javascript/controllers/index.js:
--------------------------------------------------------------------------------
1 | // Import and register all your controllers from the importmap under controllers/*
2 |
3 | import { application } from "controllers/application"
4 |
5 | // Eager load all controllers defined in the import map under controllers/**/*_controller
6 | import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
7 | eagerLoadControllersFrom("controllers", application)
8 |
9 | // Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!)
10 | // import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
11 | // lazyLoadControllersFrom("controllers", application)
12 |
--------------------------------------------------------------------------------
/app/views/devise/confirmations/new.html.erb:
--------------------------------------------------------------------------------
1 |
14 | <% end %>
15 |
16 | <%= render "devise/shared/links" %>
17 |
--------------------------------------------------------------------------------
/spec/models/user_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe User, type: :model do
4 | subject do
5 | User.new(name: 'Samantha Woods', email: 'sam@outlook.com', password: 'password',
6 | password_confirmation: 'password')
7 | end
8 |
9 | before { subject.save }
10 |
11 | context 'Test user validations' do
12 | it 'is a user with valid attributes' do
13 | expect(subject).to be_valid
14 | end
15 |
16 | it 'name should be present' do
17 | subject.name = nil
18 | expect(subject).to_not be_valid
19 | end
20 |
21 | it 'email should be an string' do
22 | expect(subject.email).to be_a_kind_of(String)
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 | # Be sure to restart your server when you modify this file.
3 |
4 | # Add new inflection rules using the following format. Inflections
5 | # are locale specific, and you may define rules for as many different
6 | # locales as you wish. All of these examples are active by default:
7 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
8 | # inflect.plural /^(ox)$/i, "\\1en"
9 | # inflect.singular /^(ox)en/i, "\\1"
10 | # inflect.irregular "person", "people"
11 | # inflect.uncountable %w( fish sheep )
12 | # end
13 |
14 | # These inflection rules are supported but not enabled by default:
15 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
16 | # inflect.acronym "RESTful"
17 | # end
18 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
6 | * vendor/assets/stylesheets directory can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS
10 | * files in this directory. Styles in this file should be added after the last require_* statement.
11 | * It is generally better to create a new file per style scope.
12 | *
13 | *= require_tree .
14 | *= require_self
15 | */
16 |
--------------------------------------------------------------------------------
/app/views/devise/passwords/new.html.erb:
--------------------------------------------------------------------------------
1 | <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
2 |
23 | <% end %>
24 |
25 | <%= render "devise/shared/links" %>
26 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t "hello"
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t("hello") %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # The following keys must be escaped otherwise they will not be retrieved by
20 | # the default I18n backend:
21 | #
22 | # true, false, on, off, yes, no
23 | #
24 | # Instead, surround them with single quotes.
25 | #
26 | # en:
27 | # "true": "foo"
28 | #
29 | # To learn more, please read the Rails Internationalization guide
30 | # available at https://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 |
--------------------------------------------------------------------------------
/spec/routing/users_routing_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe UsersController, type: :routing do
4 | describe 'routing' do
5 | it 'routes to #index' do
6 | expect(get: '/users').to route_to('users#index')
7 | end
8 |
9 | it 'routes to #new' do
10 | expect(get: '/users/new').to route_to('users#new')
11 | end
12 |
13 | it 'routes to #show' do
14 | expect(get: '/users/1').to route_to('users#show', id: '1')
15 | end
16 |
17 | it 'routes to #edit' do
18 | expect(get: '/users/1/edit').to route_to('users#edit', id: '1')
19 | end
20 |
21 | it 'routes to #update via PUT' do
22 | expect(put: '/users/1').to route_to('users#update', id: '1')
23 | end
24 |
25 | it 'routes to #update via PATCH' do
26 | expect(patch: '/users/1').to route_to('users#update', id: '1')
27 | end
28 |
29 | it 'routes to #destroy' do
30 | expect(delete: '/users/1').to route_to('users#destroy', id: '1')
31 | end
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/spec/models/spend_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe Spend, type: :model do
4 | before do
5 | @user = User.create(name: 'Samantha Woods', email: 'sam@outlook.com', password: 'password',
6 | password_confirmation: 'password')
7 | @group = Group.create(name: 'Pets', icon: 'pet_img', user: @user)
8 | @spend = Spend.create(name: 'Pet food', amount: 45, author: @user)
9 | @spend.groups << @group
10 | end
11 |
12 | context 'Test spend validations' do
13 | it 'is a spend with valid attributes' do
14 | expect(@spend).to be_valid
15 | end
16 |
17 | it 'amount should be great or equal than 0' do
18 | @spend.amount = -1
19 | expect(@spend).to_not be_valid
20 | end
21 |
22 | it 'name should be present' do
23 | @spend.name = nil
24 | expect(@spend).to_not be_valid
25 | end
26 |
27 | it 'amount should be present' do
28 | @spend.amount = nil
29 | expect(@spend).to_not be_valid
30 | end
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/app/views/spends/_form.html.erb:
--------------------------------------------------------------------------------
1 | <%= form_with model: spend, url: group_spends_path(@group) do |form| %>
2 | <% if spend.errors.any? %>
3 |
4 |
<%= pluralize(spend.errors.count, "error") %> prohibited this spend from being saved:
29 | <% end %>
30 |
31 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.tailwind.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
5 | @import url('https://fonts.googleapis.com/css2?family=Lobster+Two:ital,wght@0,400;0,700;1,400;1,700&display=swap');
6 | @import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
7 |
8 | @layer base {
9 | .logo {
10 | font-family: 'Lobster Two', cursive;
11 | }
12 |
13 | form .field {
14 | @apply mb-2 px-4 w-full;
15 | }
16 |
17 | nav {
18 | @apply bg-solid-blue text-white;
19 | }
20 | }
21 |
22 | @layer components {
23 | .auth-header {
24 | @apply flex bg-solid-blue text-white justify-between items-center px-2 sm:px-4 py-2.5;
25 | }
26 |
27 | .btn {
28 | @apply py-2 px-4 rounded font-normal text-center uppercase;
29 | }
30 |
31 | .btn-primary {
32 | @apply bg-solid-blue text-white;
33 | }
34 |
35 | .input-field {
36 | outline: none;
37 | width: 100%;
38 | height: 40px;
39 | border: 1px solid lightgray;
40 | border-top: none;
41 | padding: 10px;
42 | }
43 |
44 | .action {
45 | @apply w-screen p-4 bg-solid-green fixed bottom-0 left-0;
46 | }
47 |
48 | .action button,
49 | .action a {
50 | @apply py-3 uppercase flex justify-center rounded border-2 border-white border-solid text-white text-base;
51 | }
52 |
53 | .input-submit {
54 | @apply py-3 uppercase w-full flex justify-center rounded border-2 border-white border-solid text-white text-base;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/spec/requests/spends_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | # This spec was generated by rspec-rails when you ran the scaffold generator.
4 | # It demonstrates how one might use RSpec to test the controller code that
5 | # was generated by Rails when you ran the scaffold generator.
6 | #
7 | # It assumes that the implementation code is generated by the rails scaffold
8 | # generator. If you are using any extension libraries to generate different
9 | # controller code, this generated spec may or may not pass.
10 | #
11 | # It only uses APIs available in rails and/or rspec-rails. There are a number
12 | # of tools you can use to make these specs even more expressive, but we're
13 | # sticking to rails and rspec-rails APIs to keep things simple and stable.
14 |
15 | RSpec.describe '/spends', type: :request do
16 | before :each do
17 | @user = User.create(name: 'Samantha Woods', email: 'sam@outlook.com', password: 'password',
18 | password_confirmation: 'password')
19 | @group = Group.create(name: 'Pets', icon: 'pet_img', user: @user)
20 | @spend = Spend.create(name: 'Food', amount: 20, author: @user)
21 | @spend.groups << @group
22 | sign_in @user
23 | end
24 |
25 | describe 'GET /index' do
26 | it 'returns http success' do
27 | get group_spends_path(@group)
28 | expect(response).to have_http_status(302)
29 | end
30 | end
31 |
32 | describe 'GET /show' do
33 | it 'returns http success' do
34 | get group_spends_path(@group, @spend)
35 | expect(response).to have_http_status(302)
36 | end
37 | end
38 |
39 | describe 'GET /new' do
40 | it 'renders a successful response' do
41 | get new_group_spend_path(@group)
42 | expect(response).to have_http_status(302)
43 | end
44 | end
45 | end
46 |
--------------------------------------------------------------------------------
/spec/requests/groups_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | # This spec was generated by rspec-rails when you ran the scaffold generator.
4 | # It demonstrates how one might use RSpec to test the controller code that
5 | # was generated by Rails when you ran the scaffold generator.
6 | #
7 | # It assumes that the implementation code is generated by the rails scaffold
8 | # generator. If you are using any extension libraries to generate different
9 | # controller code, this generated spec may or may not pass.
10 | #
11 | # It only uses APIs available in rails and/or rspec-rails. There are a number
12 | # of tools you can use to make these specs even more expressive, but we're
13 | # sticking to rails and rspec-rails APIs to keep things simple and stable.
14 |
15 | RSpec.describe '/groups', type: :request do
16 | # This should return the minimal set of attributes required to create a valid
17 | # Group. As you add validations to Group, be sure to
18 | # adjust the attributes here as well.
19 | before do
20 | @user = User.create(name: 'Samantha Woods', email: 'sam@outlook.com', password: 'password',
21 | password_confirmation: 'password')
22 | @group = Group.create(name: 'Pets', icon: 'pet_img', user: @user)
23 | sign_in @user
24 | end
25 | describe 'GET /index' do
26 | it 'returns http success' do
27 | get groups_path
28 | expect(response).to have_http_status(302)
29 | end
30 | end
31 |
32 | describe 'GET /show' do
33 | it 'returns http success' do
34 | get group_path(@group.id)
35 | expect(response).to have_http_status(302)
36 | end
37 | end
38 |
39 | describe 'GET /new' do
40 | it 'renders a successful response' do
41 | get new_group_path
42 | expect(response).to have_http_status(302)
43 | end
44 | end
45 | end
46 |
--------------------------------------------------------------------------------
/.github/workflows/linters.yml:
--------------------------------------------------------------------------------
1 | name: Linters
2 |
3 | on: pull_request
4 |
5 | env:
6 | FORCE_COLOR: 1
7 |
8 | jobs:
9 | rubocop:
10 | name: Rubocop
11 | runs-on: ubuntu-22.04
12 | steps:
13 | - uses: actions/checkout@v2
14 | - uses: actions/setup-ruby@v1
15 | with:
16 | ruby-version: 3.1.x
17 | - name: Setup Rubocop
18 | run: |
19 | gem install --no-document rubocop -v '>= 1.0, < 2.0' # https://docs.rubocop.org/en/stable/installation/
20 | [ -f .rubocop.yml ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ror/.rubocop.yml
21 | - name: Rubocop Report
22 | run: rubocop --color
23 | stylelint:
24 | name: Stylelint
25 | runs-on: ubuntu-22.04
26 | steps:
27 | - uses: actions/checkout@v2
28 | - uses: actions/setup-node@v1
29 | with:
30 | node-version: "12.x"
31 | - name: Setup Stylelint
32 | run: |
33 | npm install --save-dev stylelint@13.x stylelint-scss@3.x stylelint-config-standard@21.x stylelint-csstree-validator@1.x
34 | [ -f .stylelintrc.json ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ror/.stylelintrc.json
35 | - name: Stylelint Report
36 | run: npx stylelint "**/*.{css,scss}"
37 | nodechecker:
38 | name: node_modules checker
39 | runs-on: ubuntu-22.04
40 | steps:
41 | - uses: actions/checkout@v2
42 | - name: Check node_modules existence
43 | run: |
44 | if [ -d "node_modules/" ]; then echo -e "\e[1;31mThe node_modules/ folder was pushed to the repo. Please remove it from the GitHub repository and try again."; echo -e "\e[1;32mYou can set up a .gitignore file with this folder included on it to prevent this from happening in the future." && exit 1; fi
--------------------------------------------------------------------------------
/public/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | We're sorry, but something went wrong (500)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
We're sorry, but something went wrong.
62 |
63 |
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/db/migrate/20221121225119_add_devise_columns_to_user.rb:
--------------------------------------------------------------------------------
1 | class AddDeviseColumnsToUser < ActiveRecord::Migration[7.0]
2 | def self.up
3 | change_table :users do |t|
4 | ## Database authenticatable
5 | t.string :email, null: false, default: ""
6 | t.string :encrypted_password, null: false, default: ""
7 |
8 | ## Recoverable
9 | t.string :reset_password_token
10 | t.datetime :reset_password_sent_at
11 |
12 | ## Rememberable
13 | t.datetime :remember_created_at
14 |
15 | ## Trackable
16 | # t.integer :sign_in_count, default: 0, null: false
17 | # t.datetime :current_sign_in_at
18 | # t.datetime :last_sign_in_at
19 | # t.string :current_sign_in_ip
20 | # t.string :last_sign_in_ip
21 |
22 | ## Confirmable
23 | t.string :confirmation_token
24 | t.datetime :confirmed_at
25 | t.datetime :confirmation_sent_at
26 | t.string :unconfirmed_email # Only if using reconfirmable
27 |
28 | ## Lockable
29 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
30 | # t.string :unlock_token # Only if unlock strategy is :email or :both
31 | # t.datetime :locked_at
32 |
33 |
34 | # Uncomment below if timestamps were not included in your original model.
35 | # t.timestamps null: false
36 | end
37 |
38 | add_index :users, :email, unique: true
39 | add_index :users, :reset_password_token, unique: true
40 | add_index :users, :confirmation_token, unique: true
41 | # add_index :users, :unlock_token, unique: true
42 | end
43 |
44 | def self.down
45 | # By default, we don't want to make any assumption about how to roll back a migration when your
46 | # model already existed. Please edit below which fields you would like to remove in this migration.
47 | raise ActiveRecord::IrreversibleMigration
48 | end
49 | end
50 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Puma can serve each request in a thread from an internal thread pool.
4 | # The `threads` method setting takes two numbers: a minimum and maximum.
5 | # Any libraries that use thread pools should be configured to match
6 | # the maximum value specified for Puma. Default is set to 5 threads for minimum
7 | # and maximum; this matches the default thread size of Active Record.
8 | #
9 | max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
10 | min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
11 | threads min_threads_count, max_threads_count
12 |
13 | # Specifies the `worker_timeout` threshold that Puma will use to wait before
14 | # terminating a worker in development environments.
15 | #
16 | worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development'
17 |
18 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
19 | #
20 | port ENV.fetch('PORT', 3000)
21 |
22 | # Specifies the `environment` that Puma will run in.
23 | #
24 | environment ENV.fetch('RAILS_ENV', 'development')
25 |
26 | # Specifies the `pidfile` that Puma will use.
27 | pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid')
28 |
29 | # Specifies the number of `workers` to boot in clustered mode.
30 | # Workers are forked web server processes. If using threads and workers together
31 | # the concurrency of the application would be max `threads` * `workers`.
32 | # Workers do not work on JRuby or Windows (both of which do not support
33 | # processes).
34 | #
35 | workers ENV.fetch("WEB_CONCURRENCY") { 4 }
36 |
37 | # Use the `preload_app!` method when specifying a `workers` number.
38 | # This directive tells Puma to first boot the application and load code
39 | # before forking the application. This takes advantage of Copy On Write
40 | # process behavior so workers use less memory.
41 | #
42 | preload_app!
43 |
44 | # Allow puma to be restarted by `bin/rails restart` command.
45 | plugin :tmp_restart
46 |
--------------------------------------------------------------------------------
/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The change you wanted was rejected (422)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The change you wanted was rejected.
62 |
Maybe you tried to change something you didn't have access to.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
35 | <%= f.label :current_password %> (we need your current password to confirm your changes)
36 | <%= f.password_field :current_password, autocomplete: "current-password", placeholder: "Current password", class: 'input-field' %>
37 |
38 |
39 |
40 |
41 |
42 | <% end %>
43 |
44 |
Cancel my account
45 |
46 |
Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>
47 |
48 |
--------------------------------------------------------------------------------
/app/controllers/users_controller.rb:
--------------------------------------------------------------------------------
1 | class UsersController < ApplicationController
2 | before_action :set_user, only: %i[show edit update destroy]
3 |
4 | # GET /users or /users.json
5 | def index
6 | @users = User.all
7 | end
8 |
9 | # GET /users/1 or /users/1.json
10 | def show; end
11 |
12 | # GET /users/new
13 | def new
14 | @user = User.new
15 | end
16 |
17 | # GET /users/1/edit
18 | def edit; end
19 |
20 | # POST /users or /users.json
21 | def create
22 | @user = User.new(user_params)
23 |
24 | respond_to do |format|
25 | if @user.save
26 | format.html { redirect_to user_url(@user), notice: 'User was successfully created.' }
27 | format.json { render :show, status: :created, location: @user }
28 | else
29 | format.html { render :new, status: :unprocessable_entity }
30 | format.json { render json: @user.errors, status: :unprocessable_entity }
31 | end
32 | end
33 | end
34 |
35 | # PATCH/PUT /users/1 or /users/1.json
36 | def update
37 | respond_to do |format|
38 | if @user.update(user_params)
39 | format.html { redirect_to user_url(@user), notice: 'User was successfully updated.' }
40 | format.json { render :show, status: :ok, location: @user }
41 | else
42 | format.html { render :edit, status: :unprocessable_entity }
43 | format.json { render json: @user.errors, status: :unprocessable_entity }
44 | end
45 | end
46 | end
47 |
48 | # DELETE /users/1 or /users/1.json
49 | def destroy
50 | @user.destroy
51 |
52 | respond_to do |format|
53 | format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }
54 | format.json { head :no_content }
55 | end
56 | end
57 |
58 | private
59 |
60 | # Use callbacks to share common setup or constraints between actions.
61 | def set_user
62 | @user = User.find(params[:id])
63 | end
64 |
65 | # Only allow a list of trusted parameters through.
66 | def user_params
67 | params.require(:user).permit(:name)
68 | end
69 | end
70 |
--------------------------------------------------------------------------------
/app/controllers/groups_controller.rb:
--------------------------------------------------------------------------------
1 | class GroupsController < ApplicationController
2 | before_action :set_group, only: %i[show edit update destroy]
3 |
4 | # GET /groups or /groups.json
5 | def index
6 | @groups = current_user.groups.order(created_at: :desc)
7 | @title = 'Categories'
8 | end
9 |
10 | # GET /groups/1 or /groups/1.json
11 | def show; end
12 |
13 | # GET /groups/new
14 | def new
15 | @group = Group.new
16 | @title = 'New category'
17 | end
18 |
19 | # GET /groups/1/edit
20 | def edit; end
21 |
22 | # POST /groups or /groups.json
23 | def create
24 | @group = Group.new(group_params)
25 | @group.user = current_user
26 | respond_to do |format|
27 | if @group.save
28 | format.html { redirect_to groups_path, notice: "Category #{@group.name} was successfully created." }
29 | format.json { render :show, status: :created, location: @group }
30 | else
31 | format.html { render :new, status: :unprocessable_entity }
32 | format.json { render json: @group.errors, status: :unprocessable_entity }
33 | end
34 | end
35 | end
36 |
37 | # PATCH/PUT /groups/1 or /groups/1.json
38 | def update
39 | respond_to do |format|
40 | if @group.update(group_params)
41 | format.html { redirect_to group_url(@group), notice: 'Group was successfully updated.' }
42 | format.json { render :show, status: :ok, location: @group }
43 | else
44 | format.html { render :edit, status: :unprocessable_entity }
45 | format.json { render json: @group.errors, status: :unprocessable_entity }
46 | end
47 | end
48 | end
49 |
50 | # DELETE /groups/1 or /groups/1.json
51 | def destroy
52 | @group.destroy
53 |
54 | respond_to do |format|
55 | format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }
56 | format.json { head :no_content }
57 | end
58 | end
59 |
60 | private
61 |
62 | # Use callbacks to share common setup or constraints between actions.
63 | def set_group
64 | @group = Group.find(params[:id])
65 | end
66 |
67 | # Only allow a list of trusted parameters through.
68 | def group_params
69 | params.require(:group).permit(:icon, :name)
70 | end
71 | end
72 |
--------------------------------------------------------------------------------
/app/controllers/spends_controller.rb:
--------------------------------------------------------------------------------
1 | class SpendsController < ApplicationController
2 | before_action :set_spend, only: %i[show edit update destroy]
3 | before_action :set_group, only: %i[index new]
4 |
5 | # GET /spends or /spends.json
6 | def index
7 | @spends = @group.spends.order(created_at: :desc)
8 | @title = @group.name
9 | end
10 |
11 | # GET /spends/1 or /spends/1.json
12 | def show; end
13 |
14 | # GET /spends/new
15 | def new
16 | @spend = Spend.new
17 | @title = 'New Transaction'
18 | @spend.groups << @group
19 | @groups = current_user.groups
20 | end
21 |
22 | # GET /spends/1/edit
23 | def edit; end
24 |
25 | # POST /spends or /spends.json
26 | def create
27 | @spend = Spend.new(spend_params)
28 | @spend.author = current_user
29 | respond_to do |format|
30 | if @spend.save
31 | format.html { redirect_to group_spends_path, notice: "Transaction #{@spend.name} was successfully created." }
32 | format.json { render :show, status: :created, location: @spend }
33 | else
34 | @group = Group.find(params[:group_id])
35 | @groups = current_user.groups
36 | format.html { render :new, status: :unprocessable_entity }
37 | format.json { render json: @spend.errors, status: :unprocessable_entity }
38 | end
39 | end
40 | end
41 |
42 | # PATCH/PUT /spends/1 or /spends/1.json
43 | def update
44 | respond_to do |format|
45 | if @spend.update(spend_params)
46 | format.html { redirect_to spend_url(@spend), notice: 'Spend was successfully updated.' }
47 | format.json { render :show, status: :ok, location: @spend }
48 | else
49 | format.html { render :edit, status: :unprocessable_entity }
50 | format.json { render json: @spend.errors, status: :unprocessable_entity }
51 | end
52 | end
53 | end
54 |
55 | # DELETE /spends/1 or /spends/1.json
56 | def destroy
57 | @spend.destroy
58 |
59 | respond_to do |format|
60 | format.html { redirect_to spends_url, notice: 'Spend was successfully destroyed.' }
61 | format.json { head :no_content }
62 | end
63 | end
64 |
65 | private
66 |
67 | # Use callbacks to share common setup or constraints between actions.
68 | def set_spend
69 | @spend = Spend.find(params[:id])
70 | end
71 |
72 | def set_group
73 | @group = Group.find(params[:group_id])
74 | end
75 |
76 | # Only allow a list of trusted parameters through.
77 | def spend_params
78 | params.require(:spend).permit(:name, :amount, group_ids: [])
79 | end
80 | end
81 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # This file is auto-generated from the current state of the database. Instead
2 | # of editing this file, please use the migrations feature of Active Record to
3 | # incrementally modify your database, and then regenerate this schema definition.
4 | #
5 | # This file is the source Rails uses to define your schema when running `bin/rails
6 | # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7 | # be faster and is potentially less error prone than running all of your
8 | # migrations from scratch. Old migrations may fail to apply correctly if those
9 | # migrations use external dependencies or application code.
10 | #
11 | # It's strongly recommended that you check this file into your version control system.
12 |
13 | ActiveRecord::Schema[7.0].define(version: 2022_11_21_225119) do
14 | # These are extensions that must be enabled in order to support this database
15 | enable_extension "plpgsql"
16 |
17 | create_table "groups", force: :cascade do |t|
18 | t.string "icon"
19 | t.string "name"
20 | t.datetime "created_at", null: false
21 | t.datetime "updated_at", null: false
22 | t.bigint "user_id", null: false
23 | t.index ["user_id"], name: "index_groups_on_user_id"
24 | end
25 |
26 | create_table "groups_spends", id: false, force: :cascade do |t|
27 | t.bigint "group_id", null: false
28 | t.bigint "spend_id", null: false
29 | end
30 |
31 | create_table "spends", force: :cascade do |t|
32 | t.string "name"
33 | t.decimal "amount", default: "0.0"
34 | t.datetime "created_at", null: false
35 | t.datetime "updated_at", null: false
36 | t.bigint "author_id", null: false
37 | t.index ["author_id"], name: "index_spends_on_author_id"
38 | end
39 |
40 | create_table "users", force: :cascade do |t|
41 | t.string "name"
42 | t.datetime "created_at", null: false
43 | t.datetime "updated_at", null: false
44 | t.string "email", default: "", null: false
45 | t.string "encrypted_password", default: "", null: false
46 | t.string "reset_password_token"
47 | t.datetime "reset_password_sent_at"
48 | t.datetime "remember_created_at"
49 | t.string "confirmation_token"
50 | t.datetime "confirmed_at"
51 | t.datetime "confirmation_sent_at"
52 | t.string "unconfirmed_email"
53 | t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
54 | t.index ["email"], name: "index_users_on_email", unique: true
55 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
56 | end
57 |
58 | add_foreign_key "groups", "users"
59 | add_foreign_key "spends", "users", column: "author_id"
60 | end
61 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'active_support/core_ext/integer/time'
4 |
5 | # The test environment is used exclusively to run your application's
6 | # test suite. You never need to work with it otherwise. Remember that
7 | # your test database is "scratch space" for the test suite and is wiped
8 | # and recreated between test runs. Don't rely on the data there!
9 |
10 | Rails.application.configure do
11 | # Settings specified here will take precedence over those in config/application.rb.
12 |
13 | # Turn false under Spring and add config.action_view.cache_template_loading = true.
14 | config.cache_classes = true
15 |
16 | # Eager loading loads your whole application. When running a single test locally,
17 | # this probably isn't necessary. It's a good idea to do in a continuous integration
18 | # system, or in some way before deploying your code.
19 | config.eager_load = ENV['CI'].present?
20 |
21 | # Configure public file server for tests with Cache-Control for performance.
22 | config.public_file_server.enabled = true
23 | config.public_file_server.headers = {
24 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
25 | }
26 |
27 | # Show full error reports and disable caching.
28 | config.consider_all_requests_local = true
29 | config.action_controller.perform_caching = false
30 | config.cache_store = :null_store
31 |
32 | # Raise exceptions instead of rendering exception templates.
33 | config.action_dispatch.show_exceptions = false
34 |
35 | # Disable request forgery protection in test environment.
36 | config.action_controller.allow_forgery_protection = false
37 |
38 | # Store uploaded files on the local file system in a temporary directory.
39 | config.active_storage.service = :test
40 |
41 | config.action_mailer.perform_caching = false
42 |
43 | # Tell Action Mailer not to deliver emails to the real world.
44 | # The :test delivery method accumulates sent emails in the
45 | # ActionMailer::Base.deliveries array.
46 | config.action_mailer.delivery_method = :test
47 |
48 | # Print deprecation notices to the stderr.
49 | config.active_support.deprecation = :stderr
50 |
51 | # Raise exceptions for disallowed deprecations.
52 | config.active_support.disallowed_deprecation = :raise
53 |
54 | # Tell Active Support which deprecation messages to disallow.
55 | config.active_support.disallowed_deprecation_warnings = []
56 |
57 | # Raises error for missing translations.
58 | # config.i18n.raise_on_missing_translations = true
59 |
60 | # Annotate rendered view with file names.
61 | # config.action_view.annotate_rendered_view_with_filenames = true
62 | config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
63 | end
64 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3 |
4 | ruby '3.1.2'
5 |
6 | # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
7 | gem 'rails', '~> 7.0.4'
8 |
9 | # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
10 | gem 'sprockets-rails'
11 |
12 | # Use the devise gem as the session and account manager for the application
13 | gem 'devise'
14 |
15 | # Use postgresql as the database for Active Record
16 | gem 'pg', '~> 1.1'
17 |
18 | # Use the Puma web server [https://github.com/puma/puma]
19 | gem 'puma', '~> 5.0'
20 |
21 | # Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
22 | gem 'importmap-rails'
23 |
24 | # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
25 | gem 'turbo-rails'
26 |
27 | # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
28 | gem 'stimulus-rails'
29 |
30 | # Build JSON APIs with ease [https://github.com/rails/jbuilder]
31 | gem 'jbuilder'
32 |
33 | # Use for faking data
34 | gem 'faker'
35 |
36 | # Use Redis adapter to run Action Cable in production
37 | # gem "redis", "~> 4.0"
38 |
39 | # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
40 | # gem "kredis"
41 |
42 | # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
43 | # gem "bcrypt", "~> 3.1.7"
44 |
45 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
46 | gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
47 |
48 | # Reduces boot times through caching; required in config/boot.rb
49 | gem 'bootsnap', require: false
50 |
51 | # Use Sass to process CSS
52 | # gem "sassc-rails"
53 |
54 | # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
55 | # gem "image_processing", "~> 1.2"
56 |
57 | # Use to automatically loads environment variables from a .env file into the process.env object
58 | gem 'dotenv-rails'
59 |
60 | # Use for restricting what resources a given user is allowed to access
61 | gem 'cancancan'
62 |
63 | group :development, :test do
64 | # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
65 | gem 'database_cleaner'
66 | gem 'debug', platforms: %i[mri mingw x64_mingw]
67 | gem 'ffi'
68 | gem 'rails-controller-testing'
69 | gem 'rspec-rails'
70 | end
71 |
72 | group :development do
73 | # Use console on exceptions pages [https://github.com/rails/web-console]
74 | gem 'web-console'
75 | # Bullet for check N+1 problems
76 | gem 'bullet', require: true
77 | # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
78 | # gem "rack-mini-profiler"
79 |
80 | # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
81 | # gem "spring"
82 | # gem "spring"
83 | end
84 |
85 | group :test do
86 | # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
87 | gem 'capybara'
88 | gem 'selenium-webdriver'
89 | gem 'webdrivers'
90 | end
91 |
92 | gem 'tailwindcss-rails', '~> 2.0'
93 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'active_support/core_ext/integer/time'
4 |
5 | Rails.application.configure do
6 | config.after_initialize do
7 | Bullet.enable = true
8 | Bullet.alert = true
9 | Bullet.bullet_logger = true
10 | Bullet.console = true
11 | Bullet.rails_logger = true
12 | Bullet.add_footer = true
13 | end
14 |
15 | # Settings specified here will take precedence over those in config/application.rb.
16 |
17 | # In the development environment your application's code is reloaded any time
18 | # it changes. This slows down response time but is perfect for development
19 | # since you don't have to restart the web server when you make code changes.
20 | config.cache_classes = false
21 |
22 | # Do not eager load code on boot.
23 | config.eager_load = false
24 |
25 | # Show full error reports.
26 | config.consider_all_requests_local = true
27 |
28 | # Enable server timing
29 | config.server_timing = true
30 |
31 | # Enable/disable caching. By default caching is disabled.
32 | # Run rails dev:cache to toggle caching.
33 | if Rails.root.join('tmp/caching-dev.txt').exist?
34 | config.action_controller.perform_caching = true
35 | config.action_controller.enable_fragment_cache_logging = true
36 |
37 | config.cache_store = :memory_store
38 | config.public_file_server.headers = {
39 | 'Cache-Control' => "public, max-age=#{2.days.to_i}"
40 | }
41 | else
42 | config.action_controller.perform_caching = false
43 |
44 | config.cache_store = :null_store
45 | end
46 |
47 | # Store uploaded files on the local file system (see config/storage.yml for options).
48 | config.active_storage.service = :local
49 |
50 | # Don't care if the mailer can't send.
51 | config.action_mailer.raise_delivery_errors = false
52 |
53 | config.action_mailer.perform_caching = false
54 |
55 | # config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
56 |
57 | # config.action_mailer.delivery_method = :letter_opener
58 |
59 | # config.action_mailer.perform_deliveries = true
60 |
61 | # Print deprecation notices to the Rails logger.
62 | config.active_support.deprecation = :log
63 |
64 | # Raise exceptions for disallowed deprecations.
65 | config.active_support.disallowed_deprecation = :raise
66 |
67 | # Tell Active Support which deprecation messages to disallow.
68 | config.active_support.disallowed_deprecation_warnings = []
69 |
70 | # Raise an error on page load if there are pending migrations.
71 | config.active_record.migration_error = :page_load
72 |
73 | # Highlight code that triggered database queries in logs.
74 | config.active_record.verbose_query_logs = true
75 |
76 | # Suppress logger output for asset requests.
77 | config.assets.quiet = true
78 |
79 | # Raises error for missing translations.
80 | # config.i18n.raise_on_missing_translations = true
81 |
82 | # Annotate rendered view with file names.
83 | # config.action_view.annotate_rendered_view_with_filenames = true
84 |
85 | # Uncomment if you wish to allow Action Cable access from any origin.
86 | # config.action_cable.disable_request_forgery_protection = true
87 | end
88 |
--------------------------------------------------------------------------------
/spec/rails_helper.rb:
--------------------------------------------------------------------------------
1 | # This file is copied to spec/ when you run 'rails generate rspec:install'
2 | require 'spec_helper'
3 | require 'capybara/rspec'
4 | ENV['RAILS_ENV'] ||= 'test'
5 | require_relative '../config/environment'
6 | # Prevent database truncation if the environment is production
7 | abort('The Rails environment is running in production mode!') if Rails.env.production?
8 | require 'rspec/rails'
9 | # Add additional requires below this line. Rails is not loaded until this point!
10 |
11 | # Requires supporting ruby files with custom matchers and macros, etc, in
12 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
13 | # run as spec files by default. This means that files in spec/support that end
14 | # in _spec.rb will both be required and run as specs, causing the specs to be
15 | # run twice. It is recommended that you do not name files matching this glob to
16 | # end with _spec.rb. You can configure this pattern with the --pattern
17 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
18 | #
19 | # The following line is provided for convenience purposes. It has the downside
20 | # of increasing the boot-up time by auto-requiring all files in the support
21 | # directory. Alternatively, in the individual `*_spec.rb` files, manually
22 | # require only the support files necessary.
23 | #
24 | # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
25 |
26 | # Checks for pending migrations and applies them before tests are run.
27 | # If you are not using ActiveRecord, you can remove these lines.
28 | begin
29 | ActiveRecord::Migration.maintain_test_schema!
30 | rescue ActiveRecord::PendingMigrationError => e
31 | abort e.to_s.strip
32 | end
33 | RSpec.configure do |config|
34 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
35 | config.fixture_path = "#{::Rails.root}/spec/fixtures"
36 |
37 | # If you're not using ActiveRecord, or you'd prefer not to run each of your
38 | # examples within a transaction, remove the following line or assign false
39 | # instead of true.
40 | config.use_transactional_fixtures = true
41 |
42 | # You can uncomment this line to turn off ActiveRecord support entirely.
43 | # config.use_active_record = false
44 |
45 | # RSpec Rails can automatically mix in different behaviours to your tests
46 | # based on their file location, for example enabling you to call `get` and
47 | # `post` in specs under `spec/controllers`.
48 | #
49 | # You can disable this behaviour by removing the line below, and instead
50 | # explicitly tag your specs with their type, e.g.:
51 | #
52 | # RSpec.describe UsersController, type: :controller do
53 | # # ...
54 | # end
55 | #
56 | # The different available types are documented in the features, such as in
57 | # https://relishapp.com/rspec/rspec-rails/docs
58 | config.infer_spec_type_from_file_location!
59 |
60 | # Filter lines from Rails gems in backtraces.
61 | config.filter_rails_from_backtrace!
62 | # arbitrary gems may also be filtered via:
63 | # config.filter_gems_from_backtrace("gem name")
64 | config.include Devise::Test::IntegrationHelpers, type: :feature
65 | config.include Devise::Test::IntegrationHelpers, type: :request
66 | end
67 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # PostgreSQL. Versions 9.3 and up are supported.
2 | #
3 | # Install the pg driver:
4 | # gem install pg
5 | # On macOS with Homebrew:
6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7 | # On macOS with MacPorts:
8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9 | # On Windows:
10 | # gem install pg
11 | # Choose the win32 build.
12 | # Install PostgreSQL and put its /bin directory on your path.
13 | #
14 | # Configure Using Gemfile
15 | # gem "pg"
16 | #
17 | default: &default
18 | adapter: postgresql
19 | encoding: unicode
20 | # For details on connection pooling, see Rails configuration guide
21 | # https://guides.rubyonrails.org/configuring.html#database-pooling
22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23 | host: <%= ENV['POSTGRES_HOST'] %>
24 | username: <%= POSTGRES_USER='postgres' %>
25 | password: <%= POSTGRES_PASSWORD='12345' %>
26 | port: 5432
27 |
28 | development:
29 | <<: *default
30 | database: money_moves_development
31 |
32 | # The specified database role being used to connect to postgres.
33 | # To create additional roles in postgres see `$ createuser --help`.
34 | # When left blank, postgres will use the default role. This is
35 | # the same name as the operating system user running Rails.
36 | #username: newProject
37 |
38 | # The password associated with the postgres role (username).
39 | #password:
40 |
41 | # Connect on a TCP socket. Omitted by default since the client uses a
42 | # domain socket that doesn't need configuration. Windows does not have
43 | # domain sockets, so uncomment these lines.
44 | #host: localhost
45 |
46 | # The TCP port the server listens on. Defaults to 5432.
47 | # If your server runs on a different port number, change accordingly.
48 | #port: 5432
49 |
50 | # Schema search path. The server defaults to $user,public
51 | #schema_search_path: myapp,sharedapp,public
52 |
53 | # Minimum log levels, in increasing order:
54 | # debug5, debug4, debug3, debug2, debug1,
55 | # log, notice, warning, error, fatal, and panic
56 | # Defaults to warning.
57 | #min_messages: notice
58 |
59 | # Warning: The database defined as "test" will be erased and
60 | # re-generated from your development database when you run "rake".
61 | # Do not set this db to the same as development or production.
62 | test:
63 | <<: *default
64 | database: money_moves_test
65 |
66 | # As with config/credentials.yml, you never want to store sensitive information,
67 | # like your database password, in your source code. If your source code is
68 | # ever seen by anyone, they now have access to your database.
69 | #
70 | # Instead, provide the password or a full connection URL as an environment
71 | # variable when you boot the app. For example:
72 | #
73 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
74 | #
75 | # If the connection URL is provided in the special DATABASE_URL environment
76 | # variable, Rails will automatically merge its configuration values on top of
77 | # the values provided in this file. Alternatively, you can specify a connection
78 | # URL environment variable explicitly:
79 | #
80 | # production:
81 | # url: <%= ENV["MY_APP_DATABASE_URL"] %>
82 | #
83 | # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
84 | # for a full overview on how database connection configuration can be specified.
85 | #
86 | production:
87 | <<: *default
88 | url: <%= ENV['DATABASE_URL'] %>
89 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'bundle' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require 'rubygems'
12 |
13 | m = Module.new do
14 | module_function
15 |
16 | def invoked_as_script?
17 | File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__)
18 | end
19 |
20 | def env_var_version
21 | ENV['BUNDLER_VERSION']
22 | end
23 |
24 | def cli_arg_version
25 | return unless invoked_as_script? # don't want to hijack other binstubs
26 | return unless 'update'.start_with?(ARGV.first || ' ') # must be running `bundle update`
27 |
28 | bundler_version = nil
29 | update_index = nil
30 | ARGV.each_with_index do |a, i|
31 | bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
32 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
33 |
34 | bundler_version = Regexp.last_match(1)
35 | update_index = i
36 | end
37 | bundler_version
38 | end
39 |
40 | def gemfile
41 | gemfile = ENV['BUNDLE_GEMFILE']
42 | return gemfile if gemfile && !gemfile.empty?
43 |
44 | File.expand_path('../Gemfile', __dir__)
45 | end
46 |
47 | def lockfile
48 | lockfile =
49 | case File.basename(gemfile)
50 | when 'gems.rb' then gemfile.sub(/\.rb$/, gemfile)
51 | else "#{gemfile}.lock"
52 | end
53 | File.expand_path(lockfile)
54 | end
55 |
56 | def lockfile_version
57 | return unless File.file?(lockfile)
58 |
59 | lockfile_contents = File.read(lockfile)
60 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
61 |
62 | Regexp.last_match(1)
63 | end
64 |
65 | def bundler_requirement
66 | @bundler_requirement ||=
67 | env_var_version || cli_arg_version ||
68 | bundler_requirement_for(lockfile_version)
69 | end
70 |
71 | def bundler_requirement_for(version)
72 | return "#{Gem::Requirement.default}.a" unless version
73 |
74 | bundler_gem_version = Gem::Version.new(version)
75 |
76 | requirement = bundler_gem_version.approximate_recommendation
77 |
78 | return requirement unless Gem.rubygems_version < Gem::Version.new('2.7.0')
79 |
80 | requirement += '.a' if bundler_gem_version.prerelease?
81 |
82 | requirement
83 | end
84 |
85 | def load_bundler!
86 | ENV['BUNDLE_GEMFILE'] ||= gemfile
87 |
88 | activate_bundler
89 | end
90 |
91 | def activate_bundler
92 | gem_error = activation_error_handling do
93 | gem 'bundler', bundler_requirement
94 | end
95 | return if gem_error.nil?
96 |
97 | require_error = activation_error_handling do
98 | require 'bundler/version'
99 | end
100 | if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
101 | return
102 | end
103 |
104 | warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
105 | exit 42
106 | end
107 |
108 | def activation_error_handling
109 | yield
110 | nil
111 | rescue StandardError, LoadError => e
112 | e
113 | end
114 | end
115 |
116 | m.load_bundler!
117 |
118 | load Gem.bin_path('bundler', 'bundle') if m.invoked_as_script?
119 |
--------------------------------------------------------------------------------
/bin/bundle.cmd:
--------------------------------------------------------------------------------
1 | @ruby -x "%~f0" %*
2 | @exit /b %ERRORLEVEL%
3 |
4 | #!/usr/bin/env ruby
5 | # frozen_string_literal: true
6 |
7 | #
8 | # This file was generated by Bundler.
9 | #
10 | # The application 'bundle' is installed as part of a gem, and
11 | # this file is here to facilitate running it.
12 | #
13 |
14 | require "rubygems"
15 |
16 | m = Module.new do
17 | module_function
18 |
19 | def invoked_as_script?
20 | File.expand_path($0) == File.expand_path(__FILE__)
21 | end
22 |
23 | def env_var_version
24 | ENV["BUNDLER_VERSION"]
25 | end
26 |
27 | def cli_arg_version
28 | return unless invoked_as_script? # don't want to hijack other binstubs
29 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
30 | bundler_version = nil
31 | update_index = nil
32 | ARGV.each_with_index do |a, i|
33 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
34 | bundler_version = a
35 | end
36 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
37 | bundler_version = $1
38 | update_index = i
39 | end
40 | bundler_version
41 | end
42 |
43 | def gemfile
44 | gemfile = ENV["BUNDLE_GEMFILE"]
45 | return gemfile if gemfile && !gemfile.empty?
46 |
47 | File.expand_path("../Gemfile", __dir__)
48 | end
49 |
50 | def lockfile
51 | lockfile =
52 | case File.basename(gemfile)
53 | when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
54 | else "#{gemfile}.lock"
55 | end
56 | File.expand_path(lockfile)
57 | end
58 |
59 | def lockfile_version
60 | return unless File.file?(lockfile)
61 | lockfile_contents = File.read(lockfile)
62 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
63 | Regexp.last_match(1)
64 | end
65 |
66 | def bundler_requirement
67 | @bundler_requirement ||=
68 | env_var_version || cli_arg_version ||
69 | bundler_requirement_for(lockfile_version)
70 | end
71 |
72 | def bundler_requirement_for(version)
73 | return "#{Gem::Requirement.default}.a" unless version
74 |
75 | bundler_gem_version = Gem::Version.new(version)
76 |
77 | requirement = bundler_gem_version.approximate_recommendation
78 |
79 | return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0")
80 |
81 | requirement += ".a" if bundler_gem_version.prerelease?
82 |
83 | requirement
84 | end
85 |
86 | def load_bundler!
87 | ENV["BUNDLE_GEMFILE"] ||= gemfile
88 |
89 | activate_bundler
90 | end
91 |
92 | def activate_bundler
93 | gem_error = activation_error_handling do
94 | gem "bundler", bundler_requirement
95 | end
96 | return if gem_error.nil?
97 | require_error = activation_error_handling do
98 | require "bundler/version"
99 | end
100 | return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
101 | warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
102 | exit 42
103 | end
104 |
105 | def activation_error_handling
106 | yield
107 | nil
108 | rescue StandardError, LoadError => e
109 | e
110 | end
111 | end
112 |
113 | m.load_bundler!
114 |
115 | if m.invoked_as_script?
116 | load Gem.bin_path("bundler", "bundle")
117 | end
118 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'active_support/core_ext/integer/time'
4 |
5 | Rails.application.configure do
6 | # Settings specified here will take precedence over those in config/application.rb.
7 |
8 | # Code is not reloaded between requests.
9 | config.cache_classes = true
10 |
11 | # Eager load code on boot. This eager loads most of Rails and
12 | # your application in memory, allowing both threaded web servers
13 | # and those relying on copy on write to perform better.
14 | # Rake tasks automatically ignore this option for performance.
15 | config.eager_load = true
16 |
17 | # Full error reports are disabled and caching is turned on.
18 | config.consider_all_requests_local = false
19 | config.action_controller.perform_caching = true
20 |
21 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
22 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
23 | # config.require_master_key = true
24 |
25 | # Disable serving static files from the `/public` folder by default since
26 | # Apache or NGINX already handles this.
27 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? || ENV['RENDER'].present?
28 |
29 | # Compress CSS using a preprocessor.
30 | # config.assets.css_compressor = :sass
31 | config.assets.css_compressor = nil
32 |
33 | # Do not fallback to assets pipeline if a precompiled asset is missed.
34 | config.assets.compile = false
35 |
36 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
37 | # config.asset_host = "http://assets.example.com"
38 |
39 | # Specifies the header that your server uses for sending files.
40 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
41 | # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
42 |
43 | # Store uploaded files on the local file system (see config/storage.yml for options).
44 | config.active_storage.service = :local
45 |
46 | # Mount Action Cable outside main process or domain.
47 | # config.action_cable.mount_path = nil
48 | # config.action_cable.url = "wss://example.com/cable"
49 | # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
50 |
51 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
52 | # config.force_ssl = true
53 |
54 | # Include generic and useful information about system operation, but avoid logging too much
55 | # information to avoid inadvertent exposure of personally identifiable information (PII).
56 | config.log_level = :info
57 |
58 | # Prepend all log lines with the following tags.
59 | config.log_tags = [:request_id]
60 |
61 | # Use a different cache store in production.
62 | # config.cache_store = :mem_cache_store
63 |
64 | # Use a real queuing backend for Active Job (and separate queues per environment).
65 | # config.active_job.queue_adapter = :resque
66 | # config.active_job.queue_name_prefix = "money_moves_production"
67 |
68 | config.action_mailer.perform_caching = false
69 |
70 | # Ignore bad email addresses and do not raise email delivery errors.
71 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
72 | # config.action_mailer.raise_delivery_errors = false
73 |
74 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
75 | # the I18n.default_locale when a translation cannot be found).
76 | config.i18n.fallbacks = true
77 |
78 | # Don't log any deprecations.
79 | config.active_support.report_deprecations = false
80 |
81 | # Use default logging formatter so that PID and timestamp are not suppressed.
82 | config.log_formatter = ::Logger::Formatter.new
83 |
84 | # Use a different logger for distributed setups.
85 | # require "syslog/logger"
86 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
87 |
88 | if ENV['RAILS_LOG_TO_STDOUT'].present?
89 | logger = ActiveSupport::Logger.new($stdout)
90 | logger.formatter = config.log_formatter
91 | config.logger = ActiveSupport::TaggedLogging.new(logger)
92 | end
93 |
94 | # Do not dump schema after migrations.
95 | config.active_record.dump_schema_after_migration = false
96 | # config.action_mailer.default_url_options = { host: 'money-moves.onrender.com' }
97 | end
98 |
--------------------------------------------------------------------------------
/config/locales/devise.en.yml:
--------------------------------------------------------------------------------
1 | # Additional translations at https://github.com/heartcombo/devise/wiki/I18n
2 |
3 | en:
4 | devise:
5 | confirmations:
6 | confirmed: "Your email address has been successfully confirmed."
7 | send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8 | send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
9 | failure:
10 | already_authenticated: "You are already signed in."
11 | inactive: "Your account is not activated yet."
12 | invalid: "Invalid %{authentication_keys} or password."
13 | locked: "Your account is locked."
14 | last_attempt: "You have one more attempt before your account is locked."
15 | not_found_in_database: "Invalid %{authentication_keys} or password."
16 | timeout: "Your session expired. Please sign in again to continue."
17 | unauthenticated: "You need to sign in or sign up before continuing."
18 | unconfirmed: "You have to confirm your email address before continuing."
19 | mailer:
20 | confirmation_instructions:
21 | subject: "Confirmation instructions"
22 | reset_password_instructions:
23 | subject: "Reset password instructions"
24 | unlock_instructions:
25 | subject: "Unlock instructions"
26 | email_changed:
27 | subject: "Email Changed"
28 | password_change:
29 | subject: "Password Changed"
30 | omniauth_callbacks:
31 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
32 | success: "Successfully authenticated from %{kind} account."
33 | passwords:
34 | no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
35 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
36 | send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
37 | updated: "Your password has been changed successfully. You are now signed in."
38 | updated_not_active: "Your password has been changed successfully."
39 | registrations:
40 | destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
41 | signed_up: "Welcome! You have signed up successfully."
42 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
43 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
44 | signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
45 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
46 | updated: "Your account has been updated successfully."
47 | updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again."
48 | sessions:
49 | signed_in: "Signed in successfully."
50 | signed_out: "Signed out successfully."
51 | already_signed_out: "Signed out successfully."
52 | unlocks:
53 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
54 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
55 | unlocked: "Your account has been unlocked successfully. Please sign in to continue."
56 | errors:
57 | messages:
58 | already_confirmed: "was already confirmed, please try signing in"
59 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
60 | expired: "has expired, please request a new one"
61 | not_found: "not found"
62 | not_locked: "was not locked"
63 | not_saved:
64 | one: "1 error prohibited this %{resource} from being saved:"
65 | other: "%{count} errors prohibited this %{resource} from being saved:"
66 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3 | # The generated `.rspec` file contains `--require spec_helper` which will cause
4 | # this file to always be loaded, without a need to explicitly require it in any
5 | # files.
6 | #
7 | # Given that it is always loaded, you are encouraged to keep this file as
8 | # light-weight as possible. Requiring heavyweight dependencies from this file
9 | # will add to the boot time of your test suite on EVERY test run, even for an
10 | # individual file that may not need all of that loaded. Instead, consider making
11 | # a separate helper file that requires the additional dependencies and performs
12 | # the additional setup, and require it from the spec files that actually need
13 | # it.
14 | #
15 | # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16 | RSpec.configure do |config|
17 | # rspec-expectations config goes here. You can use an alternate
18 | # assertion/expectation library such as wrong or the stdlib/minitest
19 | # assertions if you prefer.
20 | config.expect_with :rspec do |expectations|
21 | # This option will default to `true` in RSpec 4. It makes the `description`
22 | # and `failure_message` of custom matchers include text for helper methods
23 | # defined using `chain`, e.g.:
24 | # be_bigger_than(2).and_smaller_than(4).description
25 | # # => "be bigger than 2 and smaller than 4"
26 | # ...rather than:
27 | # # => "be bigger than 2"
28 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29 | end
30 |
31 | # rspec-mocks config goes here. You can use an alternate test double
32 | # library (such as bogus or mocha) by changing the `mock_with` option here.
33 | config.mock_with :rspec do |mocks|
34 | # Prevents you from mocking or stubbing a method that does not exist on
35 | # a real object. This is generally recommended, and will default to
36 | # `true` in RSpec 4.
37 | mocks.verify_partial_doubles = true
38 | end
39 |
40 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41 | # have no way to turn it off -- the option exists only for backwards
42 | # compatibility in RSpec 3). It causes shared context metadata to be
43 | # inherited by the metadata hash of host groups and examples, rather than
44 | # triggering implicit auto-inclusion in groups with matching metadata.
45 | config.shared_context_metadata_behavior = :apply_to_host_groups
46 |
47 | # The settings below are suggested to provide a good initial experience
48 | # with RSpec, but feel free to customize to your heart's content.
49 | # # This allows you to limit a spec run to individual examples or groups
50 | # # you care about by tagging them with `:focus` metadata. When nothing
51 | # # is tagged with `:focus`, all examples get run. RSpec also provides
52 | # # aliases for `it`, `describe`, and `context` that include `:focus`
53 | # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
54 | # config.filter_run_when_matching :focus
55 | #
56 | # # Allows RSpec to persist some state between runs in order to support
57 | # # the `--only-failures` and `--next-failure` CLI options. We recommend
58 | # # you configure your source control system to ignore this file.
59 | # config.example_status_persistence_file_path = "spec/examples.txt"
60 | #
61 | # # Limits the available syntax to the non-monkey patched syntax that is
62 | # # recommended. For more details, see:
63 | # # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode
64 | # config.disable_monkey_patching!
65 | #
66 | # # This setting enables warnings. It's recommended, but in some cases may
67 | # # be too noisy due to issues in dependencies.
68 | # config.warnings = true
69 | #
70 | # # Many RSpec users commonly either run the entire suite or an individual
71 | # # file, and it's useful to allow more verbose output when running an
72 | # # individual spec file.
73 | # if config.files_to_run.one?
74 | # # Use the documentation formatter for detailed output,
75 | # # unless a formatter has already been configured
76 | # # (e.g. via a command-line flag).
77 | # config.default_formatter = "doc"
78 | # end
79 | #
80 | # # Print the 10 slowest examples and example groups at the
81 | # # end of the spec run, to help surface which specs are running
82 | # # particularly slow.
83 | # config.profile_examples = 10
84 | #
85 | # # Run specs in random order to surface order dependencies. If you find an
86 | # # order dependency and want to debug it, you can fix the order by providing
87 | # # the seed, which is printed after each run.
88 | # # --seed 1234
89 | # config.order = :random
90 | #
91 | # # Seed global randomization in this process using the `--seed` CLI option.
92 | # # Setting this allows you to use `--seed` to deterministically reproduce
93 | # # test failures related to randomization by passing the same `--seed` value
94 | # # as the one that triggered the failure.
95 | # Kernel.srand config.seed
96 | end
97 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
MONEY MOVES
7 |
8 |
9 |
10 |
11 | # 📗 Table of Contents
12 |
13 | - [📖 About the Project](#about-project)
14 | - [🛠 Built With](#built-with)
15 | - [Tech Stack](#tech-stack)
16 | - [Key Features](#key-features)
17 | - [🚀 Live Demo](#live-demo)
18 | - [💻 Getting Started](#getting-started)
19 | - [Setup](#setup)
20 | - [Prerequisites](#prerequisites)
21 | - [Install](#install)
22 | - [Usage](#usage)
23 | - [Run tests](#run-tests)
24 | - [Deployment](#triangular_flag_on_post-deployment)
25 | - [👥 Authors](#authors)
26 | - [🔭 Future Features](#future-features)
27 | - [🤝 Contributing](#contributing)
28 | - [⭐️ Show your support](#support)
29 | - [🙏 Acknowledgements](#acknowledgements)
30 | - [❓ FAQ](#faq)
31 | - [📝 License](#license)
32 |
33 | # 📖 Money moves
34 |
35 | This is a mobile web application, which allows users to control their budgets. The user can divide the budget into different categories and insert the expenses that have been made in the categories.
36 |
37 | ## 🛠 Built With
38 |
39 | ### Tech Stack
40 |
41 |
42 | Client
43 |
60 |
61 |
62 | ### Key Features
63 |
64 | - List all budget's categories.
65 | - List all transactions that belongs to one category.
66 | - Add a new category.
67 | - Add a new transaction.
68 |
69 |
176 |
177 | ## ❓ FAQ
178 |
179 | - Why bin/dev instead of rails server?
180 |
181 | - The commend bin/dev not only start your server, it also builts your Tailwind CSS classes to give the styles.
182 |
183 | - What is current_user?
184 |
185 | - This is a built-in method of Devise which help to get the user who is currently loged in the app.
186 |
187 |
195 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | actioncable (7.0.4)
5 | actionpack (= 7.0.4)
6 | activesupport (= 7.0.4)
7 | nio4r (~> 2.0)
8 | websocket-driver (>= 0.6.1)
9 | actionmailbox (7.0.4)
10 | actionpack (= 7.0.4)
11 | activejob (= 7.0.4)
12 | activerecord (= 7.0.4)
13 | activestorage (= 7.0.4)
14 | activesupport (= 7.0.4)
15 | mail (>= 2.7.1)
16 | net-imap
17 | net-pop
18 | net-smtp
19 | actionmailer (7.0.4)
20 | actionpack (= 7.0.4)
21 | actionview (= 7.0.4)
22 | activejob (= 7.0.4)
23 | activesupport (= 7.0.4)
24 | mail (~> 2.5, >= 2.5.4)
25 | net-imap
26 | net-pop
27 | net-smtp
28 | rails-dom-testing (~> 2.0)
29 | actionpack (7.0.4)
30 | actionview (= 7.0.4)
31 | activesupport (= 7.0.4)
32 | rack (~> 2.0, >= 2.2.0)
33 | rack-test (>= 0.6.3)
34 | rails-dom-testing (~> 2.0)
35 | rails-html-sanitizer (~> 1.0, >= 1.2.0)
36 | actiontext (7.0.4)
37 | actionpack (= 7.0.4)
38 | activerecord (= 7.0.4)
39 | activestorage (= 7.0.4)
40 | activesupport (= 7.0.4)
41 | globalid (>= 0.6.0)
42 | nokogiri (>= 1.8.5)
43 | actionview (7.0.4)
44 | activesupport (= 7.0.4)
45 | builder (~> 3.1)
46 | erubi (~> 1.4)
47 | rails-dom-testing (~> 2.0)
48 | rails-html-sanitizer (~> 1.1, >= 1.2.0)
49 | activejob (7.0.4)
50 | activesupport (= 7.0.4)
51 | globalid (>= 0.3.6)
52 | activemodel (7.0.4)
53 | activesupport (= 7.0.4)
54 | activerecord (7.0.4)
55 | activemodel (= 7.0.4)
56 | activesupport (= 7.0.4)
57 | activestorage (7.0.4)
58 | actionpack (= 7.0.4)
59 | activejob (= 7.0.4)
60 | activerecord (= 7.0.4)
61 | activesupport (= 7.0.4)
62 | marcel (~> 1.0)
63 | mini_mime (>= 1.1.0)
64 | activesupport (7.0.4)
65 | concurrent-ruby (~> 1.0, >= 1.0.2)
66 | i18n (>= 1.6, < 2)
67 | minitest (>= 5.1)
68 | tzinfo (~> 2.0)
69 | addressable (2.8.1)
70 | public_suffix (>= 2.0.2, < 6.0)
71 | bcrypt (3.1.18)
72 | bindex (0.8.1)
73 | bootsnap (1.14.0)
74 | msgpack (~> 1.2)
75 | builder (3.2.4)
76 | bullet (7.0.3)
77 | activesupport (>= 3.0.0)
78 | uniform_notifier (~> 1.11)
79 | cancancan (3.4.0)
80 | capybara (3.38.0)
81 | addressable
82 | matrix
83 | mini_mime (>= 0.1.3)
84 | nokogiri (~> 1.8)
85 | rack (>= 1.6.0)
86 | rack-test (>= 0.6.3)
87 | regexp_parser (>= 1.5, < 3.0)
88 | xpath (~> 3.2)
89 | childprocess (4.1.0)
90 | concurrent-ruby (1.1.10)
91 | crass (1.0.6)
92 | database_cleaner (2.0.1)
93 | database_cleaner-active_record (~> 2.0.0)
94 | database_cleaner-active_record (2.0.1)
95 | activerecord (>= 5.a)
96 | database_cleaner-core (~> 2.0.0)
97 | database_cleaner-core (2.0.1)
98 | debug (1.6.3)
99 | irb (>= 1.3.6)
100 | reline (>= 0.3.1)
101 | devise (4.8.1)
102 | bcrypt (~> 3.0)
103 | orm_adapter (~> 0.1)
104 | railties (>= 4.1.0)
105 | responders
106 | warden (~> 1.2.3)
107 | diff-lcs (1.5.0)
108 | dotenv (2.8.1)
109 | dotenv-rails (2.8.1)
110 | dotenv (= 2.8.1)
111 | railties (>= 3.2)
112 | erubi (1.11.0)
113 | faker (3.0.0)
114 | i18n (>= 1.8.11, < 2)
115 | ffi (1.15.5)
116 | ffi (1.15.5-x64-mingw-ucrt)
117 | globalid (1.0.0)
118 | activesupport (>= 5.0)
119 | i18n (1.12.0)
120 | concurrent-ruby (~> 1.0)
121 | importmap-rails (1.1.5)
122 | actionpack (>= 6.0.0)
123 | railties (>= 6.0.0)
124 | io-console (0.5.11)
125 | irb (1.5.0)
126 | reline (>= 0.3.0)
127 | jbuilder (2.11.5)
128 | actionview (>= 5.0.0)
129 | activesupport (>= 5.0.0)
130 | loofah (2.19.0)
131 | crass (~> 1.0.2)
132 | nokogiri (>= 1.5.9)
133 | mail (2.7.1)
134 | mini_mime (>= 0.1.1)
135 | marcel (1.0.2)
136 | matrix (0.4.2)
137 | method_source (1.0.0)
138 | mini_mime (1.1.2)
139 | minitest (5.16.3)
140 | msgpack (1.6.0)
141 | net-imap (0.3.1)
142 | net-protocol
143 | net-pop (0.1.2)
144 | net-protocol
145 | net-protocol (0.1.3)
146 | timeout
147 | net-smtp (0.3.3)
148 | net-protocol
149 | nio4r (2.5.8)
150 | nokogiri (1.13.9-x64-mingw-ucrt)
151 | racc (~> 1.4)
152 | nokogiri (1.13.9-x86_64-linux)
153 | racc (~> 1.4)
154 | orm_adapter (0.5.0)
155 | pg (1.4.5)
156 | pg (1.4.5-x64-mingw-ucrt)
157 | public_suffix (5.0.0)
158 | puma (5.6.5)
159 | nio4r (~> 2.0)
160 | racc (1.6.0)
161 | rack (2.2.4)
162 | rack-test (2.0.2)
163 | rack (>= 1.3)
164 | rails (7.0.4)
165 | actioncable (= 7.0.4)
166 | actionmailbox (= 7.0.4)
167 | actionmailer (= 7.0.4)
168 | actionpack (= 7.0.4)
169 | actiontext (= 7.0.4)
170 | actionview (= 7.0.4)
171 | activejob (= 7.0.4)
172 | activemodel (= 7.0.4)
173 | activerecord (= 7.0.4)
174 | activestorage (= 7.0.4)
175 | activesupport (= 7.0.4)
176 | bundler (>= 1.15.0)
177 | railties (= 7.0.4)
178 | rails-controller-testing (1.0.5)
179 | actionpack (>= 5.0.1.rc1)
180 | actionview (>= 5.0.1.rc1)
181 | activesupport (>= 5.0.1.rc1)
182 | rails-dom-testing (2.0.3)
183 | activesupport (>= 4.2.0)
184 | nokogiri (>= 1.6)
185 | rails-html-sanitizer (1.4.3)
186 | loofah (~> 2.3)
187 | railties (7.0.4)
188 | actionpack (= 7.0.4)
189 | activesupport (= 7.0.4)
190 | method_source
191 | rake (>= 12.2)
192 | thor (~> 1.0)
193 | zeitwerk (~> 2.5)
194 | rake (13.0.6)
195 | regexp_parser (2.6.1)
196 | reline (0.3.1)
197 | io-console (~> 0.5)
198 | responders (3.0.1)
199 | actionpack (>= 5.0)
200 | railties (>= 5.0)
201 | rexml (3.2.5)
202 | rspec-core (3.12.0)
203 | rspec-support (~> 3.12.0)
204 | rspec-expectations (3.12.0)
205 | diff-lcs (>= 1.2.0, < 2.0)
206 | rspec-support (~> 3.12.0)
207 | rspec-mocks (3.12.0)
208 | diff-lcs (>= 1.2.0, < 2.0)
209 | rspec-support (~> 3.12.0)
210 | rspec-rails (6.0.1)
211 | actionpack (>= 6.1)
212 | activesupport (>= 6.1)
213 | railties (>= 6.1)
214 | rspec-core (~> 3.11)
215 | rspec-expectations (~> 3.11)
216 | rspec-mocks (~> 3.11)
217 | rspec-support (~> 3.11)
218 | rspec-support (3.12.0)
219 | rubyzip (2.3.2)
220 | selenium-webdriver (4.6.1)
221 | childprocess (>= 0.5, < 5.0)
222 | rexml (~> 3.2, >= 3.2.5)
223 | rubyzip (>= 1.2.2, < 3.0)
224 | websocket (~> 1.0)
225 | sprockets (4.1.1)
226 | concurrent-ruby (~> 1.0)
227 | rack (> 1, < 3)
228 | sprockets-rails (3.4.2)
229 | actionpack (>= 5.2)
230 | activesupport (>= 5.2)
231 | sprockets (>= 3.0.0)
232 | stimulus-rails (1.1.1)
233 | railties (>= 6.0.0)
234 | tailwindcss-rails (2.0.21-x64-mingw-ucrt)
235 | railties (>= 6.0.0)
236 | tailwindcss-rails (2.0.21-x86_64-linux)
237 | railties (>= 6.0.0)
238 | thor (1.2.1)
239 | timeout (0.3.0)
240 | turbo-rails (1.3.2)
241 | actionpack (>= 6.0.0)
242 | activejob (>= 6.0.0)
243 | railties (>= 6.0.0)
244 | tzinfo (2.0.5)
245 | concurrent-ruby (~> 1.0)
246 | tzinfo-data (1.2022.6)
247 | tzinfo (>= 1.0.0)
248 | uniform_notifier (1.16.0)
249 | warden (1.2.9)
250 | rack (>= 2.0.9)
251 | web-console (4.2.0)
252 | actionview (>= 6.0.0)
253 | activemodel (>= 6.0.0)
254 | bindex (>= 0.4.0)
255 | railties (>= 6.0.0)
256 | webdrivers (5.2.0)
257 | nokogiri (~> 1.6)
258 | rubyzip (>= 1.3.0)
259 | selenium-webdriver (~> 4.0)
260 | websocket (1.2.9)
261 | websocket-driver (0.7.5)
262 | websocket-extensions (>= 0.1.0)
263 | websocket-extensions (0.1.5)
264 | xpath (3.2.0)
265 | nokogiri (~> 1.8)
266 | zeitwerk (2.6.6)
267 |
268 | PLATFORMS
269 | x64-mingw-ucrt
270 | x86_64-linux
271 |
272 | DEPENDENCIES
273 | bootsnap
274 | bullet
275 | cancancan
276 | capybara
277 | database_cleaner
278 | debug
279 | devise
280 | dotenv-rails
281 | faker
282 | ffi
283 | importmap-rails
284 | jbuilder
285 | pg (~> 1.1)
286 | puma (~> 5.0)
287 | rails (~> 7.0.4)
288 | rails-controller-testing
289 | rspec-rails
290 | selenium-webdriver
291 | sprockets-rails
292 | stimulus-rails
293 | tailwindcss-rails (~> 2.0)
294 | turbo-rails
295 | tzinfo-data
296 | web-console
297 | webdrivers
298 |
299 | RUBY VERSION
300 | ruby 3.1.2p20
301 |
302 | BUNDLED WITH
303 | 2.3.24
304 |
--------------------------------------------------------------------------------
/config/initializers/devise.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Assuming you have not yet modified this file, each configuration option below
4 | # is set to its default value. Note that some are commented out while others
5 | # are not: uncommented lines are intended to protect your configuration from
6 | # breaking changes in upgrades (i.e., in the event that future versions of
7 | # Devise change the default values for those options).
8 | #
9 | # Use this hook to configure devise mailer, warden hooks and so forth.
10 | # Many of these configuration options can be set straight in your model.
11 | Devise.setup do |config|
12 | # The secret key used by Devise. Devise uses this key to generate
13 | # random tokens. Changing this key will render invalid all existing
14 | # confirmation, reset password and unlock tokens in the database.
15 | # Devise will use the `secret_key_base` as its `secret_key`
16 | # by default. You can change it below and use your own secret key.
17 | # config.secret_key = '4249842b0a4e4460e3081ef9077ff464fefbaed5586916a27ee3a41183f4a5e30ec77adca5cd1b42d835416c5511b85eb82acae3cb8c55e913e04bc9f802c567'
18 |
19 | # ==> Controller configuration
20 | # Configure the parent class to the devise controllers.
21 | # config.parent_controller = 'DeviseController'
22 |
23 | # ==> Mailer Configuration
24 | # Configure the e-mail address which will be shown in Devise::Mailer,
25 | # note that it will be overwritten if you use your own mailer class
26 | # with default "from" parameter.
27 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
28 |
29 | # Configure the class responsible to send e-mails.
30 | # config.mailer = 'Devise::Mailer'
31 |
32 | # Configure the parent class responsible to send e-mails.
33 | # config.parent_mailer = 'ActionMailer::Base'
34 |
35 | # ==> ORM configuration
36 | # Load and configure the ORM. Supports :active_record (default) and
37 | # :mongoid (bson_ext recommended) by default. Other ORMs may be
38 | # available as additional gems.
39 | require 'devise/orm/active_record'
40 |
41 | # ==> Configuration for any authentication mechanism
42 | # Configure which keys are used when authenticating a user. The default is
43 | # just :email. You can configure it to use [:username, :subdomain], so for
44 | # authenticating a user, both parameters are required. Remember that those
45 | # parameters are used only when authenticating and not when retrieving from
46 | # session. If you need permissions, you should implement that in a before filter.
47 | # You can also supply a hash where the value is a boolean determining whether
48 | # or not authentication should be aborted when the value is not present.
49 | # config.authentication_keys = [:email]
50 |
51 | # Configure parameters from the request object used for authentication. Each entry
52 | # given should be a request method and it will automatically be passed to the
53 | # find_for_authentication method and considered in your model lookup. For instance,
54 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
55 | # The same considerations mentioned for authentication_keys also apply to request_keys.
56 | # config.request_keys = []
57 |
58 | # Configure which authentication keys should be case-insensitive.
59 | # These keys will be downcased upon creating or modifying a user and when used
60 | # to authenticate or find a user. Default is :email.
61 | config.case_insensitive_keys = [:email]
62 |
63 | # Configure which authentication keys should have whitespace stripped.
64 | # These keys will have whitespace before and after removed upon creating or
65 | # modifying a user and when used to authenticate or find a user. Default is :email.
66 | config.strip_whitespace_keys = [:email]
67 |
68 | # Tell if authentication through request.params is enabled. True by default.
69 | # It can be set to an array that will enable params authentication only for the
70 | # given strategies, for example, `config.params_authenticatable = [:database]` will
71 | # enable it only for database (email + password) authentication.
72 | # config.params_authenticatable = true
73 |
74 | # Tell if authentication through HTTP Auth is enabled. False by default.
75 | # It can be set to an array that will enable http authentication only for the
76 | # given strategies, for example, `config.http_authenticatable = [:database]` will
77 | # enable it only for database authentication.
78 | # For API-only applications to support authentication "out-of-the-box", you will likely want to
79 | # enable this with :database unless you are using a custom strategy.
80 | # The supported strategies are:
81 | # :database = Support basic authentication with authentication key + password
82 | # config.http_authenticatable = false
83 |
84 | # If 401 status code should be returned for AJAX requests. True by default.
85 | # config.http_authenticatable_on_xhr = true
86 |
87 | # The realm used in Http Basic Authentication. 'Application' by default.
88 | # config.http_authentication_realm = 'Application'
89 |
90 | # It will change confirmation, password recovery and other workflows
91 | # to behave the same regardless if the e-mail provided was right or wrong.
92 | # Does not affect registerable.
93 | # config.paranoid = true
94 |
95 | # By default Devise will store the user in session. You can skip storage for
96 | # particular strategies by setting this option.
97 | # Notice that if you are skipping storage for all authentication paths, you
98 | # may want to disable generating routes to Devise's sessions controller by
99 | # passing skip: :sessions to `devise_for` in your config/routes.rb
100 | config.skip_session_storage = [:http_auth]
101 |
102 | # By default, Devise cleans up the CSRF token on authentication to
103 | # avoid CSRF token fixation attacks. This means that, when using AJAX
104 | # requests for sign in and sign up, you need to get a new CSRF token
105 | # from the server. You can disable this option at your own risk.
106 | # config.clean_up_csrf_token_on_authentication = true
107 |
108 | # When false, Devise will not attempt to reload routes on eager load.
109 | # This can reduce the time taken to boot the app but if your application
110 | # requires the Devise mappings to be loaded during boot time the application
111 | # won't boot properly.
112 | # config.reload_routes = true
113 |
114 | # ==> Configuration for :database_authenticatable
115 | # For bcrypt, this is the cost for hashing the password and defaults to 12. If
116 | # using other algorithms, it sets how many times you want the password to be hashed.
117 | # The number of stretches used for generating the hashed password are stored
118 | # with the hashed password. This allows you to change the stretches without
119 | # invalidating existing passwords.
120 | #
121 | # Limiting the stretches to just one in testing will increase the performance of
122 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
123 | # a value less than 10 in other environments. Note that, for bcrypt (the default
124 | # algorithm), the cost increases exponentially with the number of stretches (e.g.
125 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
126 | config.stretches = Rails.env.test? ? 1 : 12
127 |
128 | # Set up a pepper to generate the hashed password.
129 | # config.pepper = '21413c6e5acc843740022468eccb011c1c2fe8ce4ac271145ca7f75b85097893fa3fca9acc5cfee698785f449e407042aea941dc3b61c5710b78e0580c1483b1'
130 |
131 | # Send a notification to the original email when the user's email is changed.
132 | # config.send_email_changed_notification = false
133 |
134 | # Send a notification email when the user's password is changed.
135 | # config.send_password_change_notification = false
136 |
137 | # ==> Configuration for :confirmable
138 | # A period that the user is allowed to access the website even without
139 | # confirming their account. For instance, if set to 2.days, the user will be
140 | # able to access the website for two days without confirming their account,
141 | # access will be blocked just in the third day.
142 | # You can also set it to nil, which will allow the user to access the website
143 | # without confirming their account.
144 | # Default is 0.days, meaning the user cannot access the website without
145 | # confirming their account.
146 | # config.allow_unconfirmed_access_for = 2.days
147 |
148 | # A period that the user is allowed to confirm their account before their
149 | # token becomes invalid. For example, if set to 3.days, the user can confirm
150 | # their account within 3 days after the mail was sent, but on the fourth day
151 | # their account can't be confirmed with the token any more.
152 | # Default is nil, meaning there is no restriction on how long a user can take
153 | # before confirming their account.
154 | # config.confirm_within = 3.days
155 |
156 | # If true, requires any email changes to be confirmed (exactly the same way as
157 | # initial account confirmation) to be applied. Requires additional unconfirmed_email
158 | # db field (see migrations). Until confirmed, new email is stored in
159 | # unconfirmed_email column, and copied to email column on successful confirmation.
160 | config.reconfirmable = true
161 |
162 | # Defines which key will be used when confirming an account
163 | # config.confirmation_keys = [:email]
164 |
165 | # ==> Configuration for :rememberable
166 | # The time the user will be remembered without asking for credentials again.
167 | # config.remember_for = 2.weeks
168 |
169 | # Invalidates all the remember me tokens when the user signs out.
170 | config.expire_all_remember_me_on_sign_out = true
171 |
172 | # If true, extends the user's remember period when remembered via cookie.
173 | # config.extend_remember_period = false
174 |
175 | # Options to be passed to the created cookie. For instance, you can set
176 | # secure: true in order to force SSL only cookies.
177 | # config.rememberable_options = {}
178 |
179 | # ==> Configuration for :validatable
180 | # Range for password length.
181 | config.password_length = 6..128
182 |
183 | # Email regex used to validate email formats. It simply asserts that
184 | # one (and only one) @ exists in the given string. This is mainly
185 | # to give user feedback and not to assert the e-mail validity.
186 | config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
187 |
188 | # ==> Configuration for :timeoutable
189 | # The time you want to timeout the user session without activity. After this
190 | # time the user will be asked for credentials again. Default is 30 minutes.
191 | # config.timeout_in = 30.minutes
192 |
193 | # ==> Configuration for :lockable
194 | # Defines which strategy will be used to lock an account.
195 | # :failed_attempts = Locks an account after a number of failed attempts to sign in.
196 | # :none = No lock strategy. You should handle locking by yourself.
197 | # config.lock_strategy = :failed_attempts
198 |
199 | # Defines which key will be used when locking and unlocking an account
200 | # config.unlock_keys = [:email]
201 |
202 | # Defines which strategy will be used to unlock an account.
203 | # :email = Sends an unlock link to the user email
204 | # :time = Re-enables login after a certain amount of time (see :unlock_in below)
205 | # :both = Enables both strategies
206 | # :none = No unlock strategy. You should handle unlocking by yourself.
207 | # config.unlock_strategy = :both
208 |
209 | # Number of authentication tries before locking an account if lock_strategy
210 | # is failed attempts.
211 | # config.maximum_attempts = 20
212 |
213 | # Time interval to unlock the account if :time is enabled as unlock_strategy.
214 | # config.unlock_in = 1.hour
215 |
216 | # Warn on the last attempt before the account is locked.
217 | # config.last_attempt_warning = true
218 |
219 | # ==> Configuration for :recoverable
220 | #
221 | # Defines which key will be used when recovering the password for an account
222 | # config.reset_password_keys = [:email]
223 |
224 | # Time interval you can reset your password with a reset password key.
225 | # Don't put a too small interval or your users won't have the time to
226 | # change their passwords.
227 | config.reset_password_within = 6.hours
228 |
229 | # When set to false, does not sign a user in automatically after their password is
230 | # reset. Defaults to true, so a user is signed in automatically after a reset.
231 | # config.sign_in_after_reset_password = true
232 |
233 | # ==> Configuration for :encryptable
234 | # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
235 | # You can use :sha1, :sha512 or algorithms from others authentication tools as
236 | # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
237 | # for default behavior) and :restful_authentication_sha1 (then you should set
238 | # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
239 | #
240 | # Require the `devise-encryptable` gem when using anything other than bcrypt
241 | # config.encryptor = :sha512
242 |
243 | # ==> Scopes configuration
244 | # Turn scoped views on. Before rendering "sessions/new", it will first check for
245 | # "users/sessions/new". It's turned off by default because it's slower if you
246 | # are using only default views.
247 | # config.scoped_views = false
248 |
249 | # Configure the default scope given to Warden. By default it's the first
250 | # devise role declared in your routes (usually :user).
251 | # config.default_scope = :user
252 |
253 | # Set this configuration to false if you want /users/sign_out to sign out
254 | # only the current scope. By default, Devise signs out all scopes.
255 | # config.sign_out_all_scopes = true
256 |
257 | # ==> Navigation configuration
258 | # Lists the formats that should be treated as navigational. Formats like
259 | # :html, should redirect to the sign in page when the user does not have
260 | # access, but formats like :xml or :json, should return 401.
261 | #
262 | # If you have any extra navigational formats, like :iphone or :mobile, you
263 | # should add them to the navigational formats lists.
264 | #
265 | # The "*/*" below is required to match Internet Explorer requests.
266 | # config.navigational_formats = ['*/*', :html]
267 |
268 | # The default HTTP method used to sign out a resource. Default is :delete.
269 | config.sign_out_via = :delete
270 |
271 | # ==> OmniAuth
272 | # Add a new OmniAuth provider. Check the wiki for more information on setting
273 | # up on your models and hooks.
274 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
275 |
276 | # ==> Warden configuration
277 | # If you want to use other strategies, that are not supported by Devise, or
278 | # change the failure app, you can configure them inside the config.warden block.
279 | #
280 | # config.warden do |manager|
281 | # manager.intercept_401 = false
282 | # manager.default_strategies(scope: :user).unshift :some_external_strategy
283 | # end
284 |
285 | # ==> Mountable engine configurations
286 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine
287 | # is mountable, there are some extra configurations to be taken into account.
288 | # The following options are available, assuming the engine is mounted as:
289 | #
290 | # mount MyEngine, at: '/my_engine'
291 | #
292 | # The router that invoked `devise_for`, in the example above, would be:
293 | # config.router_name = :my_engine
294 | #
295 | # When using OmniAuth, Devise cannot automatically set OmniAuth path,
296 | # so you need to do it manually. For the users scope, it would be:
297 | # config.omniauth_path_prefix = '/my_engine/users/auth'
298 |
299 | # ==> Turbolinks configuration
300 | # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
301 | #
302 | # ActiveSupport.on_load(:devise_failure_app) do
303 | # include Turbolinks::Controller
304 | # end
305 |
306 | # ==> Configuration for :registerable
307 |
308 | # When set to false, does not sign a user in automatically after their password is
309 | # changed. Defaults to true, so a user is signed in automatically after changing a password.
310 | # config.sign_in_after_change_password = true
311 | end
312 |
--------------------------------------------------------------------------------