From 3fcd70593608912aefd83162db432d7fe24c256b Mon Sep 17 00:00:00 2001 From: Eliseu Ramos Date: Tue, 13 Feb 2024 16:15:10 -0300 Subject: [PATCH 1/3] Adiciona filtro de convites cancelados na listagem de convites Co-authored-by: rodrigo.gyodai@gmail.com --- app/views/invitations/index.html.erb | 1 + .../invitations/user_views_invitations_spec.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/app/views/invitations/index.html.erb b/app/views/invitations/index.html.erb index add03a1..8e757c3 100644 --- a/app/views/invitations/index.html.erb +++ b/app/views/invitations/index.html.erb @@ -10,6 +10,7 @@ <%= link_to 'Aceitos', invitations_path(status: :accepted), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'accepted'}" %> <%= link_to 'Recusados', invitations_path(status: :declined), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'declined'}" %> <%= link_to 'Expirados', invitations_path(status: :expired), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'expired'}" %> + <%= link_to 'Cancelados', invitations_path(status: :cancelled), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'cancelled'}" %> diff --git a/spec/system/invitations/user_views_invitations_spec.rb b/spec/system/invitations/user_views_invitations_spec.rb index 56fb48d..73609de 100644 --- a/spec/system/invitations/user_views_invitations_spec.rb +++ b/spec/system/invitations/user_views_invitations_spec.rb @@ -96,6 +96,22 @@ 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 cancelled_invitation.project_title + expect(page).not_to have_content pending_invitation.project_title + end + it 'e nao visualiza dos outros' do user = create(:user) other_user = create(:user) From 5a2e0642abb303c73fcebb1135d2ecf0c02630e9 Mon Sep 17 00:00:00 2001 From: Rodrigo Gyodai Date: Wed, 14 Feb 2024 10:36:57 -0300 Subject: [PATCH 2/3] Torna os testes autocontidos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alteração para explicitar os dados em asserts dos testes Co-authored-by: Eliseu Ramos --- .../user_views_invitations_spec.rb | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/spec/system/invitations/user_views_invitations_spec.rb b/spec/system/invitations/user_views_invitations_spec.rb index 73609de..cf2cfd0 100644 --- a/spec/system/invitations/user_views_invitations_spec.rb +++ b/spec/system/invitations/user_views_invitations_spec.rb @@ -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 @@ -32,39 +32,39 @@ 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', + _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) @@ -72,16 +72,16 @@ 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', + _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) @@ -89,10 +89,10 @@ 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 @@ -100,34 +100,34 @@ 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) + _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 cancelled_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 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 From 2a2dfe7d25829b584e767963e41692c786b3bfd6 Mon Sep 17 00:00:00 2001 From: Rodrigo Gyodai Date: Wed, 14 Feb 2024 10:54:50 -0300 Subject: [PATCH 3/3] =?UTF-8?q?Solu=C3=A7=C3=A3o=20de=20conflitos=20em=20i?= =?UTF-8?q?nvitaion.pt-BR.yml=20e=20invitations/index.html.erb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Eliseu Ramos --- config/locales/invitation.pt-BR.yml | 27 +++++++++++++++++++ .../user_views_invitations_spec.rb | 15 ++++++----- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/config/locales/invitation.pt-BR.yml b/config/locales/invitation.pt-BR.yml index f41ec53..6ffddbe 100644 --- a/config/locales/invitation.pt-BR.yml +++ b/config/locales/invitation.pt-BR.yml @@ -1,10 +1,37 @@ pt-BR: + activerecord: + models: + invitation: + one: Convite + other: Convites + attributes: + invitation: + expiration_date: Expira dia + category: Categoria + message: Mensagem + invitations: decline: error: 'Impossível recusar um convite que não esteja pendente' success: 'Convite recusado com sucesso' processing: 'Convite sendo recusado' + index: + empty_state: Nenhum convite encontrado + all: Todos + pending: Pendentes + accepted: Aceitos + declined: Recusados + expired: Expirados + cancelled: Cancelados + date_error: deve ser maior que a data atual + accepted_status: Aceito + expired_status: Expirado + declined_status: Recusado + cancelled_status: Cancelado + processing_status: Processando invitations_mailer: received_invitation: subject: 'Você recebeu um convite' + body: Você recebeu um convite para participar do projeto %{title}. + diff --git a/spec/system/invitations/user_views_invitations_spec.rb b/spec/system/invitations/user_views_invitations_spec.rb index cf2cfd0..dab5e0b 100644 --- a/spec/system/invitations/user_views_invitations_spec.rb +++ b/spec/system/invitations/user_views_invitations_spec.rb @@ -65,8 +65,8 @@ 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) + project_description: 'Capturar todos os Pokémons', + project_category: 'Collection', colabora_invitation_id: 2) login_as user visit invitations_path @@ -82,8 +82,8 @@ 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) + project_description: 'Capturar todos os Pokémons', + project_category: 'Collection', colabora_invitation_id: 2) login_as user visit invitations_path @@ -116,9 +116,10 @@ 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) + _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