Skip to content
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/issue-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- ⏰ **2-day timeline**: Aim to complete your work and submit a PR within **2 days** of assignment. If you need more time, please comment on this issue to discuss an extension.

- ✅ **CI checks must pass**: Before requesting a review, ensure your PR passes all automated checks (TypeScript, linting, build, security). You can see the status in the PR checks section.
- ✅ **CI checks must pass**: Before requesting a review, ensure your PR passes all automated checks (Ruby linting, tests, security audit). You can see the status in the PR checks section.

**Need help?** Feel free to ask questions in the comments or reach out to maintainers.

Expand Down Expand Up @@ -74,10 +74,10 @@ jobs:
2. ⏰ **Timeline reminder**: You have **2 days** from now to complete your work and submit a PR. The deadline is **${new Date(Date.now() + 2 * 24 * 60 * 60 * 1000).toLocaleDateString()}**.

3. ✅ **Quality checks**: Before requesting a review, make sure your PR passes all automated checks:
- TypeScript compilation
- ESLint linting
- Ruby linting (RuboCop)
- Test suite (RSpec)
- Security audit (Brakeman, Bundler Audit)
- Build verification
- Security audit

4. 📝 **Communication**: If you encounter any blockers or need clarification, please comment on this issue. We're here to help!

Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/rubyonrails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Skip CI for documentation-only changes
paths-ignore:
- '**/*.md'
- 'docs/**'
- 'README.md'
- 'CONTRIBUTING.md'
- 'LICENSE.md'
jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -25,6 +32,7 @@ jobs:
env:
RAILS_ENV: test
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test"
RAILS_MASTER_KEY: fc9798d72778290ba26391893469fefc
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -57,7 +65,10 @@ jobs:
# Add or replace any other lints here
- name: Security audit dependencies
run: bin/bundler-audit --update
continue-on-error: true
- name: Security audit application code
run: bin/brakeman -q -w2
continue-on-error: true
- name: Lint Ruby files
run: bin/rubocop --parallel
continue-on-error: true
59 changes: 59 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
AllCops:
NewCops: enable
SuggestExtensions: false
TargetRubyVersion: 2.7

# Disable some cops that are too strict for this project
Style/Documentation:
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false

Metrics/BlockLength:
Max: 50
Exclude:
- 'db/schema.rb'

Metrics/MethodLength:
Max: 20

Metrics/AbcSize:
Max: 20

Layout/LineLength:
Max: 120

# Allow some Rails-specific patterns
Style/StringLiterals:
EnforcedStyle: single_quotes

Style/SymbolArray:
EnforcedStyle: brackets

# Allow some common patterns
Layout/EmptyLinesAroundAccessModifier:
Enabled: false

Layout/EmptyLinesAroundClassBody:
Enabled: false

Layout/EmptyLinesAroundBlockBody:
Enabled: false

Layout/EmptyLines:
Enabled: false

Layout/TrailingEmptyLines:
Enabled: false

Layout/TrailingWhitespace:
Enabled: false

# Allow some test patterns
Style/BlockDelimiters:
Enabled: false

# Allow some migration patterns
Style/NumericLiterals:
Enabled: false
10 changes: 7 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "2.7.4"
ruby '2.7.4'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 6.1.3', '>= 6.1.3.2'
Expand Down Expand Up @@ -34,6 +34,10 @@ group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'factory_bot_rails'
gem 'faker'
# Linting and code quality tools
gem 'brakeman', require: false
gem 'bundler-audit', require: false
gem 'rubocop', require: false
end

group :development do
Expand All @@ -54,6 +58,6 @@ group :test do
gem 'shoulda-matchers', '~> 4.0'
end

gem "active_model_serializers", "~> 0.10.12"
gem 'active_model_serializers', '~> 0.10.12'

gem "kaminari", "~> 1.2"
gem 'kaminari', '~> 1.2'
36 changes: 36 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,16 @@ GEM
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
ast (2.4.3)
base64 (0.2.0)
bcrypt (3.1.20)
bootsnap (1.18.4)
msgpack (~> 1.2)
brakeman (5.4.1)
builder (3.3.0)
bundler-audit (0.9.2)
bundler (>= 1.2.0, < 3)
thor (~> 1.0)
byebug (11.1.3)
case_transform (0.2)
activesupport
Expand Down Expand Up @@ -109,6 +114,7 @@ GEM
activesupport (>= 6.1)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
json (2.15.1)
jsonapi-renderer (0.2.2)
jsonapi-serializer (2.2.0)
activesupport (>= 4.2)
Expand All @@ -126,6 +132,8 @@ GEM
activerecord
kaminari-core (= 1.2.2)
kaminari-core (1.2.2)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
Expand Down Expand Up @@ -159,7 +167,12 @@ GEM
nokogiri (1.15.6-x86_64-darwin)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.27.0)
parser (3.3.9.0)
ast (~> 2.4.1)
racc
pg (1.5.8)
prism (1.6.0)
puma (5.6.8)
nio4r (~> 2.0)
racc (1.8.1)
Expand Down Expand Up @@ -196,10 +209,12 @@ GEM
method_source
rake (>= 12.2)
thor (~> 1.0)
rainbow (3.1.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
regexp_parser (2.11.3)
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
Expand All @@ -221,6 +236,21 @@ GEM
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.13.1)
rubocop (1.81.1)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.47.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.47.1)
parser (>= 3.3.7.2)
prism (~> 1.4)
ruby-progressbar (1.13.0)
shoulda-matchers (4.5.1)
activesupport (>= 4.2.0)
spring (4.2.1)
Expand All @@ -235,6 +265,9 @@ GEM
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (3.2.0)
unicode-emoji (~> 4.1)
unicode-emoji (4.1.0)
warden (1.2.9)
rack (>= 2.0.9)
warden-jwt_auth (0.10.0)
Expand All @@ -255,6 +288,8 @@ DEPENDENCIES
active_model_serializers (~> 0.10.12)
bcrypt (~> 3.1.7)
bootsnap (>= 1.4.4)
brakeman
bundler-audit
byebug
devise
devise-jwt
Expand All @@ -269,6 +304,7 @@ DEPENDENCIES
rails (~> 6.1.3, >= 6.1.3.2)
rspec-json_expectations
rspec-rails (~> 5.0.0)
rubocop
shoulda-matchers (~> 4.0)
spring
tzinfo-data
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative "config/application"
require_relative 'config/application'

Rails.application.load_tasks
16 changes: 10 additions & 6 deletions app/controllers/api/v1/budgets_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class Api::V1::BudgetsController < ApplicationController
before_action :authenticate_user!
before_action :set_budget, only: [:show, :update, :destroy]
module Api
module V1
class BudgetsController < ApplicationController
before_action :authenticate_user!
before_action :set_budget, only: [:show, :update, :destroy]

# GET /api/v1/budgets
def index
Expand Down Expand Up @@ -41,14 +43,16 @@ def destroy
private

def set_budget
@budget = current_user.budgets.find(params[:id])
rescue ActiveRecord::RecordNotFound => error
render json: error.message, status: :unauthorized
@budget = current_user.budgets.find(params[:id])
rescue ActiveRecord::RecordNotFound => e
render json: e.message, status: :unauthorized
end

# Strong params
def budget_params
params.require(:budget).permit(:name, :financial_goal, :user_id)
end
end
end
end

5 changes: 3 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
class ApplicationController < ActionController::API
include ActionController::Cookies
include ErrorHandler

before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: %i[name avatar])
devise_parameter_sanitizer.permit(:account_update, keys: %i[name avatar])
devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :avatar])
devise_parameter_sanitizer.permit(:account_update, keys: [:name, :avatar])
end
end
2 changes: 2 additions & 0 deletions app/controllers/concerns/rack_sessions_fix.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module RackSessionsFix
extend ActiveSupport::Concern

class FakeRackSession < Hash
def enabled?
false
end

def destroy; end
end
included do
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/members_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class MembersController < ApplicationController
before_action :authenticate_user!
def index
render json: current_user, status: :ok
render json: current_user, status: :ok
end
end
2 changes: 1 addition & 1 deletion app/controllers/users/api_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class ApiController < ApplicationController
before_action :authenticate_user!
before_action :authenticate_user!
end
31 changes: 17 additions & 14 deletions app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# frozen_string_literal: true

class Users::RegistrationsController < Devise::RegistrationsController
include RackSessionsFix
respond_to :json
private
module Users
class RegistrationsController < Devise::RegistrationsController
include RackSessionsFix

def respond_with(current_user, _opts = {})
if resource.persisted?
render json: {
status: {code: 200, message: 'Signed up successfully.'},
data: UserSerializer.new(current_user).serializable_hash[:data][:attributes]
}
else
render json: {
status: {message: "User couldn't be created successfully. #{current_user.errors.full_messages.to_sentence}"}
}, status: :unprocessable_entity
respond_to :json
private

def respond_with(current_user, _opts = {})
if resource.persisted?
render json: {
status: { code: 200, message: 'Signed up successfully.' },
data: UserSerializer.new(current_user).serializable_hash[:data][:attributes]
}
else
render json: {
status: { message: "User couldn't be created successfully. #{current_user.errors.full_messages.to_sentence}" }
}, status: :unprocessable_entity
end
end
end
end
Loading
Loading