Skip to content

Commit

Permalink
Merge pull request #234 from cassiosantana/release/v0.6
Browse files Browse the repository at this point in the history
release/v0.6
  • Loading branch information
cassiosantana authored Sep 28, 2023
2 parents f4e2d26 + 4b90a4a commit 579c832
Show file tree
Hide file tree
Showing 134 changed files with 2,044 additions and 954 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/test

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Ruby 3.2.2
uses: ruby/setup-ruby@v1
with:
Expand All @@ -32,11 +33,22 @@ jobs:
gem install bundler
bundle install --jobs 4 --retry 3
- name: Set up Node.js 18.17.1
uses: actions/setup-node@v3
with:
node-version: 18.17.1

- name: Install Node.js dependencies
run: npm install

- name: Setup test database
run: |
bundle exec rails db:create
bundle exec rails db:schema:load
- name: Compile assets
run: bundle exec rake assets:precompile

- name: Run tests
env:
RAILS_ENV: test
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ yarn-debug.log*
.idea
# Ignore master key for decrypting credentials and more.
/config/master.key

/app/assets/builds/*
!/app/assets/builds/.keep
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.17.1
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ruby "3.2.2"

gem "bootsnap", require: false
gem "cpf_cnpj", "~> 0.5.0"
gem "foreman", "~> 0.87.2"
gem "importmap-rails"
gem "isbn", "~> 2.0", ">= 2.0.11"
gem "jbuilder"
Expand All @@ -16,6 +17,7 @@ gem "rails", "~> 7.0", ">= 7.0.7"
gem "ransack", "~> 4.0"
gem "sprockets-rails"
gem "stimulus-rails"
gem "tailwindcss-rails", "~> 2.0"
gem "turbo-rails"
gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]

Expand Down
7 changes: 6 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ GEM
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
ffaker (2.21.0)
foreman (0.87.2)
globalid (1.1.0)
activesupport (>= 5.0)
i18n (1.14.1)
Expand Down Expand Up @@ -239,6 +240,8 @@ GEM
sprockets (>= 3.0.0)
stimulus-rails (1.2.1)
railties (>= 6.0.0)
tailwindcss-rails (2.0.30)
railties (>= 6.0.0)
thor (1.2.2)
timeout (0.4.0)
turbo-rails (1.4.0)
Expand Down Expand Up @@ -274,6 +277,7 @@ DEPENDENCIES
cpf_cnpj (~> 0.5.0)
factory_bot_rails (~> 6.2)
ffaker (~> 2.21)
foreman (~> 0.87.2)
importmap-rails
isbn (~> 2.0, >= 2.0.11)
jbuilder
Expand All @@ -287,6 +291,7 @@ DEPENDENCIES
simplecov
sprockets-rails
stimulus-rails
tailwindcss-rails (~> 2.0)
turbo-rails
tzinfo-data
web-console
Expand All @@ -296,4 +301,4 @@ RUBY VERSION
ruby 3.2.2p53

BUNDLED WITH
2.4.17
2.4.19
2 changes: 2 additions & 0 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: bin/rails server -p 3000
css: bin/rails tailwindcss:watch
Empty file added app/assets/builds/.keep
Empty file.
1 change: 1 addition & 0 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
//= link_directory ../stylesheets .css
//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js
//= link_tree ../builds
13 changes: 13 additions & 0 deletions app/assets/stylesheets/application.tailwind.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

/*
@layer components {
.btn-primary {
@apply py-2 px-4 bg-blue-200;
}
}
*/
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module AccountServices
class CheckDigitCalculatorService < ApplicationService
module Accounts
class CheckDigitCalculator < BusinessApplication
def initialize(account_number)
super
@account_number = account_number.to_i
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module AssemblyServices
class ExistenceVerifierService < ApplicationService
module Assemblies
class ExistenceVerifier < BusinessApplication
def initialize(ids)
super
@ids = ids
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class ApplicationService
class BusinessApplication
def self.call(*args)
new(*args).call
end
Expand Down
51 changes: 0 additions & 51 deletions app/controllers/accounts_controller.rb

This file was deleted.

53 changes: 53 additions & 0 deletions app/controllers/admin/accounts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# frozen_string_literal: true

module Admin
class AccountsController < ApplicationController
before_action :set_account, only: %i[show edit update destroy]

def index
@accounts = Account.all
end

def show; end

def new
@account = Account.new
end

def edit; end

def create
@account = Account.new(account_params)

if @account.save
redirect_to admin_account_url(@account), notice: "Account was successfully created."
else
render :new, status: :unprocessable_entity
end
end

def update
if @account.update(account_params)
redirect_to admin_account_url(@account), notice: "Account was successfully updated."
else
render :edit, status: :unprocessable_entity
end
end

def destroy
@account.destroy

redirect_to admin_accounts_url, notice: "Account was successfully destroyed."
end

private

def set_account
@account = Account.find(params[:id])
end

def account_params
params.require(:account).permit(:supplier_id, :account_number)
end
end
end
62 changes: 62 additions & 0 deletions app/controllers/admin/assemblies_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# frozen_string_literal: true

module Admin
class AssembliesController < ApplicationController
before_action :set_assembly, only: %i[show edit update destroy]

def index
@q = Assembly.ransack(params[:q])
@assemblies = @q.result(distinct: true).includes(:parts)
end

def show; end

def new
@assembly = Assembly.new
end

def edit; end

def create
@assembly = Assembly.new(assembly_params)

if @assembly.save
redirect_to admin_assembly_url(@assembly), notice: "Assembly was successfully created."
else
render :new, status: :unprocessable_entity
end
end

def update
if @assembly.update(assembly_params)

%i[part book].each do |attribute|
@assembly.send(attribute.to_s.pluralize).clear

attribute_ids = Array(params[:assembly][:"#{attribute}_ids"]).select(&:present?)
@assembly.send("#{attribute}_ids=", attribute_ids)
end

redirect_to admin_assembly_url(@assembly), notice: "Assembly was successfully updated."
else
render :edit, status: :unprocessable_entity
end
end

def destroy
@assembly.destroy

redirect_to admin_assemblies_url, notice: "Assembly was successfully destroyed."
end

private

def set_assembly
@assembly = Assembly.find(params[:id])
end

def assembly_params
params.require(:assembly).permit(:name, part_ids: [], book_ids: [])
end
end
end
57 changes: 57 additions & 0 deletions app/controllers/admin/authors_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# frozen_string_literal: true

module Admin
class AuthorsController < ApplicationController
before_action :set_author, only: %i[show edit update destroy]

def index
@authors = Author.all
end

def show; end

def new
@author = Author.new
end

def edit; end

def create
@author = Author.new(author_params)

if @author.save
redirect_to admin_author_url(@author), notice: "Author was successfully created."
else
render :new, status: :unprocessable_entity
end
end

def update
if @author.update(author_params)
redirect_to admin_author_url(@author), notice: "Author was successfully updated."
else
render :edit, status: :unprocessable_entity
end
end

def destroy
@author.destroy

redirect_to admin_authors_url, notice: "Author was successfully destroyed."
end

def report
@author = Author.includes(:books).find(params[:id])
end

private

def set_author
@author = Author.find(params[:id])
end

def author_params
params.require(:author).permit(:name, :cpf)
end
end
end
Loading

0 comments on commit 579c832

Please sign in to comment.