updates method name to be more accurate
This commit is contained in:
@@ -19,7 +19,7 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
|
|||||||
def valuate
|
def valuate
|
||||||
if valid_price_params? && @spending_proposal.update(valuation_params)
|
if valid_price_params? && @spending_proposal.update(valuation_params)
|
||||||
|
|
||||||
if @spending_proposal.marked_as_unfeasible?
|
if @spending_proposal.unfeasible_email_pending?
|
||||||
@spending_proposal.send_unfeasible_email
|
@spending_proposal.send_unfeasible_email
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class SpendingProposal < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def marked_as_unfeasible?
|
def unfeasible_email_pending?
|
||||||
unfeasible_email_sent_at.blank? && unfeasible? && valuation_finished?
|
unfeasible_email_sent_at.blank? && unfeasible? && valuation_finished?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ namespace :spending_proposals do
|
|||||||
desc "Sends an email to the authors of unfeasible spending proposals"
|
desc "Sends an email to the authors of unfeasible spending proposals"
|
||||||
task send_unfeasible_emails: :environment do
|
task send_unfeasible_emails: :environment do
|
||||||
SpendingProposal.find_each do |spending_propsal|
|
SpendingProposal.find_each do |spending_propsal|
|
||||||
if spending_propsal.marked_as_unfeasible?
|
if spending_propsal.unfeasible_email_pending?
|
||||||
spending_propsal.send_unfeasible_email
|
spending_propsal.send_unfeasible_email
|
||||||
puts "email sent for proposal #{spending_propsal.title}"
|
puts "email sent for proposal #{spending_propsal.title}"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -72,27 +72,27 @@ describe SpendingProposal do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#marked_as_unfeasible?" do
|
describe "#unfeasible_email_pending?" do
|
||||||
let(:spending_proposal) { create(:spending_proposal) }
|
let(:spending_proposal) { create(:spending_proposal) }
|
||||||
|
|
||||||
it "returns true when marked as unfeasibable and valuation_finished" do
|
it "returns true when marked as unfeasibable and valuation_finished" do
|
||||||
spending_proposal.update(feasible: false, valuation_finished: true)
|
spending_proposal.update(feasible: false, valuation_finished: true)
|
||||||
expect(spending_proposal.marked_as_unfeasible?).to eq true
|
expect(spending_proposal.unfeasible_email_pending?).to eq true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when marked as feasible" do
|
it "returns false when marked as feasible" do
|
||||||
spending_proposal.update(feasible: true)
|
spending_proposal.update(feasible: true)
|
||||||
expect(spending_proposal.marked_as_unfeasible?).to eq false
|
expect(spending_proposal.unfeasible_email_pending?).to eq false
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when marked as feasable and valuation_finished" do
|
it "returns false when marked as feasable and valuation_finished" do
|
||||||
spending_proposal.update(feasible: true, valuation_finished: true)
|
spending_proposal.update(feasible: true, valuation_finished: true)
|
||||||
expect(spending_proposal.marked_as_unfeasible?).to eq false
|
expect(spending_proposal.unfeasible_email_pending?).to eq false
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when unfeasible email already sent" do
|
it "returns false when unfeasible email already sent" do
|
||||||
spending_proposal.update(unfeasible_email_sent_at: 1.day.ago)
|
spending_proposal.update(unfeasible_email_sent_at: 1.day.ago)
|
||||||
expect(spending_proposal.marked_as_unfeasible?).to eq false
|
expect(spending_proposal.unfeasible_email_pending?).to eq false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user