Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
AllCops:
Exclude:
- "vendor/**/*"
- "db/**/*"
- "bin/*"
- "node_modules/**/*"
- "config/initializers/devise.rb"
- "config/environments/*.rb"
- "Gemfile"
- "Rakefile"

Style/FrozenStringLiteralComment:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false

Style/Documentation:
Enabled: false

Metrics/BlockLength:
Exclude:
- "config/routes.rb"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ARG UID=1000
ARG GID=1000

RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential curl libpq-dev \
&& apt-get install -y --no-install-recommends build-essential curl libpq-dev vim \
&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
&& apt-get clean \
&& groupadd -g "${GID}" ruby \
Expand Down
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]

gem "rubocop", require: false
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false

end

group :development do
Expand All @@ -70,3 +75,5 @@ group :test do
gem "selenium-webdriver"
gem "webdrivers"
end

gem "devise"
48 changes: 48 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
bcrypt (3.1.18)
bindex (0.8.1)
bootsnap (1.15.0)
msgpack (~> 1.2)
Expand All @@ -90,6 +92,12 @@ GEM
debug (1.6.3)
irb (>= 1.3.6)
reline (>= 0.3.1)
devise (4.9.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
erubi (1.11.0)
globalid (1.0.0)
activesupport (>= 5.0)
Expand All @@ -103,6 +111,7 @@ GEM
activesupport (>= 5.0.0)
jsbundling-rails (1.0.3)
railties (>= 6.0.0)
json (2.6.3)
loofah (2.19.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand All @@ -123,8 +132,15 @@ GEM
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nokogiri (1.13.9-aarch64-linux)
racc (~> 1.4)
nokogiri (1.13.9-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pg (1.4.5)
public_suffix (5.0.0)
puma (6.0.0)
Expand Down Expand Up @@ -161,6 +177,7 @@ GEM
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
redis (5.0.5)
redis-client (>= 0.9.0)
Expand All @@ -169,7 +186,30 @@ GEM
regexp_parser (2.6.1)
reline (0.3.1)
io-console (~> 0.5)
responders (3.1.0)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.5)
rubocop (1.52.1)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-performance (1.18.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.20.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
ruby-progressbar (1.13.0)
rubyzip (2.3.2)
selenium-webdriver (4.6.1)
childprocess (>= 0.5, < 5.0)
Expand Down Expand Up @@ -198,6 +238,9 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -216,20 +259,25 @@ GEM
zeitwerk (2.6.6)

PLATFORMS
aarch64-linux
x86_64-linux

DEPENDENCIES
bootsnap
capybara
cssbundling-rails
debug
devise
jbuilder
jsbundling-rails
pg (~> 1.1)
puma (~> 6.0)
rack-mini-profiler
rails (~> 7.0.4)
redis (~> 5.0)
rubocop
rubocop-performance
rubocop-rails
selenium-webdriver
sidekiq (~> 7.0)
sprockets-rails
Expand Down
40 changes: 40 additions & 0 deletions app/controllers/expenses_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class ExpensesController < ApplicationController
before_action :set_group_and_users, only: [:show, :edit, :update]
before_action :set_expense, only: [:edit, :update]

def show
@difference = Expense.new.split_expenses(@users)
end

def edit
end

def update
@users.each do |user|
expense = user.expense
amount = params["group"]["group_user_#{user.id}_expenses"].to_i
if expense
expense.update(amount: amount)
else
Expense.create(user_id: user.id, group_id: @group.id, amount: amount)
end
end

redirect_to group_expense_path(@group)
end

private

def set_group_and_users
@group = Group.find(params[:group_id])
@users = @group.users
end

def set_expense
@expense = @group.expenses.find_by(user_id: @users.pluck(:id))
end

def expense_params
params.require(:expense).permit(:amount, :group_id, :user_id)
end
end
60 changes: 60 additions & 0 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
class GroupsController < ApplicationController
before_action :set_group, only: %i[show edit update]

def index
@groups = Group.all
@user = User.find(current_user.id)
end

def new
@group = Group.new
@user_list = @group.users.pluck(:id).join(',')
end

def create
@group = Group.new(group_params)
if @group.save
user_list = user_params[:user_lists].delete(' ').split(',')

@group.save_user(user_list)
redirect_to group_path(@group)
else
render :new
end
end

def show
@group = Group.find(params[:id])
@user = User.find(current_user.id) if current_user
end

def edit
@group = Group.find(params[:id])
@user_list = @group.users.pluck(:name).join(',')
end

def update
@group = Group.find(params[:id])
@user_list = user_params[:user_lists].delete(' ')
if @group.update(group_params)
@group.save_user(@user_list.split(','))
redirect_to group_path(@group)
else
render :edit
end
end

private

def set_group
@group = Group.find(params[:id])
end

def group_params
params.require(:group).permit(:name)
end

def user_params
params.require(:group).permit(:user_lists)
end
end
3 changes: 1 addition & 2 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class PagesController < ApplicationController
def home
end
def home; end
end
2 changes: 1 addition & 1 deletion app/controllers/up_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def index

def databases
RedisConn.current.ping
ActiveRecord::Base.connection.execute("SELECT 1")
ActiveRecord::Base.connection.execute('SELECT 1')

head :ok
end
Expand Down
30 changes: 30 additions & 0 deletions app/controllers/user/confirmations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

class User::ConfirmationsController < Devise::ConfirmationsController
# GET /resource/confirmation/new
# def new
# super
# end

# POST /resource/confirmation
# def create
# super
# end

# GET /resource/confirmation?confirmation_token=abcdef
# def show
# super
# end

# protected

# The path used after resending confirmation instructions.
# def after_resending_confirmation_instructions_path_for(resource_name)
# super(resource_name)
# end

# The path used after confirmation.
# def after_confirmation_path_for(resource_name, resource)
# super(resource_name, resource)
# end
end
30 changes: 30 additions & 0 deletions app/controllers/user/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

class User::OmniauthCallbacksController < Devise::OmniauthCallbacksController
# You should configure your model like this:
# devise :omniauthable, omniauth_providers: [:twitter]

# You should also create an action method in this controller like this:
# def twitter
# end

# More info at:
# https://github.com/heartcombo/devise#omniauth

# GET|POST /resource/auth/twitter
# def passthru
# super
# end

# GET|POST /users/auth/twitter/callback
# def failure
# super
# end

# protected

# The path used when OmniAuth fails
# def after_omniauth_failure_path_for(scope)
# super(scope)
# end
end
34 changes: 34 additions & 0 deletions app/controllers/user/passwords_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

class User::PasswordsController < Devise::PasswordsController
# GET /resource/password/new
# def new
# super
# end

# POST /resource/password
# def create
# super
# end

# GET /resource/password/edit?reset_password_token=abcdef
# def edit
# super
# end

# PUT /resource/password
# def update
# super
# end

# protected

# def after_resetting_password_path_for(resource)
# super(resource)
# end

# The path used after sending reset password instructions
# def after_sending_reset_password_instructions_path_for(resource_name)
# super(resource_name)
# end
end
Loading