Browse Source
* feat: initial commit * feat: update designs * feat: actually clear filters * refactor: don't use underscore in route * refactor: make filters_count more readable * feat: add session controller tests * feat: add more tests * refactor: simplification * feat: add bulk upload id to filter count, make nil safe * feat: add tests (and add other missing ones to sales log controller spec) * Update flaky test (#1773) * feat: revert db changes * refactor: lint --------- Co-authored-by: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>pull/1779/head v0.3.39
natdeanlewissoftwire
1 year ago
committed by
GitHub
11 changed files with 334 additions and 2 deletions
@ -0,0 +1,13 @@ |
|||||||
|
class SessionsController < ApplicationController |
||||||
|
def clear_filters |
||||||
|
session[session_name_for(params[:filter_type])] = "{}" |
||||||
|
|
||||||
|
redirect_to send("#{params[:filter_type]}_path") |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def session_name_for(filter_type) |
||||||
|
"#{filter_type}_filters" |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,33 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe SessionsController do |
||||||
|
describe "#clear_filters" do |
||||||
|
context "when filter_type is lettings_logs" do |
||||||
|
let(:filter_type) { "lettings_logs" } |
||||||
|
|
||||||
|
it "clears only lettings filters" do |
||||||
|
session[:lettings_logs_filters] = "{'some_category':'some_filter'}" |
||||||
|
session[:sales_logs_filters] = "{'some_other_category':'some_other_filter'}" |
||||||
|
|
||||||
|
get :clear_filters, params: { filter_type: } |
||||||
|
|
||||||
|
expect(session[:lettings_logs_filters]).to eq("{}") |
||||||
|
expect(session[:sales_logs_filters]).to eq("{'some_other_category':'some_other_filter'}") |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
context "when filter_type is sales_logs" do |
||||||
|
let(:filter_type) { "sales_logs" } |
||||||
|
|
||||||
|
it "clears only sales filters" do |
||||||
|
session[:lettings_logs_filters] = "{'some_category':'some_filter'}" |
||||||
|
session[:sales_logs_filters] = "{'some_other_category':'some_other_filter'}" |
||||||
|
|
||||||
|
get :clear_filters, params: { filter_type: } |
||||||
|
|
||||||
|
expect(session[:lettings_logs_filters]).to eq("{'some_category':'some_filter'}") |
||||||
|
expect(session[:sales_logs_filters]).to eq("{}") |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue