Add guide to create a proposal or investment

During a Participatory Budget, some users are getting confused and
creating a proposal instead of a budget investment. This intermediate
page should help them create investments

Adding a feature flag just in case other forks don’t need this feature
and setting seeds and dev_seeds for appropriate initial setup
This commit is contained in:
rgarcia
2018-01-18 18:20:02 +01:00
committed by Bertocq
parent 3e316edc40
commit d3d05f9cee
12 changed files with 113 additions and 3 deletions

View File

@@ -0,0 +1,8 @@
class GuidesController < ApplicationController
skip_authorization_check
def new
end
end

View File

@@ -0,0 +1,19 @@
module GuidesHelper
def new_proposal_guide
if feature?("guides")
new_guide_path
else
new_proposal_path
end
end
def new_budget_investment_guide
if feature?("guides")
new_guide_path
else
new_budget_investment_path(current_budget)
end
end
end

View File

@@ -27,7 +27,7 @@
<% if current_user %> <% if current_user %>
<% if current_user.level_two_or_three_verified? %> <% if current_user.level_two_or_three_verified? %>
<%= link_to t("budgets.investments.index.sidebar.create"), <%= link_to t("budgets.investments.index.sidebar.create"),
new_budget_investment_path(@budget), new_budget_investment_guide,
class: "button margin-top expanded" %> class: "button margin-top expanded" %>
<% else %> <% else %>
<div class="callout warning margin-top"> <div class="callout warning margin-top">

View File

@@ -0,0 +1,11 @@
<% if current_budget %>
<div>
<%= link_to t("guides.new_budget_investment"),
new_budget_investment_path(current_budget) %>
</div>
<% end %>
<div>
<%= link_to t("guides.new_proposal"),
new_proposal_path %>
</div>

View File

@@ -63,7 +63,9 @@
<% if @proposals.any? %> <% if @proposals.any? %>
<div class="show-for-small-only"> <div class="show-for-small-only">
<%= link_to t("proposals.index.start_proposal"), new_proposal_path, class: 'button expanded' %> <%= link_to t("proposals.index.start_proposal"),
new_proposal_guide,
class: 'button expanded' %>
</div> </div>
<% end %> <% end %>
@@ -92,7 +94,9 @@
<div class="small-12 medium-3 column"> <div class="small-12 medium-3 column">
<aside class="margin-bottom"> <aside class="margin-bottom">
<%= link_to t("proposals.index.start_proposal"), new_proposal_path, class: 'button expanded' %> <%= link_to t("proposals.index.start_proposal"),
new_proposal_guide,
class: 'button expanded' %>
<% if params[:retired].blank? %> <% if params[:retired].blank? %>
<%= render 'categories' %> <%= render 'categories' %>
<%= render "shared/tag_cloud", taggable: 'proposal' %> <%= render "shared/tag_cloud", taggable: 'proposal' %>

View File

@@ -0,0 +1,4 @@
en:
guides:
new_proposal: I want to create a proposal
new_budget_investment: I want to create a budget investment

View File

@@ -0,0 +1,4 @@
es:
guides:
new_proposal: Quiero crear una propuesta
new_budget_investment: Quiero crear un nuevo proyecto de gasto

View File

@@ -18,6 +18,7 @@ Rails.application.routes.draw do
draw :direct_upload draw :direct_upload
draw :document draw :document
draw :graphql draw :graphql
draw :guide
draw :legislation draw :legislation
draw :management draw :management
draw :moderation draw :moderation

1
config/routes/guide.rb Normal file
View File

@@ -0,0 +1 @@
resources :guides, only: :new

View File

@@ -37,6 +37,7 @@ section "Creating Settings" do
Setting.create(key: 'url', value: 'http://localhost:3000') Setting.create(key: 'url', value: 'http://localhost:3000')
Setting.create(key: 'org_name', value: 'CONSUL') Setting.create(key: 'org_name', value: 'CONSUL')
Setting.create(key: 'place_name', value: 'City') Setting.create(key: 'place_name', value: 'City')
Setting.create(key: 'feature.debates', value: "true") Setting.create(key: 'feature.debates', value: "true")
Setting.create(key: 'feature.proposals', value: "true") Setting.create(key: 'feature.proposals', value: "true")
Setting.create(key: 'feature.polls', value: "true") Setting.create(key: 'feature.polls', value: "true")
@@ -53,6 +54,8 @@ section "Creating Settings" do
Setting.create(key: 'feature.map', value: "true") Setting.create(key: 'feature.map', value: "true")
Setting.create(key: 'feature.allow_images', value: "true") Setting.create(key: 'feature.allow_images', value: "true")
Setting.create(key: 'feature.public_stats', value: "true") Setting.create(key: 'feature.public_stats', value: "true")
Setting.create(key: 'feature.guides', value: nil)
Setting.create(key: 'per_page_code_head', value: "") Setting.create(key: 'per_page_code_head', value: "")
Setting.create(key: 'per_page_code_body', value: "") Setting.create(key: 'per_page_code_body', value: "")
Setting.create(key: 'comments_body_max_length', value: '1000') Setting.create(key: 'comments_body_max_length', value: '1000')

View File

@@ -85,6 +85,7 @@ Setting['feature.user.recommendations'] = true
Setting['feature.community'] = true Setting['feature.community'] = true
Setting['feature.map'] = nil Setting['feature.map'] = nil
Setting['feature.allow_images'] = true Setting['feature.allow_images'] = true
Setting['feature.guides'] = nil
# Spending proposals feature flags # Spending proposals feature flags
Setting['feature.spending_proposal_features.voting_allowed'] = nil Setting['feature.spending_proposal_features.voting_allowed'] = nil

View File

@@ -0,0 +1,54 @@
require 'rails_helper'
feature 'Guide the user to create the correct resource' do
let(:user) { create(:user, :verified)}
let!(:budget) { create(:budget, :accepting) }
background do
Setting['feature.guides'] = true
end
after do
Setting['feature.guides'] = nil
end
scenario "Proposal" do
login_as(user)
visit proposals_path
click_link "Create a proposal"
click_link "I want to create a proposal"
expect(page).to have_current_path(new_proposal_path)
end
scenario "Budget Investment" do
login_as(user)
visit budgets_path
click_link "Create a budget investment"
click_link "I want to create a budget investment"
expect(page).to have_current_path(new_budget_investment_path(budget))
end
scenario "Feature deactivated" do
Setting['feature.guides'] = nil
login_as(user)
visit proposals_path
click_link "Create a proposal"
expect(page).to_not have_link "I want to create a proposal"
expect(page).to have_current_path(new_proposal_path)
visit budgets_path
click_link "Create a budget investment"
expect(page).to_not have_link "I want to create a new budget investment"
expect(page).to have_current_path(new_budget_investment_path(budget))
end
end