Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve budget investment form #2280

Merged
merged 4 commits into from
Jan 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/budgets/investments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def set_random_seed

def investment_params
params.require(:budget_investment)
.permit(:title, :description, :external_url, :heading_id, :tag_list,
.permit(:title, :description, :heading_id, :tag_list,
:organization_name, :location, :terms_of_service, :skip_map,
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy],
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy],
Expand Down
7 changes: 2 additions & 5 deletions app/views/budgets/investments/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
<%= f.cktext_area :description, maxlength: SpendingProposal.description_max_length, ckeditor: { language: I18n.locale } %>
</div>

<div class="small-12 column">
<%= f.text_field :external_url %>
</div>

<% if feature?(:allow_images) %>
<div class="images small-12 column">
<%= render 'images/nested_image', imageable: @investment, f: f %>
Expand All @@ -46,7 +42,8 @@
<% end %>

<div class="small-12 column">
<%= f.text_field :location %>
<%= f.label :location, t("budgets.investments.form.location") %>
<%= f.text_field :location, label: false %>
</div>

<div class="small-12 column">
Expand Down
6 changes: 1 addition & 5 deletions app/views/valuation/budget_investments/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@

<%= safe_html_with_links @investment.description %>

<% if @investment.external_url.present? %>
<p><%= text_with_links @investment.external_url %></p>
<% end %>

<h2><%= t("valuation.budget_investments.show.info") %></h2>

<p><strong><%= t("valuation.budget_investments.show.by") %>:</strong>
Expand Down Expand Up @@ -142,4 +138,4 @@
<li><%= t("valuation.budget_investments.show.undefined") %></li>
<% end %>
</ul>
</div>
</div>
1 change: 1 addition & 0 deletions config/locales/en/budgets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ en:
map_location: "Map location"
map_location_instructions: "Navigate the map to the location and place the marker."
map_remove_marker: "Remove map marker"
location: "Location additional info"
index:
title: Participatory budgeting
unfeasible: Unfeasible investment projects
Expand Down
1 change: 1 addition & 0 deletions config/locales/es/budgets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ es:
map_location: "Ubicación en el mapa"
map_location_instructions: "Navega por el mapa hasta la ubicación y coloca el marcador."
map_remove_marker: "Eliminar el marcador"
location: "Información adicional de la ubicación"
index:
title: Presupuestos participativos
unfeasible: Propuestas de inversión no viables
Expand Down
2 changes: 0 additions & 2 deletions db/dev_seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ def unique_document_number
group: heading.group,
budget: heading.group.budget,
title: Faker::Lorem.sentence(3).truncate(60),
external_url: Faker::Internet.url,
description: "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>",
created_at: rand((Time.current - 1.week)..Time.current),
feasibility: %w{undecided unfeasible feasible feasible feasible feasible}.sample,
Expand Down Expand Up @@ -468,7 +467,6 @@ def unique_document_number
group: heading.group,
budget: heading.group.budget,
title: Faker::Lorem.sentence(3).truncate(60),
external_url: Faker::Internet.url,
description: "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>",
created_at: rand((Time.current - 1.week)..Time.current),
feasibility: "feasible",
Expand Down
1 change: 0 additions & 1 deletion spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@
description 'Spend money on this'
price 10
unfeasibility_explanation ''
external_url 'http:https://external_documention.org'
skip_map '1'
terms_of_service '1'
incompatible false
Expand Down
2 changes: 0 additions & 2 deletions spec/features/budgets/investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ def investments_order
select 'Health: More hospitals', from: 'budget_investment_heading_id'
fill_in 'budget_investment_title', with: 'Build a skyscraper'
fill_in 'budget_investment_description', with: 'I want to live in a high tower over the clouds'
fill_in 'budget_investment_external_url', with: 'http:https://http:https://skyscraperpage.com/'
Copy link
Collaborator

@bertocq bertocq Jan 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see 3 more budget_investment_external_url occurences in the codebase 🤔 in two more tests:
https://github.com/consul/consul/blob/master/spec/features/management/budget_investments_spec.rb#L35
https://github.com/consul/consul/blob/master/spec/features/emails_spec.rb#L372

That management one... maybe there is a form for investments at management section ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in management panel also there is a new budget investment form with this field ☺️

fill_in 'budget_investment_location', with: 'City center'
fill_in 'budget_investment_organization_name', with: 'T.I.A.'
fill_in 'budget_investment_tag_list', with: 'Towers'
Expand All @@ -322,7 +321,6 @@ def investments_order
expect(page).to have_content 'Investment created successfully'
expect(page).to have_content 'Build a skyscraper'
expect(page).to have_content 'I want to live in a high tower over the clouds'
expect(page).to have_content 'http:https://http:https://skyscraperpage.com/'
expect(page).to have_content 'City center'
expect(page).to have_content 'T.I.A.'
expect(page).to have_content 'Towers'
Expand Down
1 change: 0 additions & 1 deletion spec/features/emails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@
select "#{group.name}: #{heading.name}", from: 'budget_investment_heading_id'
fill_in 'budget_investment_title', with: 'Build a hospital'
fill_in 'budget_investment_description', with: 'We have lots of people that require medical attention'
fill_in 'budget_investment_external_url', with: 'http:https://http:https://hospitalsforallthepeople.com/'
check 'budget_investment_terms_of_service'

click_button 'Create Investment'
Expand Down
2 changes: 0 additions & 2 deletions spec/features/management/budget_investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
select "Whole city: Health", from: 'budget_investment_heading_id'
fill_in 'budget_investment_title', with: 'Build a park in my neighborhood'
fill_in 'budget_investment_description', with: 'There is no parks here...'
fill_in 'budget_investment_external_url', with: 'http:https://moarparks.com'
fill_in 'budget_investment_location', with: 'City center'
fill_in 'budget_investment_organization_name', with: 'T.I.A.'
fill_in 'budget_investment_tag_list', with: 'green'
Expand All @@ -44,7 +43,6 @@
expect(page).to have_content 'Health'
expect(page).to have_content 'Build a park in my neighborhood'
expect(page).to have_content 'There is no parks here...'
expect(page).to have_content 'http:https://moarparks.com'
expect(page).to have_content 'City center'
expect(page).to have_content 'T.I.A.'
expect(page).to have_content 'green'
Expand Down