Extract method to check the current phase
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<ul class="no-bullet budget-phases">
|
<ul class="no-bullet budget-phases">
|
||||||
<% budget.published_phases.each do |phase| %>
|
<% budget.published_phases.each do |phase| %>
|
||||||
<li class="phase <%= "is-active" if phase == budget.current_phase %>">
|
<li class="phase <%= "is-active" if phase.current? %>">
|
||||||
<h3><%= t("budgets.phase.#{phase.kind}") %></h3>
|
<h3><%= t("budgets.phase.#{phase.kind}") %></h3>
|
||||||
<span>
|
<span>
|
||||||
<%= l(phase.starts_at.to_date, format: :long) if phase.starts_at.present? %>
|
<%= l(phase.starts_at.to_date, format: :long) if phase.starts_at.present? %>
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ class Budget
|
|||||||
in_phase_or_later?("balloting")
|
in_phase_or_later?("balloting")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current?
|
||||||
|
budget.current_phase == self
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def adjust_date_ranges
|
def adjust_date_ranges
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
<tr id="<%= dom_id(phase) %>" class="phase">
|
<tr id="<%= dom_id(phase) %>" class="phase">
|
||||||
<td>
|
<td>
|
||||||
<%= t("budgets.phase.#{phase.kind}") %>
|
<%= t("budgets.phase.#{phase.kind}") %>
|
||||||
<% if @budget.current_phase == phase %>
|
<% if phase.current? %>
|
||||||
<span class="label success"><strong><%= t("admin.budgets.edit.active") %></strong></span>
|
<span class="label success"><strong><%= t("admin.budgets.edit.active") %></strong></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ describe "Admin budgets", :admin do
|
|||||||
expect(page).to have_content("#{phase.starts_at.to_date} - #{phase.ends_at.to_date}")
|
expect(page).to have_content("#{phase.starts_at.to_date} - #{phase.ends_at.to_date}")
|
||||||
expect(page).to have_css(".budget-phase-enabled.enabled")
|
expect(page).to have_css(".budget-phase-enabled.enabled")
|
||||||
expect(page).to have_link("Edit phase", href: edit_phase_link)
|
expect(page).to have_link("Edit phase", href: edit_phase_link)
|
||||||
expect(page).to have_content("Active") if budget.current_phase == phase
|
expect(page).to have_content("Active") if phase.current?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user