Skip to content

Commit

Permalink
Inicia implementação do breadcrumb.
Browse files Browse the repository at this point in the history
Co-authored-by: Thalyta Lima <[email protected]>
  • Loading branch information
luckslima and thalytalima211 committed Jul 2, 2024
1 parent 4625406 commit ce783d2
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 6 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ruby '3.2.2'
gem 'rails', '~> 7.1.2'

gem 'bootsnap', require: false
gem 'breadcrumbs_on_rails'
gem 'cpf_cnpj'
gem 'cssbundling-rails'
gem 'devise'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ GEM
bigdecimal (3.1.5)
bootsnap (1.17.1)
msgpack (~> 1.2)
breadcrumbs_on_rails (4.1.0)
railties (>= 5.0)
builder (3.2.4)
capybara (3.39.2)
addressable
Expand Down Expand Up @@ -317,6 +319,7 @@ PLATFORMS

DEPENDENCIES
bootsnap
breadcrumbs_on_rails
capybara (>= 2.15)
cpf_cnpj
cssbundling-rails
Expand Down
17 changes: 15 additions & 2 deletions app/controllers/condos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,26 @@ class CondosController < ApplicationController
before_action :authenticate_manager!, only: %i[new create edit update]
before_action :set_condo, only: %i[show edit update]

def show; end
add_breadcrumb 'Home', :root_path
add_breadcrumb 'Condomínios', :condos_path, only: %i[show edit]

def index
@condos = Condo.all
end

def show
add_breadcrumb @condo.name.to_s, condo_path(@condo)
end

def new
add_breadcrumb 'Cadastrar'
@condo = Condo.new
end

def edit; end
def edit
add_breadcrumb @condo.name.to_s, condo_path(@condo)
add_breadcrumb 'Editar'
end

def create
@condo = Condo.new(condo_params)
Expand Down
2 changes: 2 additions & 0 deletions app/views/condos/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%= render 'shared/breadcrumb' %>

<h1>Editar Condomínio:</h1>

<%= render 'form' %>
3 changes: 3 additions & 0 deletions app/views/condos/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= render 'shared/breadcrumb' %>

<h1>Condomínios</h1>
5 changes: 3 additions & 2 deletions app/views/condos/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<h1>Cadastre um novo Condomínio:</h1>
<%= render 'shared/breadcrumb' %>

<%= render 'form' %>
<h1>Cadastre um novo Condomínio:</h1>

<%= render 'form' %>
2 changes: 1 addition & 1 deletion app/views/condos/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

<%= render 'shared/breadcrumb' %>

<h1><%= @condo.name %></h1>
<p>CNPJ: <%= @condo.registration_number %></p>
Expand Down
3 changes: 3 additions & 0 deletions app/views/shared/_breadcrumb.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<ol class="breadcrumb">
<%= render_breadcrumbs :tag => :li, :separator => " > " %>
</ol>
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
resources :common_areas, only: [:show, :edit, :update]
resources :unit_types, only: [:new, :create, :show, :edit, :update]

resources :condos, only: [:new, :create, :show, :edit, :update] do
resources :condos, only: [:index, :new, :create, :show, :edit, :update] do
resources :common_areas, only: [:new, :create]

resources :towers, only: [:new, :create] do
Expand Down
15 changes: 15 additions & 0 deletions spec/system/condos/manager_edit_condo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
expect(current_path).to eq new_manager_session_path
end

it 'and sees breadcrumb' do
manager = create(:manager)
condo = create :condo, name: 'Condominio Residencial Paineiras'

login_as(manager, scope: :manager)
visit edit_condo_path(condo)

within 'ol.breadcrumb' do
expect(page).to have_content 'Home'
expect(page).to have_content 'Condomínios'
expect(page).to have_content 'Condominio Residencial Paineiras'
expect(page).to have_content 'Editar'
end
end

it 'sucessfully' do
manager = create(:manager)
condo = create(:condo)
Expand Down
11 changes: 11 additions & 0 deletions spec/system/condos/manager_register_condo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
click_on 'Criar Condominio'
end

within 'ol.breadcrumb' do
expect(page).to have_content 'Home'
expect(page).to have_content 'Cadastrar'
end

expect(current_path).to eq new_condo_path
expect(page).to have_content('Cadastre um novo Condomínio:')
end
Expand Down Expand Up @@ -38,6 +43,12 @@
click_on 'Salvar'

expect(current_path).to eq condo_path(Condo.last)

within 'ol.breadcrumb' do
expect(page).to have_content 'Home'
expect(page).to have_content 'Condomínios'
expect(page).to have_content 'Condominio Teste'
end
expect(page).to have_content 'Cadastrado com sucesso'
expect(page).to have_content 'Condominio Teste'
expect(page).to have_content 'CNPJ: 38.352.640/0001-33'
Expand Down

0 comments on commit ce783d2

Please sign in to comment.