diff --git a/Gemfile.lock b/Gemfile.lock
index 72989ad..d5f5e1b 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -131,6 +131,8 @@ GEM
nio4r (2.5.8)
nokogiri (1.13.8-arm64-darwin)
racc (~> 1.4)
+ nokogiri (1.13.8-x86_64-linux)
+ racc (~> 1.4)
orm_adapter (0.5.0)
popper_js (2.11.6)
public_suffix (5.0.0)
@@ -206,6 +208,7 @@ GEM
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.5.2-arm64-darwin)
+ sqlite3 (1.5.2-x86_64-linux)
thor (1.2.1)
tilt (2.0.11)
timeout (0.3.0)
@@ -222,6 +225,7 @@ GEM
PLATFORMS
arm64-darwin-21
+ x86_64-linux
DEPENDENCIES
bootstrap (~> 5.2.1)
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
new file mode 100644
index 0000000..44d2914
--- /dev/null
+++ b/app/controllers/home_controller.rb
@@ -0,0 +1,9 @@
+class HomeController < ApplicationController
+
+
+ def index
+
+ end
+
+
+end
\ No newline at end of file
diff --git a/app/controllers/product_categories_controller.rb b/app/controllers/product_categories_controller.rb
index 180bc41..03ea568 100644
--- a/app/controllers/product_categories_controller.rb
+++ b/app/controllers/product_categories_controller.rb
@@ -1,21 +1,28 @@
class ProductCategoriesController < ApplicationController
- def create
- ProductCategory.create!(name: params.require(:product_category).permit(:name))
- redirect_to products_path, notice: 'Categoria cadastrada'
+
+ def index
+ @product_categories = ProductCategory.all
end
- def search
- nome_a_buscar = params[:busca]
- ProductCategory.where("name LIKE :param_busca OR outro_campo LIKE :param_busca OR mais_um_campo LIKE :param_busca ",
- { param_busca: "%#{nome_a_buscar}%" } )
-
- @transports = find_available_transports
+ def new
+ @product_category = ProductCategory.new
+ end
+ def create
+ @product_category = ProductCategory.new(product_category_params)
+ if @product_category.save
+ redirect_to root_path, notice: 'Cadastrado com sucesso'
+ else
+ render 'new', notice: 'Não foi possível cadastrar produto'
+ end
+ end
+
+ def show
+ @product_category = ProductCategory.find(params[:id])
end
private
-
- def find_available_transports()
- FreightageFinder.new(transports, order).find()
+ def product_category_params
+ params.require(:product_category).permit(:name)
end
end
\ No newline at end of file
diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb
index 039a826..e00c322 100644
--- a/app/controllers/products_controller.rb
+++ b/app/controllers/products_controller.rb
@@ -1,20 +1,20 @@
class ProductsController < ApplicationController
- before_action :set_product, only: %i[ show edit update destroy ]
+ #before_action :set_product, only: %i[ show edit update destroy ]
# GET /products
def index
- @products = Product.all
- @product = Product.new
- @product_category = ProductCategory.new
- @product_categories = ProductCategory.all
+
end
# GET /products/1
def show
+ @product = Product.find(params[:id])
+ @product_category = ProductCategory.find(params[:product_category_id])
end
# GET /products/new
def new
+ @product_category = ProductCategory.find(params[:product_category_id])
@product = Product.new
end
@@ -24,28 +24,27 @@ def edit
# POST /products
def create
+ product_params = params.require(:product).permit(:name, :price)
+ @product_category = ProductCategory.find(params[:product_category_id])
@product = Product.new(product_params)
-
- if @product.save
- redirect_to @product, notice: "Product was successfully created."
+ @product.product_category_id = @product_category.id
+
+ if @product.save
+ redirect_to product_category_product_path(@product_category.id, @product.id ), notice: 'Cadastrado com sucesso'
else
- render :new, status: :unprocessable_entity
+ render 'new', notice: 'Não foi possível cadastrar produto'
end
+
end
# PATCH/PUT /products/1
def update
- if @product.update(product_params)
- redirect_to @product, notice: "Product was successfully updated."
- else
- render :edit, status: :unprocessable_entity
- end
+
end
# DELETE /products/1
def destroy
- @product.destroy
- redirect_to products_url, notice: "Product was successfully destroyed."
+
end
private
@@ -56,6 +55,6 @@ def set_product
# Only allow a list of trusted parameters through.
def product_params
- params.require(:product).permit(:name, :price, :product_category_id)
+ params.require(:product).permit(:name, :price)
end
end
diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb
deleted file mode 100644
index 73ff2dc..0000000
--- a/app/controllers/welcome_controller.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class WelcomeController < ApplicationController
-
-
- def index
-
- end
-
-
-end
\ No newline at end of file
diff --git a/app/models/product_category.rb b/app/models/product_category.rb
index 282738c..d95f936 100644
--- a/app/models/product_category.rb
+++ b/app/models/product_category.rb
@@ -1,3 +1,4 @@
class ProductCategory < ApplicationRecord
validates :name, presence: true
+ has_many :products
end
diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb
new file mode 100644
index 0000000..b12dd0c
--- /dev/null
+++ b/app/views/devise/confirmations/new.html.erb
@@ -0,0 +1,16 @@
+
Resend confirmation instructions
+
+<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
+ <%= render "devise/shared/error_messages", resource: resource %>
+
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
+
+
+
+ <%= f.submit "Resend confirmation instructions" %>
+
+<% end %>
+
+<%= render "devise/shared/links" %>
diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb
new file mode 100644
index 0000000..dc55f64
--- /dev/null
+++ b/app/views/devise/mailer/confirmation_instructions.html.erb
@@ -0,0 +1,5 @@
+Welcome <%= @email %>!
+
+You can confirm your account email through the link below:
+
+<%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>
diff --git a/app/views/devise/mailer/email_changed.html.erb b/app/views/devise/mailer/email_changed.html.erb
new file mode 100644
index 0000000..32f4ba8
--- /dev/null
+++ b/app/views/devise/mailer/email_changed.html.erb
@@ -0,0 +1,7 @@
+Hello <%= @email %>!
+
+<% if @resource.try(:unconfirmed_email?) %>
+ We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.
+<% else %>
+ We're contacting you to notify you that your email has been changed to <%= @resource.email %>.
+<% end %>
diff --git a/app/views/devise/mailer/password_change.html.erb b/app/views/devise/mailer/password_change.html.erb
new file mode 100644
index 0000000..b41daf4
--- /dev/null
+++ b/app/views/devise/mailer/password_change.html.erb
@@ -0,0 +1,3 @@
+Hello <%= @resource.email %>!
+
+We're contacting you to notify you that your password has been changed.
diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb
new file mode 100644
index 0000000..f667dc1
--- /dev/null
+++ b/app/views/devise/mailer/reset_password_instructions.html.erb
@@ -0,0 +1,8 @@
+Hello <%= @resource.email %>!
+
+Someone has requested a link to change your password. You can do this through the link below.
+
+<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>
+
+If you didn't request this, please ignore this email.
+Your password won't change until you access the link above and create a new one.
diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb
new file mode 100644
index 0000000..41e148b
--- /dev/null
+++ b/app/views/devise/mailer/unlock_instructions.html.erb
@@ -0,0 +1,7 @@
+Hello <%= @resource.email %>!
+
+Your account has been locked due to an excessive number of unsuccessful sign in attempts.
+
+Click the link below to unlock your account:
+
+<%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>
diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb
new file mode 100644
index 0000000..5fbb9ff
--- /dev/null
+++ b/app/views/devise/passwords/edit.html.erb
@@ -0,0 +1,25 @@
+Change your password
+
+<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
+ <%= render "devise/shared/error_messages", resource: resource %>
+ <%= f.hidden_field :reset_password_token %>
+
+
+ <%= f.label :password, "New password" %>
+ <% if @minimum_password_length %>
+ (<%= @minimum_password_length %> characters minimum)
+ <% end %>
+ <%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
+
+
+
+ <%= f.label :password_confirmation, "Confirm new password" %>
+ <%= f.password_field :password_confirmation, autocomplete: "new-password" %>
+
+
+
+ <%= f.submit "Change my password" %>
+
+<% end %>
+
+<%= render "devise/shared/links" %>
diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb
new file mode 100644
index 0000000..9b486b8
--- /dev/null
+++ b/app/views/devise/passwords/new.html.erb
@@ -0,0 +1,16 @@
+Forgot your password?
+
+<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
+ <%= render "devise/shared/error_messages", resource: resource %>
+
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
+
+
+
+ <%= f.submit "Send me reset password instructions" %>
+
+<% end %>
+
+<%= render "devise/shared/links" %>
diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb
new file mode 100644
index 0000000..38d95b8
--- /dev/null
+++ b/app/views/devise/registrations/edit.html.erb
@@ -0,0 +1,43 @@
+Edit <%= resource_name.to_s.humanize %>
+
+<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
+ <%= render "devise/shared/error_messages", resource: resource %>
+
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
+
+
+ <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
+ Currently waiting confirmation for: <%= resource.unconfirmed_email %>
+ <% end %>
+
+
+ <%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.password_field :password, autocomplete: "new-password" %>
+ <% if @minimum_password_length %>
+
+ <%= @minimum_password_length %> characters minimum
+ <% end %>
+
+
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: "new-password" %>
+
+
+
+ <%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.password_field :current_password, autocomplete: "current-password" %>
+
+
+
+ <%= f.submit "Update" %>
+
+<% end %>
+
+Cancel my account
+
+Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>
+
+<%= link_to "Back", :back %>
diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb
new file mode 100644
index 0000000..d655b66
--- /dev/null
+++ b/app/views/devise/registrations/new.html.erb
@@ -0,0 +1,29 @@
+Sign up
+
+<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
+ <%= render "devise/shared/error_messages", resource: resource %>
+
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
+
+
+
+ <%= f.label :password %>
+ <% if @minimum_password_length %>
+ (<%= @minimum_password_length %> characters minimum)
+ <% end %>
+ <%= f.password_field :password, autocomplete: "new-password" %>
+
+
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: "new-password" %>
+
+
+
+ <%= f.submit "Sign up" %>
+
+<% end %>
+
+<%= render "devise/shared/links" %>
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb
new file mode 100644
index 0000000..5ede964
--- /dev/null
+++ b/app/views/devise/sessions/new.html.erb
@@ -0,0 +1,26 @@
+Log in
+
+<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
+
+
+
+ <%= f.label :password %>
+ <%= f.password_field :password, autocomplete: "current-password" %>
+
+
+ <% if devise_mapping.rememberable? %>
+
+ <%= f.check_box :remember_me %>
+ <%= f.label :remember_me %>
+
+ <% end %>
+
+
+ <%= f.submit "Log in" %>
+
+<% end %>
+
+<%= render "devise/shared/links" %>
diff --git a/app/views/devise/shared/_error_messages.html.erb b/app/views/devise/shared/_error_messages.html.erb
new file mode 100644
index 0000000..ba7ab88
--- /dev/null
+++ b/app/views/devise/shared/_error_messages.html.erb
@@ -0,0 +1,15 @@
+<% if resource.errors.any? %>
+
+
+ <%= I18n.t("errors.messages.not_saved",
+ count: resource.errors.count,
+ resource: resource.class.model_name.human.downcase)
+ %>
+
+
+ <% resource.errors.full_messages.each do |message| %>
+ - <%= message %>
+ <% end %>
+
+
+<% end %>
diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb
new file mode 100644
index 0000000..96a9412
--- /dev/null
+++ b/app/views/devise/shared/_links.html.erb
@@ -0,0 +1,25 @@
+<%- if controller_name != 'sessions' %>
+ <%= link_to "Log in", new_session_path(resource_name) %>
+<% end %>
+
+<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
+ <%= link_to "Sign up", new_registration_path(resource_name) %>
+<% end %>
+
+<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+<% end %>
+
+<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
+<% end %>
+
+<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
+<% end %>
+
+<%- if devise_mapping.omniauthable? %>
+ <%- resource_class.omniauth_providers.each do |provider| %>
+ <%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), method: :post %>
+ <% end %>
+<% end %>
diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb
new file mode 100644
index 0000000..ffc34de
--- /dev/null
+++ b/app/views/devise/unlocks/new.html.erb
@@ -0,0 +1,16 @@
+Resend unlock instructions
+
+<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
+ <%= render "devise/shared/error_messages", resource: resource %>
+
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
+
+
+
+ <%= f.submit "Resend unlock instructions" %>
+
+<% end %>
+
+<%= render "devise/shared/links" %>
diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb
new file mode 100644
index 0000000..a948e07
--- /dev/null
+++ b/app/views/home/index.html.erb
@@ -0,0 +1,5 @@
+ Produtos
+
+
+<%= link_to 'Início', root_path, class: 'btn btn-primary btn-lg' %>
+<%= link_to 'Ver Categorias de Produtos', product_categories_path, class: 'btn btn-primary btn-lg' %>
\ No newline at end of file
diff --git a/app/views/product_categories/_product_category.html.erb b/app/views/product_categories/_product_category.html.erb
deleted file mode 100644
index e216369..0000000
--- a/app/views/product_categories/_product_category.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= product_category.name %>
\ No newline at end of file
diff --git a/app/views/product_categories/index.html.erb b/app/views/product_categories/index.html.erb
new file mode 100644
index 0000000..e1e825a
--- /dev/null
+++ b/app/views/product_categories/index.html.erb
@@ -0,0 +1,7 @@
+ Categorias de Produtos
+
+<% @product_categories.each do |pc|%>
+ <%= link_to pc.name, product_category_path(pc.id) %>
+<% end %>
+
+<%= link_to 'Cadastrar Categoria de Produto', new_product_category_path, class: 'btn btn-primary btn'%>
diff --git a/app/views/product_categories/new.html.erb b/app/views/product_categories/new.html.erb
new file mode 100644
index 0000000..62ef02f
--- /dev/null
+++ b/app/views/product_categories/new.html.erb
@@ -0,0 +1,13 @@
+Cadastrar Nova Categoria Produto
+
+<%= form_with(model: @product_category ) do |f| %>
+
+ <%= f.label :name, 'Nome' %>
+ <%= f.text_field :name, class: "form-control" %>
+
+
+
+ <%= f.submit 'Salvar', class: "btn btn-primary" %>
+
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/product_categories/show.html.erb b/app/views/product_categories/show.html.erb
new file mode 100644
index 0000000..d173bca
--- /dev/null
+++ b/app/views/product_categories/show.html.erb
@@ -0,0 +1,4 @@
+ Categoria de Produto: <%= @product_category.name %>
+
+
+ <%= link_to 'Cadastrar Produto', new_product_category_product_url(@product_category.id), class: 'btn btn-primary btn'%>
diff --git a/app/views/products/_form.html.erb b/app/views/products/_form.html.erb
deleted file mode 100644
index a2a1d8e..0000000
--- a/app/views/products/_form.html.erb
+++ /dev/null
@@ -1,27 +0,0 @@
-<%= form_with(model: product) do |form| %>
- <% if product.errors.any? %>
-
-
<%= pluralize(product.errors.count, "error") %> prohibited this product from being saved:
-
-
- <% product.errors.each do |error| %>
- - <%= error.full_message %>
- <% end %>
-
-
- <% end %>
-
-
- <%= form.label :name, style: "display: block" %>
- <%= form.text_field :name %>
-
-
-
- <%= form.label :price, style: "display: block" %>
- <%= form.text_field :price %>
-
-
-
- <%= form.submit %>
-
-<% end %>
diff --git a/app/views/products/_product.html.erb b/app/views/products/_product.html.erb
deleted file mode 100644
index 19ca353..0000000
--- a/app/views/products/_product.html.erb
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
- Name:
- <%= product.name %>
-
-
-
- Price:
- <%= product.price %>
-
-
-
diff --git a/app/views/products/edit.html.erb b/app/views/products/edit.html.erb
deleted file mode 100644
index 90cb860..0000000
--- a/app/views/products/edit.html.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-Editing product
-
-<%= render "form", product: @product %>
-
-
-
-
- <%= link_to "Show this product", @product %> |
- <%= link_to "Back to products", products_path %>
-
diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb
deleted file mode 100644
index a84a004..0000000
--- a/app/views/products/index.html.erb
+++ /dev/null
@@ -1,50 +0,0 @@
-<%= notice %>
-
-Products
-
- <% @products.each do |product| %>
- <%= render product %>
-
- <%= link_to "Show this product", product %>
-
- <% end %>
-
-
-Nova Categoria de Produto
-<%= form_with(model: @product_category) do |f| %>
- <%= f.label :name %>
- <%= f.text_field :name %>
- <%= f.submit %>
-<% end %>
-
-
-
-
-Novo Produto
-<%= form_with(model: @product) do |form| %>
-
- <%= form.label :name, style: "display: block" %>
- <%= form.text_field :name %>
-
-
-
- <%= form.label :price, style: "display: block" %>
- <%= form.text_field :price %>
-
-
-
- <%= form.label :condition_new, 'Produto Novo' %>
- <%= form.radio_button :condition, :new %>
-
- <%= form.label :condition_used, 'Produto Usado' %>
- <%= form.radio_button :condition, :used %>
-
-
-
- <%= form.submit %>
-
-<% end %>
-
-
-choose 'Produto Usado'
-
diff --git a/app/views/products/new.html.erb b/app/views/products/new.html.erb
index d438e41..cb2c278 100644
--- a/app/views/products/new.html.erb
+++ b/app/views/products/new.html.erb
@@ -1,9 +1,16 @@
-New product
+Cadastrar Novo Produto
-<%= render "form", product: @product %>
+<%= form_with(model: @product, url: product_category_products_url(@product_category.id) ) do |f| %>
+
+ <%= f.label :name, 'Nome' %>
+ <%= f.text_field :name, class: "form-control" %>
+
+
+ <%= f.label :price, 'Valor' %>
+ <%= f.number_field :price, step: :any, class: "form-control" %>
+
+
+ <%= f.submit 'Salvar', class: "btn btn-primary" %>
+
-
-
-
- <%= link_to "Back to products", products_path %>
-
+<% end %>
\ No newline at end of file
diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb
index 7e30dc8..04f480f 100644
--- a/app/views/products/show.html.erb
+++ b/app/views/products/show.html.erb
@@ -1,12 +1,5 @@
-<%= notice %>
+Descrição do Produto
-<%= render @product %>
+Nome: <%= @product.name %>
+Preço: R$<%= @product.price %>
-<%= render @product.product_category %>
-
-
- <%= link_to "Edit this product", edit_product_path(@product) %> |
- <%= link_to "Back to products", products_path %>
-
- <%= button_to "Destroy this product", @product, method: :delete %>
-
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb
deleted file mode 100644
index 65777a5..0000000
--- a/app/views/welcome/index.html.erb
+++ /dev/null
@@ -1,42 +0,0 @@
-<%= translate('.title') %>
-
-
-
- <%= image_tag 'delivery.png', class: 'img-fluid' %>
-
-
-
-
-
-
- | # |
- First |
- Last |
- Handle |
-
-
-
-
- | 1 |
- Mark |
- Otto |
- @mdo |
-
-
- | 2 |
- Jacob |
- Thornton |
- @fat |
-
-
- | 3 |
- Larry the Bird |
- @twitter |
-
-
-
-
-
-
-
-<%= link_to 'Início', root_path, class: 'btn btn-primary btn-lg' %>
diff --git a/config/application.rb b/config/application.rb
index cfa4ef9..f874ca7 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -7,7 +7,7 @@
require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
-# require "action_mailer/railtie"
+require "action_mailer/railtie"
# require "action_mailbox/engine"
# require "action_text/engine"
require "action_view/railtie"
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 5ab2549..bde63ae 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -2,7 +2,9 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
-
+
+ config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
+
# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
@@ -33,6 +35,7 @@
config.cache_store = :null_store
end
+
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
diff --git a/config/initializers/locale.rb b/config/initializers/locale.rb
new file mode 100644
index 0000000..51fed0e
--- /dev/null
+++ b/config/initializers/locale.rb
@@ -0,0 +1,5 @@
+# Permitted locales available for the application
+I18n.available_locales = [:en]
+
+# Set default locale to something other than :en
+I18n.default_locale = :en
\ No newline at end of file
diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml
deleted file mode 100644
index 68c10cf..0000000
--- a/config/locales/pt-BR.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-en:
- transport_mode:
- error:
- not_available: 'Não existe modalidade disponível'
-
- welcome:
- index:
- title: 'Sistema de Frete e Transporatdoras'
- outro:
- outro:
- outro:
-
-
-I18n.translate('transport_mode.error.not_available')
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index e23c4d5..ac2cac7 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,8 +1,9 @@
Rails.application.routes.draw do
- resources :products
- resources :product_categories, only: [:create, :show] do
- resources :products, only: [:create]
+
+ resources :product_categories, only: [:index, :show, :new, :create] do
+ resources :products, only: [:new, :create, :show]
end
+
devise_for :users
- root 'welcome#index'
+ root 'home#index'
end
diff --git a/db/seeds.rb b/db/seeds.rb
index fbaf120..0119433 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -6,13 +6,4 @@
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
# Character.create(name: "Luke", movie: movies.first)
-User.create(email: user@email.com, password: )
-Company.create(name: , cnpj: )
-Product.create(name: , price: , company: )
-
-
-
-
-
-
-User.create(email: user@email.com, password: )
\ No newline at end of file
+User.create(email: 'user@email.com', password: 'password')
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 1a859fa..bd8c344 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -20,7 +20,7 @@
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
-# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
+ Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
# Checks for pending migrations and applies them before tests are run.
# If you are not using ActiveRecord, you can remove these lines.
@@ -31,7 +31,7 @@
end
RSpec.configure do |config|
config.before(:each, type: :system) do
- driven_by :rack_test
+ driven_by(:rack_test)
end
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
diff --git a/spec/support/devise_methods.rb b/spec/support/devise_methods.rb
new file mode 100644
index 0000000..ad49d80
--- /dev/null
+++ b/spec/support/devise_methods.rb
@@ -0,0 +1 @@
+include Warden::Test::Helpers
diff --git a/spec/system/product/register_product_spec.rb b/spec/system/product/register_product_spec.rb
new file mode 100644
index 0000000..de6a155
--- /dev/null
+++ b/spec/system/product/register_product_spec.rb
@@ -0,0 +1,38 @@
+require 'rails_helper'
+
+describe "Usuário cadastra novo produto" do
+
+ it 'com sucesso' do
+ #arrange
+ user = User.create!(email:'user@email.com', password: 'password')
+ product_category = ProductCategory.create!(name: 'Geladeira')
+ #act
+ login_as(user)
+ visit root_path
+ click_on('Ver Categorias de Produtos')
+ click_on('Geladeira')
+
+ click_on('Cadastrar Produto')
+ fill_in "Nome", with: "Geladeira Smart"
+ fill_in "Valor", with: 15500
+ click_on 'Salvar'
+ #assert
+ expect(page).to have_content 'Descrição do Produto'
+ expect(page).to have_content 'Geladeira Smart'
+ expect(page).to have_content 'Preço: R$15500.0'
+ end
+
+ it 'com campos incompletos' do
+ #arrange
+ user = User.create!(email:'user@email.com', password: 'password')
+ #act
+ login_as(user)
+ visit root_path
+ click_on('Cadastrar Produto')
+ fill_in "Nome", with: "Geladeira Smart"
+ fill_in "Preço", with: nil
+ click_on 'Salvar'
+ #assert
+ expect(page).to have_content 'Não foi possível cadastrar esse produto'
+ end
+end