-
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 branch 'feat/protege-rotas-premium' into feat/priorizando-usuar…
…ios-premium
- Loading branch information
Showing
15 changed files
with
160 additions
and
44 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Subscription < ApplicationRecord | ||
belongs_to :user | ||
enum status: { inactive: 0, active: 10 } | ||
|
||
def active! | ||
self.start_date = Time.zone.now.to_date | ||
super | ||
end | ||
|
||
def inactive! | ||
self.start_date = nil | ||
super | ||
end | ||
end |
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,48 +1,54 @@ | ||
<h2 class="text-center mb-5"><%= InvitationRequest.model_name.human(count: @invitation_request_infos.length) %></h2> | ||
|
||
<div class="container"> | ||
<div class="row justify-content-center gap-5"> | ||
<%= form_with url: invitation_requests_path, method: :get, class: 'col-10 me-5 px-0' do |f| %> | ||
<div class="d-flex gap-2 col-3"> | ||
<%= f.label :filter, class: 'd-none' %> | ||
<%= f.select :filter, | ||
invitation_request_filter_options, | ||
{ include_blank: 'Todas', selected: params[:filter] }, | ||
class: 'form-select' %> | ||
<%= f.submit t(:filter_btn ), class: 'btn btn-sm btn-primary' %> | ||
</div> | ||
<% end %> | ||
<% if current_user.subscription.inactive? %> | ||
<div class="text-center become-premium-div mt-5"> | ||
<h2 class="become-premium-text"><%= t('subscriptions.become') %> <strong><%= t('subscriptions.subscriber') %></strong> <%= t('subscriptions.see_and_request') %></h2 class="become-premium-text"> | ||
</div> | ||
<% else %> | ||
<div class="container"> | ||
<div class="row justify-content-center gap-5"> | ||
<%= form_with url: invitation_requests_path, method: :get, class: 'col-10 me-5 px-0' do |f| %> | ||
<div class="d-flex gap-2 col-3"> | ||
<%= f.label :filter, class: 'd-none' %> | ||
<%= f.select :filter, | ||
invitation_request_filter_options, | ||
{ include_blank: 'Todas', selected: params[:filter] }, | ||
class: 'form-select' %> | ||
<%= f.submit t(:filter_btn ), class: 'btn btn-sm btn-primary' %> | ||
</div> | ||
<% end %> | ||
<% if @invitation_request_infos.any? %> | ||
<% @invitation_request_infos.each do |invitation_request| %> | ||
<div class="col-5 rounded border p-3" id="request_<%= invitation_request.id %>"> | ||
<div class="card-body"> | ||
<div class="d-flex flex-column gap-4"> | ||
<div class="d-flex flex-column gap-2"> | ||
<h4 class="text-break text-dark m-0"><%= invitation_request.project_title %></h4> | ||
<div class="d-flex flex-column gap-2 align-items-start"> | ||
<p class="m-0"><%= invitation_request.project_description %></p> | ||
<p class="m-0 fs-sm badge text-bg-secondary"><%= invitation_request.project_category %></p> | ||
<% if @invitation_request_infos.any? %> | ||
<% @invitation_request_infos.each do |invitation_request| %> | ||
<div class="col-5 rounded border p-3" id="request_<%= invitation_request.id %>"> | ||
<div class="card-body"> | ||
<div class="d-flex flex-column gap-4"> | ||
<div class="d-flex flex-column gap-2"> | ||
<h4 class="text-break text-dark m-0"><%= invitation_request.project_title %></h4> | ||
<div class="d-flex flex-column gap-2 align-items-start"> | ||
<p class="m-0"><%= invitation_request.project_description %></p> | ||
<p class="m-0 fs-sm badge text-bg-secondary"><%= invitation_request.project_category %></p> | ||
</div> | ||
</div> | ||
<div class="d-flex justify-content-between align-items-center"> | ||
<p class="m-0 text-muted"> | ||
<%= t(:time_ago, time: time_ago_in_words(invitation_request.created_at)) %> | ||
</p> | ||
<p class="m-0 text-center <%= css_color_class(invitation_request.status.to_sym) %> fw-bold fs-5"> | ||
<%= InvitationRequest.human_attribute_name("status.#{invitation_request.status}") %> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="d-flex justify-content-between align-items-center"> | ||
<p class="m-0 text-muted"> | ||
<%= t(:time_ago, time: time_ago_in_words(invitation_request.created_at)) %> | ||
</p> | ||
<p class="m-0 text-center <%= css_color_class(invitation_request.status.to_sym) %> fw-bold fs-5"> | ||
<%= InvitationRequest.human_attribute_name("status.#{invitation_request.status}") %> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
<% elsif @error %> | ||
<h3 class="mt-5 alert alert-warning text-center" ><%= t(:project_api_error) %></h3> | ||
<% elsif params[:filter].nil? || params[:filter].blank? %> | ||
<h3 class="mt-5 alert alert-warning text-center" ><%= t(:no_invitation_request_msg) %></h3> | ||
<% else %> | ||
<h3 class="mt-5 alert alert-warning text-center" ><%= t(:no_filter_results_msg) %></h3> | ||
<% end %> | ||
<% elsif @error %> | ||
<h3 class="mt-5 alert alert-warning text-center" ><%= t(:project_api_error) %></h3> | ||
<% elsif params[:filter].nil? || params[:filter].blank? %> | ||
<h3 class="mt-5 alert alert-warning text-center" ><%= t(:no_invitation_request_msg) %></h3> | ||
<% else %> | ||
<h3 class="mt-5 alert alert-warning text-center" ><%= t(:no_filter_results_msg) %></h3> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pt-BR: | ||
activerecord: | ||
models: | ||
subscription: Assinatura | ||
|
||
subscriptions: | ||
become: Torne-se | ||
subscriber: assinante | ||
see_listed_projects: para ver projetos listados | ||
see_and_request: para ver e fazer solicitações |
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,11 @@ | ||
class CreateSubscriptions < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :subscriptions do |t| | ||
t.references :user, null: false, foreign_key: true | ||
t.date :start_date | ||
t.integer :status, default: 0 | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,7 @@ | ||
FactoryBot.define do | ||
factory :subscription do | ||
user { nil } | ||
start_date { "2024-02-14" } | ||
status { 1 } | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Subscription, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |
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,27 @@ | ||
require 'rails_helper' | ||
|
||
describe 'Usuário não assinante' do | ||
it 'acessa página de solicitações e recebe mensagem para se tornar assinante' do | ||
user = create(:user, :free) | ||
|
||
login_as user | ||
visit root_path | ||
click_button class: 'dropdown-toggle' | ||
click_on 'Solicitações de Convite' | ||
|
||
expect(page).to have_current_path(invitation_requests_path) | ||
expect(page).to have_content 'Torne-se assinante para ver e fazer solicitações' | ||
end | ||
|
||
it 'acessa página de projetos e recebe mensagem para se tornar assinante' do | ||
user = create(:user, :free) | ||
|
||
login_as user | ||
visit root_path | ||
click_button class: 'dropdown-toggle' | ||
click_on 'Projetos' | ||
|
||
expect(page).to have_current_path(projects_path) | ||
expect(page).to have_content 'Torne-se assinante para ver projetos listados' | ||
end | ||
end |
Empty file.