Merge pull request #1355 from consul/budget-tags
Displays tag cloud in all phases
This commit is contained in:
@@ -5,6 +5,8 @@ module Budgets
|
||||
#before_action :ensure_final_voting_allowed
|
||||
before_action :load_budget
|
||||
before_action :load_ballot
|
||||
before_action :load_tag_cloud
|
||||
before_action :load_categories
|
||||
|
||||
before_action :load_investments
|
||||
|
||||
@@ -63,6 +65,14 @@ module Budgets
|
||||
@heading = @investment.heading
|
||||
end
|
||||
|
||||
def load_tag_cloud
|
||||
@tag_cloud = TagCloud.new(Budget::Investment, params[:search])
|
||||
end
|
||||
|
||||
def load_categories
|
||||
@categories = ActsAsTaggableOn::Tag.where("kind = 'category'").order(:name)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,27 +2,29 @@
|
||||
|
||||
<% if can?(:create, Budget::Investment.new(budget: @budget)) %>
|
||||
<% if current_user && current_user.level_two_or_three_verified? %>
|
||||
<%= link_to t("budgets.investments.index.sidebar.create"), new_budget_investment_path, class: "button budget expanded" %>
|
||||
<%= link_to t("budgets.investments.index.sidebar.create"),
|
||||
new_budget_investment_path, class: "button budget expanded" %>
|
||||
<% else %>
|
||||
<div class="callout warning">
|
||||
<%= t("budgets.investments.index.sidebar.verified_only",
|
||||
verify: link_to(t("budgets.investments.index.sidebar.verify_account"), verification_path)).html_safe %>
|
||||
verify: link_to(t("budgets.investments.index.sidebar.verify_account"),
|
||||
verification_path)).html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @budget.accepting? %>
|
||||
<%= render "shared/tag_cloud", taggable: 'budget/investment' %>
|
||||
<%= render 'categories' %>
|
||||
<%= render 'feasibility_link' %>
|
||||
<% end %>
|
||||
|
||||
<%= render "shared/tag_cloud", taggable: 'budget/investment' %>
|
||||
<%= render 'budgets/investments/categories' %>
|
||||
<%= render 'budgets/investments/feasibility_link' %>
|
||||
|
||||
<% if @heading && can?(:show, @ballot) %>
|
||||
|
||||
<div class="sidebar-divider"></div>
|
||||
|
||||
<h2 class="sidebar-title"><%= t("budgets.investments.index.sidebar.my_ballot") %></h2>
|
||||
<h2 class="sidebar-title">
|
||||
<%= t("budgets.investments.index.sidebar.my_ballot") %>
|
||||
</h2>
|
||||
|
||||
<% if @ballot.investments.by_heading(@heading.id).count > 0 %>
|
||||
<p>
|
||||
<em>
|
||||
@@ -45,5 +47,7 @@
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<p class="callout primary"><%= t("budgets.investments.index.sidebar.voted_info") %></p>
|
||||
<p class="callout primary">
|
||||
<%= t("budgets.investments.index.sidebar.voted_info") %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
@@ -164,72 +164,91 @@ feature 'Tags' do
|
||||
|
||||
context 'Tag cloud' do
|
||||
|
||||
let!(:investment1) { create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente') }
|
||||
let!(:investment2) { create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente') }
|
||||
let!(:investment3) { create(:budget_investment, heading: heading, tag_list: 'Economía') }
|
||||
|
||||
scenario 'Display user tags' do
|
||||
earth = create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente')
|
||||
money = create(:budget_investment, heading: heading, tag_list: 'Economía')
|
||||
Budget::PHASES.each do |phase|
|
||||
budget.update(phase: phase)
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
within "#tag-cloud" do
|
||||
expect(page).to have_content "Medio Ambiente"
|
||||
expect(page).to have_content "Economía"
|
||||
within "#tag-cloud" do
|
||||
expect(page).to have_content "Medio Ambiente"
|
||||
expect(page).to have_content "Economía"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Filter by user tags" do
|
||||
investment1 = create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente')
|
||||
investment2 = create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente')
|
||||
investment3 = create(:budget_investment, heading: heading, tag_list: 'Economía')
|
||||
Budget::PHASES.each do |phase|
|
||||
budget.update(phase: phase)
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
if budget.balloting?
|
||||
[investment1, investment2, investment3].each do |investment|
|
||||
investment.update(selected: true)
|
||||
end
|
||||
end
|
||||
|
||||
within "#tag-cloud" do
|
||||
click_link "Medio Ambiente"
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
within "#tag-cloud" do
|
||||
click_link "Medio Ambiente"
|
||||
end
|
||||
|
||||
expect(page).to have_css ".budget-investment", count: 2
|
||||
expect(page).to have_content investment1.title
|
||||
expect(page).to have_content investment2.title
|
||||
expect(page).to_not have_content investment3.title
|
||||
end
|
||||
|
||||
expect(page).to have_css ".budget-investment", count: 2
|
||||
expect(page).to have_content investment1.title
|
||||
expect(page).to have_content investment2.title
|
||||
expect(page).to_not have_content investment3.title
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "Categories" do
|
||||
|
||||
let!(:tag1) { create(:tag, kind: 'category', name: 'Medio Ambiente') }
|
||||
let!(:tag2) { create(:tag, kind: 'category', name: 'Economía') }
|
||||
|
||||
let!(:investment1) { create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente') }
|
||||
let!(:investment2) { create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente') }
|
||||
let!(:investment3) { create(:budget_investment, heading: heading, tag_list: 'Economía') }
|
||||
|
||||
scenario 'Display category tags' do
|
||||
create(:tag, kind: 'category', name: 'Medio Ambiente')
|
||||
create(:tag, kind: 'category', name: 'Economía')
|
||||
Budget::PHASES.each do |phase|
|
||||
budget.update(phase: phase)
|
||||
|
||||
earth = create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente')
|
||||
money = create(:budget_investment, heading: heading, tag_list: 'Economía')
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
within "#categories" do
|
||||
expect(page).to have_content "Medio Ambiente"
|
||||
expect(page).to have_content "Economía"
|
||||
within "#categories" do
|
||||
expect(page).to have_content "Medio Ambiente"
|
||||
expect(page).to have_content "Economía"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Filter by category tags" do
|
||||
create(:tag, kind: 'category', name: 'Medio Ambiente')
|
||||
create(:tag, kind: 'category', name: 'Economía')
|
||||
Budget::PHASES.each do |phase|
|
||||
budget.update(phase: phase)
|
||||
|
||||
investment1 = create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente')
|
||||
investment2 = create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente')
|
||||
investment3 = create(:budget_investment, heading: heading, tag_list: 'Economía')
|
||||
if budget.balloting?
|
||||
[investment1, investment2, investment3].each do |investment|
|
||||
investment.update(selected: true)
|
||||
end
|
||||
end
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id, search: 'Economía')
|
||||
visit budget_investments_path(budget, heading_id: heading.id, search: 'Economía')
|
||||
|
||||
within "#categories" do
|
||||
click_link "Medio Ambiente"
|
||||
within "#categories" do
|
||||
click_link "Medio Ambiente"
|
||||
end
|
||||
|
||||
expect(page).to have_css ".budget-investment", count: 2
|
||||
expect(page).to have_content investment1.title
|
||||
expect(page).to have_content investment2.title
|
||||
expect(page).to_not have_content investment3.title
|
||||
end
|
||||
|
||||
expect(page).to have_css ".budget-investment", count: 2
|
||||
expect(page).to have_content investment1.title
|
||||
expect(page).to have_content investment2.title
|
||||
expect(page).to_not have_content investment3.title
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user