Skip to content

Commit

Permalink
Merge pull request #204 from TreinaDev/feat/adiciona-filtro-cancelado…
Browse files Browse the repository at this point in the history
…s-lista-convites

Adiciona filtro de convites cancelados na listagem de convites

Co-authored-by: Eliseu Ramos <[email protected]>
  • Loading branch information
GyodaiDDA and eliseuramos93 authored Feb 14, 2024
2 parents 1c410e5 + 75abb7c commit 4125d13
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 40 deletions.
3 changes: 2 additions & 1 deletion app/views/invitations/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
<h2 class="text-center"><%= Invitation.model_name.human(count: 2) %></h2>

<div class="nav-scroller border-bottom mb-4">
<nav class="d-flex nav nav-underline">
<nav class="d-flex nav nav-underline">
<%= link_to t('all'), invitations_path, class: "nav-item col nav-link link-body-emphasis" %>
<%= link_to t('.pending'), invitations_path(status: :pending), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'pending'}" %>
<%= link_to t('.accepted'), invitations_path(status: :accepted), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'accepted'}" %>
<%= link_to t('.declined'), invitations_path(status: :declined), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'declined'}" %>
<%= link_to t('.expired'), invitations_path(status: :expired), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'expired'}" %>
<%= link_to t('.cancelled'), invitations_path(status: :cancelled), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'cancelled'}" %>
</nav>
</div>

Expand Down
1 change: 1 addition & 0 deletions config/locales/models/invitation.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pt-BR:
accepted: Aceitos
declined: Recusados
expired: Expirados
cancelled: Cancelados
date_error: deve ser maior que a data atual
accepted_status: Aceito
expired_status: Expirado
Expand Down
95 changes: 56 additions & 39 deletions spec/system/invitations/user_views_invitations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
end

expect(current_path).to eq invitations_path
expect(page).to have_content invitation.project_title
expect(page).to have_content invitation.truncate_description
expect(page).to have_content 'Projeto Cola?Bora!'
expect(page).to have_content 'Um projeto muito legal'
expect(page).to have_content "Expira dia: #{I18n.l(invitation.expiration_date, format: :default)}"
end

Expand All @@ -32,86 +32,103 @@
user = create(:user)
expired_invitation = build(:invitation, profile: user.profile, status: 'expired', expiration_date: 7.days.ago)
expired_invitation.save(validate: false)
pending_invitation = create(:invitation, profile: user.profile, project_title: 'Projeto Gotta cath`em all',
project_description: 'Capturar todos os Pokémons',
project_category: 'Collection', colabora_invitation_id: 2)
_pending_invitation = create(:invitation, profile: user.profile, project_title: 'Projeto Gotta cath`em all',
project_description: 'Capturar todos os Pokémons',
project_category: 'Collection', colabora_invitation_id: 2)

login_as user
visit invitations_path
click_on 'Expirados'

expect(page).to have_content expired_invitation.project_title
expect(page).not_to have_content pending_invitation.project_title
expect(page).to have_content 'Projeto Cola?Bora!'
expect(page).not_to have_content 'Projeto Gotta cath`em all'
end

it 'e visualiza convites pendentes' do
user = create(:user)
accepted_invitation = create(:invitation, profile: user.profile, status: 'accepted')
pending_invitation = create(:invitation, profile: user.profile, project_title: 'Projeto Gotta cath`em all',
project_description: 'Capturar todos os Pokémons',
project_category: 'Collection', colabora_invitation_id: 2)
_accepted_invitation = create(:invitation, profile: user.profile, status: 'accepted')
_pending_invitation = create(:invitation, profile: user.profile, project_title: 'Projeto Gotta cath`em all',
project_description: 'Capturar todos os Pokémons',
project_category: 'Collection', colabora_invitation_id: 2)

login_as user
visit invitations_path
click_on 'Pendentes'

expect(page).not_to have_content accepted_invitation.project_title
expect(page).not_to have_content accepted_invitation.truncate_description
expect(page).to have_content pending_invitation.project_title
expect(page).to have_content pending_invitation.truncate_description
expect(page).not_to have_content 'Projeto Cola?Bora!'
expect(page).not_to have_content 'Um projeto muito legal'
expect(page).to have_content 'Projeto Gotta cath`em all'
expect(page).to have_content 'Capturar todos os Pokémons'
end

it 'e visualiza convites aceitos' do
user = create(:user)
accepted_invitation = create(:invitation, profile: user.profile, status: 'accepted')
pending_invitation = create(:invitation, profile: user.profile, project_title: 'Projeto Gotta cath`em all',
project_description: 'Capturar todos os Pokémons',
project_category: 'Collection', colabora_invitation_id: 2)
_accepted_invitation = create(:invitation, profile: user.profile, status: 'accepted')
_pending_invitation = create(:invitation, profile: user.profile, project_title: 'Projeto Gotta cath`em all',
project_description: 'Capturar todos os Pokémons',
project_category: 'Collection', colabora_invitation_id: 2)

login_as user
visit invitations_path
click_on 'Aceitos'

expect(page).to have_content accepted_invitation.project_title
expect(page).to have_content accepted_invitation.truncate_description
expect(page).not_to have_content pending_invitation.project_title
expect(page).not_to have_content pending_invitation.truncate_description
expect(page).to have_content 'Projeto Cola?Bora!'
expect(page).to have_content 'Um projeto muito legal'
expect(page).not_to have_content 'Projeto Gotta cath`em all'
expect(page).not_to have_content 'Capturar todos os Pokémons'
end

it 'e visualiza convites rejeitados' do
user = create(:user)
declined_invitation = create(:invitation, profile: user.profile, status: 'declined')
pending_invitation = create(:invitation, profile: user.profile, project_title: 'Projeto Gotta cath`em all',
project_description: 'Capturar todos os Pokémons',
project_category: 'Collection', colabora_invitation_id: 2)
_declined_invitation = create(:invitation, profile: user.profile, status: 'declined')
_pending_invitation = create(:invitation, profile: user.profile, project_title: 'Projeto Gotta cath`em all',
project_description: 'Capturar todos os Pokémons',
project_category: 'Collection', colabora_invitation_id: 2)

login_as user
visit invitations_path
click_on 'Recusados'

expect(page).to have_content declined_invitation.project_title
expect(page).to have_content declined_invitation.truncate_description
expect(page).not_to have_content pending_invitation.project_title
expect(page).not_to have_content pending_invitation.truncate_description
expect(page).to have_content 'Projeto Cola?Bora!'
expect(page).to have_content 'Um projeto muito legal'
expect(page).not_to have_content 'Projeto Gotta cath`em all'
expect(page).not_to have_content 'Capturar todos os Pokémons'
end
end

it 'e visualiza convites cancelados' do
user = create(:user)
cancelled_invitation = build(:invitation, profile: user.profile, status: 'cancelled')
cancelled_invitation.save(validate: false)
_pending_invitation = create(:invitation, profile: user.profile, project_title: 'Projeto Gotta cath`em all',
project_description: 'Capturar todos os Pokémons',
project_category: 'Collection', colabora_invitation_id: 2)

login_as user
visit invitations_path
click_on 'Cancelados'

expect(page).to have_content 'Projeto Cola?Bora!'
expect(page).not_to have_content 'Projeto Gotta cath`em all'
end

it 'e nao visualiza dos outros' do
user = create(:user)
other_user = create(:user)
invitation = create(:invitation, profile: user.profile)
other_user_invitation = create(:invitation, profile: other_user.profile, project_title: 'Projeto Gotta cath`em all',
project_description: 'Capturar todos os Pokémons',
project_category: 'Collection', colabora_invitation_id: 2)
_invitation = create(:invitation, profile: user.profile)
_other_user_invitation = create(:invitation,
profile: other_user.profile, project_title: 'Projeto Gotta cath`em all',
project_description: 'Capturar todos os Pokémons',
project_category: 'Collection', colabora_invitation_id: 2)

login_as user

visit invitations_path

expect(page).to have_content invitation.project_title
expect(page).to have_content invitation.truncate_description
expect(page).not_to have_content other_user_invitation.project_title
expect(page).not_to have_content other_user_invitation.truncate_description
expect(page).to have_content 'Projeto Cola?Bora!'
expect(page).to have_content 'Um projeto muito legal'
expect(page).not_to have_content 'Projeto Gotta cath`em all'
expect(page).not_to have_content 'Capturar todos os Pokémons'
end

it 'mas precisa estar logado' do
Expand Down

0 comments on commit 4125d13

Please sign in to comment.