diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 6ef68fd6..7b596d66 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -9,7 +9,7 @@ class ApplicationController < ActionController::Base
if current_user.nil?
redirect_to login_path
else
- redirect_to request.referer || root_path
+ redirect_to request.referer || thaalis_all_path(CURR_YR)
end
end
@@ -20,6 +20,6 @@ def current_user
end
def logged_in?
- redirect_to root_path, notice: t("flash.active_session") if session[:user_id]
+ redirect_to thaalis_all_path(CURR_YR), notice: t("flash.active_session") if session[:user_id]
end
end
diff --git a/app/controllers/sabeels_controller.rb b/app/controllers/sabeels_controller.rb
index 430e3d2e..d08551fa 100644
--- a/app/controllers/sabeels_controller.rb
+++ b/app/controllers/sabeels_controller.rb
@@ -43,24 +43,7 @@ def update
def destroy
@sabeel.destroy
respond_to do |format|
- format.all { redirect_to root_path(format: :html), success: t(".success") }
- end
- end
-
- def stats
- @apts = {}
-
- APARTMENTS.each do |apartment|
- total_sabeels = Sabeel.send(apartment)
- active_thaalis = total_sabeels.taking_thaali
- inactive = total_sabeels.not_taking_thaali
- @apts[apartment] = {}
- @apts[apartment].store(:active_thaalis, active_thaalis.length)
- @apts[apartment].store(:total_sabeels, total_sabeels.length)
- @apts[apartment].store(:inactive_thaalis, inactive.length)
- SIZES.each do |size|
- @apts[apartment].store(size.to_sym, active_thaalis.with_thaali_size(size).length)
- end
+ format.all { redirect_to sabeels_path(format: :html), success: t(".success") }
end
end
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index c90332a4..4cb354f8 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -10,7 +10,7 @@ def create
session[:user_id] = user.id
respond_to do |format|
- format.all { redirect_to root_path(format: :html), success: t(".success") }
+ format.all { redirect_to thaalis_all_path(CURR_YR, format: :html), success: t(".success") }
end
else
flash.now.alert = t(".error")
diff --git a/app/controllers/statistics_controller.rb b/app/controllers/statistics_controller.rb
new file mode 100644
index 00000000..3d72bece
--- /dev/null
+++ b/app/controllers/statistics_controller.rb
@@ -0,0 +1,40 @@
+class StatisticsController < ApplicationController
+ def sabeels
+ authorize! :read, :thaalis
+
+ @apts = {}
+
+ APARTMENTS.each do |apartment|
+ total_sabeels = Sabeel.send(apartment)
+ active_thaalis = total_sabeels.taking_thaali
+ inactive = total_sabeels.not_taking_thaali
+ @apts[apartment] = {}
+ @apts[apartment].store(:active_thaalis, active_thaalis.length)
+ @apts[apartment].store(:total_sabeels, total_sabeels.length)
+ @apts[apartment].store(:inactive_thaalis, inactive.length)
+ SIZES.each do |size|
+ @apts[apartment].store(size.to_sym, active_thaalis.with_thaali_size(size).length)
+ end
+ end
+ end
+
+ def thaalis
+ authorize! :read, :thaalis
+
+ years = Thaali.distinct.pluck(:year)
+ @years = {}
+
+ years.each do |y|
+ thaalis = Thaali.for_year(y).preload(:transactions)
+ @years[y] = {}
+ @years[y].store(:total, thaalis.sum(:total))
+ @years[y].store(:balance, thaalis.sum(&:balance))
+ @years[y].store(:count, thaalis.count)
+ @years[y].store(:pending, Thaali.dues_unpaid_for(y).length)
+ @years[y].store(:complete, Thaali.dues_cleared_in(y).length)
+ SIZES.each do |size|
+ @years[y].store(size.to_sym, thaalis.send(size).count)
+ end
+ end
+ end
+end
diff --git a/app/controllers/thaalis_controller.rb b/app/controllers/thaalis_controller.rb
index c8063f7c..0fe84152 100644
--- a/app/controllers/thaalis_controller.rb
+++ b/app/controllers/thaalis_controller.rb
@@ -4,12 +4,6 @@ class ThaalisController < ApplicationController
before_action :check_thaali_for_current_year, only: [:new]
before_action :set_year, only: %i[complete pending all]
- def index
- @q = Thaali.for_year(CURR_YR).ransack(params[:q])
- query = @q.result(distinct: true)
- turbo_load(query)
- end
-
def show
@transactions = @thaali.transactions.load
end
@@ -56,24 +50,6 @@ def destroy
redirect_to sabeel_path(@thaali.sabeel), success: t(".success")
end
- def stats
- years = Thaali.distinct.pluck(:year)
- @years = {}
-
- years.each do |y|
- thaalis = Thaali.for_year(y).preload(:transactions)
- @years[y] = {}
- @years[y].store(:total, thaalis.sum(:total))
- @years[y].store(:balance, thaalis.sum(&:balance))
- @years[y].store(:count, thaalis.count)
- @years[y].store(:pending, Thaali.dues_unpaid_for(y).length)
- @years[y].store(:complete, Thaali.dues_cleared_in(y).length)
- SIZES.each do |size|
- @years[y].store(size.to_sym, thaalis.send(size).count)
- end
- end
- end
-
def complete
thaalis = Thaali.dues_cleared_in(@year)
turbo_load(thaalis)
@@ -85,8 +61,9 @@ def pending
end
def all
- thaalis = Thaali.for_year(@year)
- turbo_load(thaalis)
+ @q = Thaali.for_year(@year).ransack(params[:q])
+ query = @q.result(distinct: true)
+ turbo_load(query)
end
private
diff --git a/app/models/ability.rb b/app/models/ability.rb
index d4911d7e..b529d02b 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -9,23 +9,26 @@ class Ability
def initialize(user)
return if user.blank?
+ can :read, :thaalis
+ can :read, :sabeels
+
+ if %w[admin member].include?(user.role)
+ can :manage, Sabeel
+ can :manage, Thaali
+ can :manage, Transaction
+ end
+
case user.role
when "admin"
can :manage, User, id: user.id
can [:show, :destroy], User
- can :manage, Sabeel
- can :manage, Thaali
- can :manage, Transaction
when "member"
- can [:show, :update, :destroy], User, id: user.id
- can :manage, Sabeel
cannot [:create, :destroy], Sabeel
- can :manage, Thaali
- can :manage, Transaction
+ can [:show, :update, :destroy], User, id: user.id
when "viewer"
- can [:read, :stats, :active, :inactive], Sabeel
- can [:read, :stats, :complete, :pending, :all], Thaali
- can [:all, :show], Transaction
+ can [:read, :active, :inactive], Sabeel
+ can [:read, :complete, :pending, :all], Thaali
+ can [:read, :all], Transaction
end
end
end
diff --git a/app/views/shared/navbar/_navbar.html.erb b/app/views/shared/navbar/_navbar.html.erb
index 07d5c97f..d541495b 100644
--- a/app/views/shared/navbar/_navbar.html.erb
+++ b/app/views/shared/navbar/_navbar.html.erb
@@ -3,7 +3,7 @@
<%# * Navbar logo %>
- <%= link_to image_tag("logo.png", size: "30", alt: "logo"), root_path, class: "navbar-brand" %>
+ <%= link_to image_tag("logo.png", size: "30", alt: "logo"), thaalis_all_path(CURR_YR), class: "navbar-brand" %>
- <%= link_to_if(year == CURR_YR, "Total Thaalis: #{values[:count]}", root_path, class: "fw-bold text-success fs-5") do %>
- <%= link_to "Total Thaalis: #{values[:count]}", thaalis_all_path(year), class: "fw-bold text-success fs-5" %>
- <% end %>
+ <%= link_to "Total Thaalis: #{values[:count]}", thaalis_all_path(year), class: "fw-bold text-success fs-5" %>
<% end %>
diff --git a/app/views/thaalis/all.html.erb b/app/views/thaalis/all.html.erb
index e3686b11..a3f38936 100644
--- a/app/views/thaalis/all.html.erb
+++ b/app/views/thaalis/all.html.erb
@@ -3,5 +3,8 @@
<%# * Heading %>
Thaalis in <%= @year %>
+<%# * search %>
+<%= render "shared/search", attr_name: "Thaali no.", url: thaalis_all_path(@year), search: :number_eq %>
+
<%# * show all thaalis %>
-<%= render "shared/results", instances: @thaalis, model: "thaalis", url: thaalis_all_path(format: :turbo_stream) %>
+<%= render "shared/results", instances: @thaalis, model: "thaalis", url: thaalis_all_path(format: :turbo_stream, q: params[:q]&.to_unsafe_h) %>
diff --git a/app/views/thaalis/all.turbo_stream.erb b/app/views/thaalis/all.turbo_stream.erb
index d4b9a3f5..366a6a46 100644
--- a/app/views/thaalis/all.turbo_stream.erb
+++ b/app/views/thaalis/all.turbo_stream.erb
@@ -4,4 +4,4 @@
<%= turbo_stream.append :thaalis, partial: "shared/no_results" %>
<% end %>
-<%= render "shared/pagy", src: thaalis_all_path(format: :turbo_stream, page: @pagy.next) %>
\ No newline at end of file
+<%= render "shared/pagy", src: thaalis_all_path(format: :turbo_stream, page: @pagy.next, q: params[:q]&.to_unsafe_h) %>
\ No newline at end of file
diff --git a/app/views/thaalis/index.html.erb b/app/views/thaalis/index.html.erb
deleted file mode 100644
index 0b60b4fa..00000000
--- a/app/views/thaalis/index.html.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-<% content_for :title, "Thaalis" %>
-
-<%# * Heading %>
-Thaalis in <%= CURR_YR %>
-
-<%# * search %>
-<%= render "shared/search", attr_name: "Thaali no.", url: root_path, search: :number_eq %>
-
-<%# * show all Current Year Thaalis %>
-<%= render "shared/results", model: "thaalis", url: root_path(format: :turbo_stream, q: params[:q]&.to_unsafe_h) %>
diff --git a/app/views/thaalis/index.turbo_stream.erb b/app/views/thaalis/index.turbo_stream.erb
deleted file mode 100644
index 14077ec4..00000000
--- a/app/views/thaalis/index.turbo_stream.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-<% if @thaalis.any? %>
- <%= turbo_stream.append :thaalis, partial: "thaalis" %>
-<% else %>
- <%= turbo_stream.append :thaalis, partial: "shared/no_results" %>
-<% end %>
-
-<%= render "shared/pagy", src: root_path(format: :turbo_stream, page: @pagy.next, q: params[:q]&.to_unsafe_h) %>
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 48e4a2f8..5c981c8a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -2,25 +2,18 @@
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Defines the root path route ("/")
- root "thaalis#index"
+ root "pages#home"
# * CUSTOM ROUTES
- # pages
- get "/home", to: "pages#home"
# session
get "/login", to: "sessions#new"
post "/signup", to: "sessions#create"
delete "/destroy", to: "sessions#destroy"
- # thaali
- get "/thaalis/stats", to: "thaalis#stats", as: :thaalis_stats
-
# * RESOURCEFUL ROUTES
resources :users
resources :sabeels, shallow: true do
- get :stats, on: :collection
-
resources :thaalis, except: %i[index] do
resources :transactions, except: %i[index]
end
@@ -31,6 +24,11 @@
get :inactive
end
+ namespace :statistics do
+ get :thaalis
+ get :sabeels
+ end
+
namespace :thaalis, path: "thaalis/:year" do
get :complete
get :pending
diff --git a/spec/features/layout/navbar_spec.rb b/spec/features/layout/navbar_spec.rb
index 95cf94c0..1949301b 100644
--- a/spec/features/layout/navbar_spec.rb
+++ b/spec/features/layout/navbar_spec.rb
@@ -7,7 +7,7 @@
describe "logged in" do
before do
page.set_rack_session(user_id: user.id)
- visit root_path
+ visit thaalis_all_path(CURR_YR)
end
describe "any user can view" do
@@ -16,11 +16,11 @@
# * Statistics
describe "Statistics dropdown menu" do
it do
- within("#statistics") { expect(page).to have_link("Sabeels", href: stats_sabeels_path) }
+ within("#statistics") { expect(page).to have_link("Sabeels", href: statistics_sabeels_path) }
end
it do
- within("#statistics") { expect(page).to have_link("Thaalis", href: thaalis_stats_path) }
+ within("#statistics") { expect(page).to have_link("Thaalis", href: statistics_thaalis_path) }
end
end
@@ -31,7 +31,7 @@
end
it do
- within("#resources") { expect(page).to have_link("Thaalis", href: root_path) }
+ within("#resources") { expect(page).to have_link("Thaalis", href: thaalis_all_path(CURR_YR)) }
end
it do
diff --git a/spec/features/pages/home_spec.rb b/spec/features/pages/home_spec.rb
index 20c4a4e1..ece15dcb 100644
--- a/spec/features/pages/home_spec.rb
+++ b/spec/features/pages/home_spec.rb
@@ -3,7 +3,7 @@
require "rails_helper"
RSpec.describe "Page Home template, displays" do
- before { visit home_path }
+ before { visit root_path }
it "logo" do
within("#home__header") { expect(page).to have_css("img[src*='fmb-logo-full']") }
diff --git a/spec/features/sabeels/destroy_spec.rb b/spec/features/sabeels/destroy_spec.rb
index 22f75239..407496c0 100644
--- a/spec/features/sabeels/destroy_spec.rb
+++ b/spec/features/sabeels/destroy_spec.rb
@@ -28,7 +28,7 @@
context "when clicking 'delete button'" do
before { click_button "Yes, delete it!" }
- it { expect(page).to have_current_path root_path, ignore_query: true }
+ it { expect(page).to have_current_path sabeels_path(format: :html) }
it { expect(page).to have_content("Sabeel deleted") }
end
diff --git a/spec/features/sabeels/new_spec.rb b/spec/features/sabeels/new_spec.rb
index dddb548b..f066aa2f 100644
--- a/spec/features/sabeels/new_spec.rb
+++ b/spec/features/sabeels/new_spec.rb
@@ -48,6 +48,6 @@
let(:user) { create(:user_member_or_viewer) }
it { expect(page).to have_content("Not Authorized") }
- it { expect(page).to have_current_path root_path }
+ it { expect(page).to have_current_path thaalis_all_path(CURR_YR) }
end
end
diff --git a/spec/features/sessions/destroy_spec.rb b/spec/features/sessions/destroy_spec.rb
index 72ed4280..fa863545 100644
--- a/spec/features/sessions/destroy_spec.rb
+++ b/spec/features/sessions/destroy_spec.rb
@@ -7,7 +7,7 @@
before do
page.set_rack_session(user_id: user.id)
- visit root_path
+ visit thaalis_all_path(CURR_YR)
click_link "Log out"
end
diff --git a/spec/features/sessions/new_spec.rb b/spec/features/sessions/new_spec.rb
index 6b19ac52..df95190c 100644
--- a/spec/features/sessions/new_spec.rb
+++ b/spec/features/sessions/new_spec.rb
@@ -26,8 +26,8 @@
click_button "Login"
end
- it "redirects to root path after login" do
- expect(page).to have_current_path root_path, ignore_query: true
+ it "redirects to thaalis_all_path after login" do
+ expect(page).to have_current_path thaalis_all_path(CURR_YR, format: :html)
end
it "displays welcome message" do
diff --git a/spec/features/sabeels/stats_spec.rb b/spec/features/statistics/sabeels_spec.rb
similarity index 98%
rename from spec/features/sabeels/stats_spec.rb
rename to spec/features/statistics/sabeels_spec.rb
index a1e70ebd..af886499 100644
--- a/spec/features/sabeels/stats_spec.rb
+++ b/spec/features/statistics/sabeels_spec.rb
@@ -9,7 +9,7 @@
page.set_rack_session(user_id: user.id)
create_list(:burhani_sabeel_taking_thaali, 2)
create_list(:burhani_sabeel_took_thaali, 2)
- visit stats_sabeels_path
+ visit statistics_sabeels_path
end
# * ALL user types
diff --git a/spec/features/thaalis/stats_spec.rb b/spec/features/statistics/thaalis_spec.rb
similarity index 98%
rename from spec/features/thaalis/stats_spec.rb
rename to spec/features/statistics/thaalis_spec.rb
index 9c76599f..f6112b3a 100644
--- a/spec/features/thaalis/stats_spec.rb
+++ b/spec/features/statistics/thaalis_spec.rb
@@ -10,7 +10,7 @@
page.set_rack_session(user_id: user.id)
create_list(:taking_thaali, 2)
create_list(:taking_thaali_dues_cleared, 2)
- visit thaalis_stats_path
+ visit statistics_thaalis_path
end
it { expect(page).to have_title "Thaali Statistics" }
diff --git a/spec/features/thaalis/all_spec.rb b/spec/features/thaalis/all_spec.rb
index 4883e118..8ea005fa 100644
--- a/spec/features/thaalis/all_spec.rb
+++ b/spec/features/thaalis/all_spec.rb
@@ -5,19 +5,31 @@
RSpec.describe "Thaali all template" do
let(:user) { create(:user) }
+ let(:year) { [CURR_YR, PREV_YR].sample }
let(:thaalis) { Thaali.first(2) }
before do
page.set_rack_session(user_id: user.id)
- create_list(:took_thaali, 2)
+ create_list(:thaali, 2, year:)
- visit thaalis_all_path(PREV_YR)
+ visit thaalis_all_path(year)
end
# * ALL user types
describe "visited by any user type can", :js do
- it { expect(page).to have_title "Thaalis in #{PREV_YR}" }
+ it { expect(page).to have_title "Thaalis in #{year}" }
it_behaves_like "view thaali records"
+
+ describe "search" do
+ context "with thaali number" do
+ let(:thaali_number) { Thaali.first.number }
+
+ before { fill_in "q_number_eq", with: thaali_number }
+
+ it { within("div#thaalis") { expect(page).to have_content(thaali_number) } }
+ it { within("div#thaalis") { expect(page).not_to have_content(Thaali.last.number) } }
+ end
+ end
end
end
diff --git a/spec/features/thaalis/index_spec.rb b/spec/features/thaalis/index_spec.rb
deleted file mode 100644
index ed5d1b89..00000000
--- a/spec/features/thaalis/index_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# frozen_string_literal: true
-
-require "rails_helper"
-require_relative "thaali_helpers"
-
-RSpec.describe "Thaali index template" do
- let(:user) { create(:user) }
- let(:thaalis) { Thaali.first(2) }
-
- before do
- page.set_rack_session(user_id: user.id)
- create_list(:taking_thaali, 2)
-
- visit root_path
- end
-
- # * ALL user types
- describe "visited by any user type can", :js do
- it { expect(page).to have_title "Thaalis" }
-
- it_behaves_like "view thaali records"
-
- describe "search" do
- context "with thaali number" do
- let(:thaali_number) { Thaali.first.number }
-
- before { fill_in "q_number_eq", with: thaali_number }
-
- it { within("div#thaalis") { expect(page).to have_content(thaali_number) } }
- it { within("div#thaalis") { expect(page).not_to have_content(Thaali.last.number) } }
- end
- end
- end
-end
diff --git a/spec/features/users/index_spec.rb b/spec/features/users/index_spec.rb
index c29aa60b..f0634ec4 100644
--- a/spec/features/users/index_spec.rb
+++ b/spec/features/users/index_spec.rb
@@ -41,6 +41,6 @@
let(:user) { create(:user_member_or_viewer) }
it { expect(page).to have_content("Not Authorized") }
- it { expect(page).to have_current_path root_path }
+ it { expect(page).to have_current_path thaalis_all_path(CURR_YR) }
end
end
diff --git a/spec/features/users/new_spec.rb b/spec/features/users/new_spec.rb
index 93a2d366..5eafc564 100644
--- a/spec/features/users/new_spec.rb
+++ b/spec/features/users/new_spec.rb
@@ -10,7 +10,7 @@
Role.insert_all([{name: "member"}, {name: "viewer"}])
# rubocop:enable Rails/SkipsModelValidations
page.set_rack_session(user_id: user.id)
- visit root_path
+ visit thaalis_all_path(CURR_YR)
end
# * Admin
@@ -55,6 +55,6 @@
before { visit new_user_path }
it { expect(page).to have_content("Not Authorized") }
- it { expect(page).to have_current_path root_path }
+ it { expect(page).to have_current_path thaalis_all_path(CURR_YR) }
end
end
diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb
index 739587fa..deb9c6e6 100644
--- a/spec/features/users/show_spec.rb
+++ b/spec/features/users/show_spec.rb
@@ -33,6 +33,6 @@
let(:user) { create(:viewer_user) }
it { expect(page).to have_content("Not Authorized") }
- it { expect(page).to have_current_path root_path }
+ it { expect(page).to have_current_path thaalis_all_path(CURR_YR) }
end
end
diff --git a/spec/requests/pages/home_spec.rb b/spec/requests/pages/home_spec.rb
index 428b2db2..7b4679c5 100644
--- a/spec/requests/pages/home_spec.rb
+++ b/spec/requests/pages/home_spec.rb
@@ -5,7 +5,7 @@
RSpec.describe "Pages home request" do
# * ACCESSIBLE
context "when made by logged out user" do
- before { get home_path }
+ before { get root_path }
it { expect(response).to render_template(:home) }
it { expect(response).to have_http_status(:ok) }
@@ -17,10 +17,10 @@
before do
post signup_path, params: {sessions: user.attributes.merge({password: user.password})}
- get home_path
+ get root_path
end
- it { expect(response).to redirect_to root_path }
+ it { expect(response).to redirect_to thaalis_all_path(CURR_YR) }
it { expect(response).to have_http_status(:found) }
end
end
diff --git a/spec/requests/sabeels/edit_spec.rb b/spec/requests/sabeels/edit_spec.rb
index f96dcb96..1a36329f 100644
--- a/spec/requests/sabeels/edit_spec.rb
+++ b/spec/requests/sabeels/edit_spec.rb
@@ -24,7 +24,7 @@
let(:user) { create(:viewer_user) }
it { expect(response).to have_http_status(:found) }
- it { expect(response).to redirect_to root_path }
+ it { expect(response).to redirect_to thaalis_all_path(CURR_YR) }
end
# * ACCESSIBLE
diff --git a/spec/requests/sabeels/new_spec.rb b/spec/requests/sabeels/new_spec.rb
index 8f1b1c96..ef6bcd9b 100644
--- a/spec/requests/sabeels/new_spec.rb
+++ b/spec/requests/sabeels/new_spec.rb
@@ -22,7 +22,7 @@
let(:user) { create(:user_member_or_viewer) }
it { expect(response).to have_http_status(:found) }
- it { expect(response).to redirect_to root_path }
+ it { expect(response).to redirect_to thaalis_all_path(CURR_YR) }
end
# * ACCESSIBLE
diff --git a/spec/requests/sessions/new_spec.rb b/spec/requests/sessions/new_spec.rb
index 07e9e166..d916716d 100644
--- a/spec/requests/sessions/new_spec.rb
+++ b/spec/requests/sessions/new_spec.rb
@@ -20,7 +20,7 @@
get login_path
end
- it { expect(response).to redirect_to root_path }
+ it { expect(response).to redirect_to thaalis_all_path(CURR_YR) }
it { expect(response).to have_http_status(:found) }
end
end
diff --git a/spec/requests/sabeels/stats_spec.rb b/spec/requests/statistics/sabeels_spec.rb
similarity index 80%
rename from spec/requests/sabeels/stats_spec.rb
rename to spec/requests/statistics/sabeels_spec.rb
index 5f13df3e..50098975 100644
--- a/spec/requests/sabeels/stats_spec.rb
+++ b/spec/requests/statistics/sabeels_spec.rb
@@ -5,7 +5,7 @@
RSpec.describe "Sabeel Stats request" do
# * NOT ACCESSIBLE
context "when made by logged out user" do
- before { get stats_sabeels_path }
+ before { get statistics_sabeels_path }
it { expect(response).to have_http_status(:found) }
it { expect(response).to redirect_to login_path }
@@ -17,10 +17,10 @@
before do
post signup_path, params: {sessions: user.attributes.merge({password: user.password})}
- get stats_sabeels_path
+ get statistics_sabeels_path
end
- it { expect(response).to render_template(:stats) }
+ it { expect(response).to render_template(:sabeels) }
it { expect(response).to have_http_status(:ok) }
end
end
diff --git a/spec/requests/thaalis/stats_spec.rb b/spec/requests/statistics/thaalis_spec.rb
similarity index 75%
rename from spec/requests/thaalis/stats_spec.rb
rename to spec/requests/statistics/thaalis_spec.rb
index 12389df7..261ba268 100644
--- a/spec/requests/thaalis/stats_spec.rb
+++ b/spec/requests/statistics/thaalis_spec.rb
@@ -2,10 +2,10 @@
require "rails_helper"
-RSpec.describe "Thaali Stats request" do
+RSpec.describe "Thaali request" do
# * NOT ACCESSIBLE
context "when made by logged out user" do
- before { get thaalis_stats_path }
+ before { get statistics_thaalis_path }
it { expect(response).to have_http_status(:found) }
it { expect(response).to redirect_to login_path }
@@ -17,10 +17,10 @@
before do
post signup_path, params: {sessions: user.attributes.merge({password: user.password})}
- get thaalis_stats_path
+ get statistics_thaalis_path
end
- it { expect(response).to render_template(:stats) }
+ it { expect(response).to render_template(:thaalis) }
it { expect(response).to have_http_status(:ok) }
end
end
diff --git a/spec/requests/thaalis/edit_spec.rb b/spec/requests/thaalis/edit_spec.rb
index 0d572ad4..3818d67c 100644
--- a/spec/requests/thaalis/edit_spec.rb
+++ b/spec/requests/thaalis/edit_spec.rb
@@ -24,7 +24,7 @@
let(:user) { create(:viewer_user) }
it { expect(response).to have_http_status(:found) }
- it { expect(response).to redirect_to root_path }
+ it { expect(response).to redirect_to thaalis_all_path(CURR_YR) }
end
# * ACCESSIBLE
diff --git a/spec/requests/thaalis/index_spec.rb b/spec/requests/thaalis/index_spec.rb
deleted file mode 100644
index 935d07ca..00000000
--- a/spec/requests/thaalis/index_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# frozen_string_literal: true
-
-require "rails_helper"
-
-RSpec.describe "Thaali Index request" do
- # * NOT ACCESSIBLE
- context "when made by logged out user" do
- before { get root_path }
-
- it { expect(response).to have_http_status(:found) }
- it { expect(response).to redirect_to login_path }
- end
-
- # * ACCESSIBLE
- context "when made by any logged in user" do
- let(:user) { create(:user) }
-
- before do
- post signup_path, params: {sessions: user.attributes.merge({password: user.password})}
- get root_path
- end
-
- it { expect(response).to render_template(:index) }
- it { expect(response).to have_http_status(:ok) }
- end
-end
diff --git a/spec/requests/thaalis/new_spec.rb b/spec/requests/thaalis/new_spec.rb
index d46b26b9..e5a2deac 100644
--- a/spec/requests/thaalis/new_spec.rb
+++ b/spec/requests/thaalis/new_spec.rb
@@ -24,7 +24,7 @@
let(:user) { create(:viewer_user) }
it { expect(response).to have_http_status(:found) }
- it { expect(response).to redirect_to root_path }
+ it { expect(response).to redirect_to thaalis_all_path(CURR_YR) }
end
# * ACCESSIBLE
diff --git a/spec/requests/transactions/edit_spec.rb b/spec/requests/transactions/edit_spec.rb
index 85360213..ff2f3d4c 100644
--- a/spec/requests/transactions/edit_spec.rb
+++ b/spec/requests/transactions/edit_spec.rb
@@ -24,7 +24,7 @@
let(:user) { create(:viewer_user) }
it { expect(response).to have_http_status(:found) }
- it { expect(response).to redirect_to root_path }
+ it { expect(response).to redirect_to thaalis_all_path(CURR_YR) }
end
# * ACCESSIBLE
diff --git a/spec/requests/transactions/new_spec.rb b/spec/requests/transactions/new_spec.rb
index 62d7c547..c230bff4 100644
--- a/spec/requests/transactions/new_spec.rb
+++ b/spec/requests/transactions/new_spec.rb
@@ -25,7 +25,7 @@
let(:thaali) { create(:thaali) }
it { expect(response).to have_http_status(:found) }
- it { expect(response).to redirect_to root_path }
+ it { expect(response).to redirect_to thaalis_all_path(CURR_YR) }
end
# * ACCESSIBLE
diff --git a/spec/requests/users/edit_spec.rb b/spec/requests/users/edit_spec.rb
index b4710919..77fb78ad 100644
--- a/spec/requests/users/edit_spec.rb
+++ b/spec/requests/users/edit_spec.rb
@@ -24,7 +24,7 @@
let(:user) { create(:viewer_user) }
it { expect(response).to have_http_status(:found) }
- it { expect(response).to redirect_to root_path }
+ it { expect(response).to redirect_to thaalis_all_path(CURR_YR) }
end
# * ACCESSIBLE
diff --git a/spec/requests/users/index_spec.rb b/spec/requests/users/index_spec.rb
index b1ad34f4..fa31c594 100644
--- a/spec/requests/users/index_spec.rb
+++ b/spec/requests/users/index_spec.rb
@@ -24,7 +24,7 @@
let(:user) { create(:user_member_or_viewer) }
it { expect(response).to have_http_status(:found) }
- it { expect(response).to redirect_to root_path }
+ it { expect(response).to redirect_to thaalis_all_path(CURR_YR) }
end
# * ACCESSIBLE
diff --git a/spec/requests/users/new_spec.rb b/spec/requests/users/new_spec.rb
index ec2edbff..9ec375b7 100644
--- a/spec/requests/users/new_spec.rb
+++ b/spec/requests/users/new_spec.rb
@@ -22,7 +22,7 @@
let(:user) { create(:user_member_or_viewer) }
it { expect(response).to have_http_status(:found) }
- it { expect(response).to redirect_to root_path }
+ it { expect(response).to redirect_to thaalis_all_path(CURR_YR) }
end
# * ACCESSIBLE
diff --git a/spec/requests/users/show_spec.rb b/spec/requests/users/show_spec.rb
index 63471487..8b1fafd9 100644
--- a/spec/requests/users/show_spec.rb
+++ b/spec/requests/users/show_spec.rb
@@ -24,7 +24,7 @@
let(:user) { create(:viewer_user) }
it { expect(response).to have_http_status(:found) }
- it { expect(response).to redirect_to root_path }
+ it { expect(response).to redirect_to thaalis_all_path(CURR_YR) }
end
# * NOT ACCESSIBLE
@@ -35,7 +35,7 @@
before { get user_path(other_user) }
it { expect(response).to have_http_status(:found) }
- it { expect(response).to redirect_to root_path }
+ it { expect(response).to redirect_to thaalis_all_path(CURR_YR) }
end
# * ACCESSIBLE
diff --git a/spec/routing/page_spec.rb b/spec/routing/page_spec.rb
index 84b7a4ee..1a36cd77 100644
--- a/spec/routing/page_spec.rb
+++ b/spec/routing/page_spec.rb
@@ -5,12 +5,12 @@
RSpec.describe "Pages" do
# * home
describe "home action" do
- it "is accessible by /home route" do
- expect(get("/home")).to route_to("pages#home")
+ it "is accessible by / route" do
+ expect(get("/")).to route_to("pages#home")
end
- it "is accessible by home_path route" do
- expect(get: home_path).to route_to(controller: "pages", action: "home")
+ it "is accessible by root_path route" do
+ expect(get: root_path).to route_to(controller: "pages", action: "home")
end
end
end
diff --git a/spec/routing/sabeel_spec.rb b/spec/routing/sabeel_spec.rb
index f3315fcb..da6c4632 100644
--- a/spec/routing/sabeel_spec.rb
+++ b/spec/routing/sabeel_spec.rb
@@ -80,17 +80,6 @@
end
end
- # * STATS
- describe "stats action" do
- it "is accessible by /sabeels/stats route" do
- expect(get("/sabeels/stats")).to route_to("sabeels#stats")
- end
-
- it "is accessible by sabeel_stats_path route" do
- expect(get: stats_sabeels_path).to route_to(controller: "sabeels", action: "stats")
- end
- end
-
# * ACTIVE
describe "active action" do
it "is accessible by /sabeels/mohammedi/active route" do
diff --git a/spec/routing/statistics_spec.rb b/spec/routing/statistics_spec.rb
new file mode 100644
index 00000000..ed616ce1
--- /dev/null
+++ b/spec/routing/statistics_spec.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+RSpec.describe "Statistics" do
+ # * THAALI
+ describe "thaali action" do
+ it "is accessible by /statistics/thaalis route" do
+ expect(get("/statistics/thaalis")).to route_to("statistics#thaalis")
+ end
+
+ it "is accessible by statistics_thaalis_path route" do
+ expect(get: statistics_thaalis_path).to route_to(controller: "statistics", action: "thaalis")
+ end
+ end
+
+ # * SABEEL
+ describe "sabeels action" do
+ it "is accessible by /statistics/sabeels route" do
+ expect(get("/statistics/sabeels")).to route_to("statistics#sabeels")
+ end
+
+ it "is accessible by statistics_sabeels_path route" do
+ expect(get: statistics_sabeels_path).to route_to(controller: "statistics", action: "sabeels")
+ end
+ end
+end
diff --git a/spec/routing/thaali_spec.rb b/spec/routing/thaali_spec.rb
index c99d2eef..566923a6 100644
--- a/spec/routing/thaali_spec.rb
+++ b/spec/routing/thaali_spec.rb
@@ -3,17 +3,6 @@
require "rails_helper"
RSpec.describe Thaali do
- # * INDEX
- describe "index action" do
- it "is accessible by / route" do
- expect(get("/")).to route_to("thaalis#index")
- end
-
- it "is accessible by root url helper" do
- expect(get: root_path).to route_to(controller: "thaalis", action: "index")
- end
- end
-
# * NEW
describe "new action" do
it "is accessible by /sabeels/1/thaalis/new route" do
@@ -80,17 +69,6 @@
end
end
- # * STATS
- describe "stats action" do
- it "is accessible by /thaalis/stats route" do
- expect(get("/thaalis/stats")).to route_to("thaalis#stats")
- end
-
- it "is accessible by thaalis_stats_path route" do
- expect(get: thaalis_stats_path).to route_to(controller: "thaalis", action: "stats")
- end
- end
-
# * COMPLETE
describe "complete action" do
it "is accessible by /thaalis/2022/complete route" do