From f4982f9d933cd367f15c8f2db0de1873b5a0d51e Mon Sep 17 00:00:00 2001 From: Jack <113976590+bibblobcode@users.noreply.github.com> Date: Wed, 24 May 2023 14:01:54 +0100 Subject: [PATCH] Delete not started logs (#1656) --- app/policies/lettings_log_policy.rb | 3 --- app/policies/sales_log_policy.rb | 3 --- spec/policies/lettings_log_policy_spec.rb | 16 +++------------- spec/policies/sales_log_policy_spec.rb | 12 ++---------- 4 files changed, 5 insertions(+), 29 deletions(-) diff --git a/app/policies/lettings_log_policy.rb b/app/policies/lettings_log_policy.rb index 1d92cd72f..d9ac8a845 100644 --- a/app/policies/lettings_log_policy.rb +++ b/app/policies/lettings_log_policy.rb @@ -12,9 +12,6 @@ class LettingsLogPolicy # Can only delete editable logs return false unless log.collection_period_open? - # Only delete logs with answered questions - return false unless log.in_progress? || log.completed? - # Support users can delete any log return true if user.support? diff --git a/app/policies/sales_log_policy.rb b/app/policies/sales_log_policy.rb index 671690831..de34527ff 100644 --- a/app/policies/sales_log_policy.rb +++ b/app/policies/sales_log_policy.rb @@ -12,9 +12,6 @@ class SalesLogPolicy # Can only delete editable logs return false unless log.collection_period_open? - # Only delete logs with answered questions - return false unless log.in_progress? || log.completed? - # Support users can delete any log return true if user.support? diff --git a/spec/policies/lettings_log_policy_spec.rb b/spec/policies/lettings_log_policy_spec.rb index a89280212..826dd2768 100644 --- a/spec/policies/lettings_log_policy_spec.rb +++ b/spec/policies/lettings_log_policy_spec.rb @@ -44,16 +44,8 @@ RSpec.describe LettingsLogPolicy do end context "when not started" do - before do - allow(log).to receive(:in_progress?).and_return(false) - allow(log).to receive(:completed?).and_return(false) - end - - it "does not allow deletion of log" do - expect(log).to receive(:in_progress?) - expect(log).to receive(:collection_period_open?) - - expect(policy).not_to permit(build(:user, :support), log) + it "allows deletion of log" do + expect(policy).to permit(build(:user, :support), create(:lettings_log)) end end @@ -83,9 +75,7 @@ RSpec.describe LettingsLogPolicy do context "when user is support" do let(:user) { create(:user, :support) } - it "does allow deletion of log" do - expect(log).to receive(:collection_period_open?) - + it "allows deletion of log" do expect(policy).to permit(user, log) end end diff --git a/spec/policies/sales_log_policy_spec.rb b/spec/policies/sales_log_policy_spec.rb index 38a8cc7b8..73947d24c 100644 --- a/spec/policies/sales_log_policy_spec.rb +++ b/spec/policies/sales_log_policy_spec.rb @@ -44,16 +44,8 @@ RSpec.describe SalesLogPolicy do end context "when not started" do - before do - allow(log).to receive(:in_progress?).and_return(false) - allow(log).to receive(:completed?).and_return(false) - end - - it "does not allow deletion of log" do - expect(log).to receive(:in_progress?) - expect(log).to receive(:collection_period_open?) - - expect(policy).not_to permit(build(:user, :support), log) + it "allows deletion of log" do + expect(policy).to permit(build(:user, :support), create(:sales_log)) end end