Renames Budget::VALID_PHASES to just PHASES
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
module BudgetsHelper
|
module BudgetsHelper
|
||||||
|
|
||||||
def budget_phases_select_options
|
def budget_phases_select_options
|
||||||
Budget::VALID_PHASES.map { |ph| [ t("budget.phase.#{ph}"), ph ] }
|
Budget::PHASES.map { |ph| [ t("budget.phase.#{ph}"), ph ] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def budget_currency_symbol_select_options
|
def budget_currency_symbol_select_options
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ class Budget < ActiveRecord::Base
|
|||||||
|
|
||||||
include Measurable
|
include Measurable
|
||||||
|
|
||||||
VALID_PHASES = %w(accepting reviewing selecting valuating balloting reviewing_ballots finished).freeze
|
PHASES = %w(accepting reviewing selecting valuating balloting reviewing_ballots finished).freeze
|
||||||
CURRENCY_SYMBOLS = %w(€ $ £ ¥).freeze
|
CURRENCY_SYMBOLS = %w(€ $ £ ¥).freeze
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
validates :phase, inclusion: { in: VALID_PHASES }
|
validates :phase, inclusion: { in: PHASES }
|
||||||
validates :currency_symbol, presence: true
|
validates :currency_symbol, presence: true
|
||||||
|
|
||||||
has_many :investments, dependent: :destroy
|
has_many :investments, dependent: :destroy
|
||||||
@@ -94,7 +94,7 @@ class Budget < ActiveRecord::Base
|
|||||||
|
|
||||||
def sanitize_descriptions
|
def sanitize_descriptions
|
||||||
s = WYSIWYGSanitizer.new
|
s = WYSIWYGSanitizer.new
|
||||||
VALID_PHASES.each do |phase|
|
PHASES.each do |phase|
|
||||||
sanitized = s.sanitize(self.send("description_#{phase}"))
|
sanitized = s.sanitize(self.send("description_#{phase}"))
|
||||||
self.send("description_#{phase}=", sanitized)
|
self.send("description_#{phase}=", sanitized)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ describe Budget do
|
|||||||
it "changes depending on the phase" do
|
it "changes depending on the phase" do
|
||||||
budget = create(:budget)
|
budget = create(:budget)
|
||||||
|
|
||||||
Budget::VALID_PHASES.each do |phase|
|
Budget::PHASES.each do |phase|
|
||||||
budget.phase = phase
|
budget.phase = phase
|
||||||
expect(budget.description).to eq(budget.send("description_#{phase}"))
|
expect(budget.description).to eq(budget.send("description_#{phase}"))
|
||||||
expect(budget.description).to be_html_safe
|
expect(budget.description).to be_html_safe
|
||||||
@@ -18,7 +18,7 @@ describe Budget do
|
|||||||
let(:budget) { create(:budget) }
|
let(:budget) { create(:budget) }
|
||||||
|
|
||||||
it "is validated" do
|
it "is validated" do
|
||||||
Budget::VALID_PHASES.each do |phase|
|
Budget::PHASES.each do |phase|
|
||||||
budget.phase = phase
|
budget.phase = phase
|
||||||
expect(budget).to be_valid
|
expect(budget).to be_valid
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user