-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from TreinaDev/listagem-de-torres
Listagem de torres
- Loading branch information
Showing
4 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
<h1>Torres</h1> | ||
<h1 class="mb-5"> Torres do Condomínio: <%= @condo.name %></h1> | ||
|
||
<div class="list-group list d-flex justify-content-center align-items-center"> | ||
<% @towers.each do |tower| %> | ||
<%= link_to tower.name, tower_path(tower), class:"list-group-item list-group-item-action w-25 p-3 text-center"%> | ||
<% end %> | ||
</div> |
72 changes: 72 additions & 0 deletions
72
spec/system/towers/administrator_view_condo_towers_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
require 'rails_helper' | ||
|
||
describe 'Administrator view list of towers' do | ||
it 'and must be authenticated' do | ||
condo = create(:condo) | ||
|
||
visit condo_towers_path(condo) | ||
|
||
expect(current_path).to eq new_manager_session_path | ||
end | ||
|
||
it 'and only sees the list of towers that belong to the condo' do | ||
condo = create(:condo) | ||
condo2 = create(:condo) | ||
user = create :manager | ||
tower_a = build :tower, name: 'Torre A', condo_id: condo.id | ||
tower_a.generate_floors | ||
tower_b = build :tower, name: 'Torre B', condo_id: condo.id | ||
tower_b.generate_floors | ||
tower_c = build :tower, name: 'Torre C', condo_id: condo.id | ||
tower_c.generate_floors | ||
tower_z = build :tower, name: 'Torre Z', condo_id: condo2.id | ||
tower_z.generate_floors | ||
|
||
login_as user, scope: :manager | ||
visit condo_path(condo) | ||
click_on 'Listar Torres' | ||
|
||
expect(current_path).to eq condo_towers_path(condo) | ||
within '.list' do | ||
expect(page).to have_link 'Torre A' | ||
expect(page).to have_link 'Torre B' | ||
expect(page).to have_link 'Torre C' | ||
expect(page).not_to have_link 'Torre Z' | ||
end | ||
end | ||
|
||
it 'and see a tower details when click on tower´s name' do | ||
condo = create(:condo) | ||
user = create :manager | ||
tower_a = build :tower, name: 'Torre A', condo_id: condo.id | ||
tower_a.generate_floors | ||
|
||
login_as user, scope: :manager | ||
visit condo_path(condo) | ||
click_on 'Listar Torres' | ||
click_on 'Torre A' | ||
|
||
expect(current_path).to eq tower_path(tower_a) | ||
end | ||
|
||
it 'resident can´t see link to list of towers' do | ||
condo = create(:condo) | ||
resident = create :resident | ||
|
||
login_as resident, scope: :resident | ||
visit condo_path(condo) | ||
|
||
expect(current_path).to eq condo_path(condo) | ||
expect(page).not_to have_link 'Listar Torres' | ||
end | ||
|
||
it 'resident can´t access the list of condo´s tower' do | ||
condo = create(:condo) | ||
resident = create :resident | ||
|
||
login_as resident, scope: :resident | ||
visit condo_towers_path(condo) | ||
|
||
expect(current_path).to eq root_path | ||
end | ||
end |