diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb
new file mode 100644
index 0000000000..f33cfae870
--- /dev/null
+++ b/app/controllers/payments_controller.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class PaymentsController < ApplicationController
+ def index
+ authorize :index, policy_class: PaymentPolicy
+ end
+end
diff --git a/app/policies/payment_policy.rb b/app/policies/payment_policy.rb
new file mode 100644
index 0000000000..5f72b4a28d
--- /dev/null
+++ b/app/policies/payment_policy.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class PaymentPolicy < ApplicationPolicy
+ def index?
+ user_owner_or_admin?
+ end
+end
diff --git a/app/views/partial/_navbar.html.erb b/app/views/partial/_navbar.html.erb
index 624abee80a..1bbb4be55e 100644
--- a/app/views/partial/_navbar.html.erb
+++ b/app/views/partial/_navbar.html.erb
@@ -25,6 +25,7 @@
<% if current_user.has_owner_or_admin_role?(current_company) %>
navbar__smaller-screen_titles"><%= t('navbar.reports') %>
navbar__smaller-screen_titles"><%= t('navbar.invoices') %>
+ navbar__smaller-screen_titles"><%= t('navbar.payments') %>
<% end %>
@@ -118,6 +119,11 @@
<%= t('navbar.reports') %>
<% end %>
+ <% if policy(:payment).index? %>
+ navbar__small-screen-second_titles">
+ <%= t('navbar.payments') %>
+
+ <% end %>
@@ -152,6 +158,11 @@
<%= t('navbar.reports') %>
<% end %>
+ <% if policy(:payment).index? %>
+ navbar__large-screen_title">
+ <%= t('navbar.payments') %>
+
+ <% end %>
diff --git a/app/views/payments/index.html.erb b/app/views/payments/index.html.erb
new file mode 100644
index 0000000000..85cb02004b
--- /dev/null
+++ b/app/views/payments/index.html.erb
@@ -0,0 +1 @@
+
Code
diff --git a/config/locales/en.yml b/config/locales/en.yml
index c184b4b2a1..b139d36e04 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -40,6 +40,7 @@ en:
reports: Reports
settings: Settings
team: Team
+ payments: Payments
time_tracking: Time Tracking
view_notifications: View Notifications
projects:
diff --git a/config/routes.rb b/config/routes.rb
index 6d5aa0e732..cfe3e83cf8 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -40,6 +40,7 @@ def draw(routes_name)
resources :projects, only: [:index, :create]
resources :reports, only: [:index]
# resources :invoices, only: [:index, :create]
+ # resources :payments, only: [:index]
resources :workspaces, only: [:update]
get "clients/*path", to: "clients#index", via: :all
@@ -48,6 +49,9 @@ def draw(routes_name)
get "invoices/*path", to: "invoices#index", via: :all
get "invoices", to: "invoices#index"
+ get "payments/*path", to: "payments#index", via: :all
+ get "payments", to: "payments#index"
+
devise_scope :user do
get "profile", to: "users/registrations#edit"
delete "profile/purge_avatar", to: "users/registrations#purge_avatar"
diff --git a/spec/requests/payments/index_spec.rb b/spec/requests/payments/index_spec.rb
new file mode 100644
index 0000000000..40469bf70d
--- /dev/null
+++ b/spec/requests/payments/index_spec.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+RSpec.describe "Payments#index", type: :request do
+ let(:company) { create(:company) }
+ let(:user) { create(:user, current_workspace_id: company.id) }
+
+ context "when user is an admin" do
+ before do
+ create(:company_user, company:, user:)
+ user.add_role :admin, company
+ sign_in user
+ send_request :get, payments_path
+ end
+
+ it "they should be able to visit payments page successfully" do
+ expect(response).to be_successful
+ end
+ end
+
+ context "when the user is an employee" do
+ before do
+ create(:company_user, company:, user:)
+ user.add_role :employee, company
+ sign_in user
+ send_request :get, payments_path
+ end
+
+ it "they should not be permitted to visit index page" do
+ expect(response).to have_http_status(:redirect)
+ expect(flash["alert"]).to eq("You are not authorized to perform this action.")
+ end
+ end
+
+ context "when unauthenticated" do
+ it "is not be permitted to view the payments" do
+ send_request :get, payments_path
+ expect(response).to have_http_status(:redirect)
+ expect(flash["alert"]).to eq("You need to sign in or sign up before continuing.")
+ end
+ end
+end