Extract method to check the current phase
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<ul class="no-bullet budget-phases">
|
||||
<% 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>
|
||||
<span>
|
||||
<%= l(phase.starts_at.to_date, format: :long) if phase.starts_at.present? %>
|
||||
|
||||
@@ -62,6 +62,10 @@ class Budget
|
||||
in_phase_or_later?("balloting")
|
||||
end
|
||||
|
||||
def current?
|
||||
budget.current_phase == self
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def adjust_date_ranges
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<tr id="<%= dom_id(phase) %>" class="phase">
|
||||
<td>
|
||||
<%= 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>
|
||||
<% end %>
|
||||
</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_css(".budget-phase-enabled.enabled")
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user