Browse Source

Move case logs filter from helpers to modules

pull/557/head
Kat 3 years ago
parent
commit
ab821a06f4
  1. 4
      app/controllers/case_logs_controller.rb
  2. 2
      app/controllers/modules/case_logs_filter.rb
  3. 4
      app/controllers/organisations_controller.rb
  4. 2
      spec/requests/organisations_controller_spec.rb

4
app/controllers/case_logs_controller.rb

@ -1,6 +1,8 @@
require_relative "./modules/case_logs_filter"
class CaseLogsController < ApplicationController
include Pagy::Backend
include Helpers::Filter
include CaseLogsFilter
skip_before_action :verify_authenticity_token, if: :json_api_request?
before_action :authenticate, if: :json_api_request?

2
app/controllers/helpers/filter.rb → app/controllers/modules/case_logs_filter.rb

@ -1,4 +1,4 @@
module Helpers::Filter
module CaseLogsFilter
def filtered_case_logs(logs)
if session[:case_logs_filters].present?
filters = JSON.parse(session[:case_logs_filters])

4
app/controllers/organisations_controller.rb

@ -1,6 +1,8 @@
require_relative "./modules/case_logs_filter"
class OrganisationsController < ApplicationController
include Pagy::Backend
include Helpers::Filter
include CaseLogsFilter
before_action :authenticate_user!, except: [:index]
before_action :find_resource, except: [:index]

2
spec/requests/organisations_controller_spec.rb

@ -459,7 +459,7 @@ RSpec.describe OrganisationsController, type: :request do
end
it "shows the total organisations count" do
expect(CGI.unescape_html(response.body)).to match("<strong>#{total_organisations_count}</strong> total organisations")
expect(CGI.unescape_html(response.body)).to match("<strong>#{total_organisations_count}</strong><span style=\"font-weight: normal\"> total organisations</span>")
end
it "has pagination links" do

Loading…
Cancel
Save