diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index edb11f9b5..e7b4623df 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -462,7 +462,7 @@ word-break: break-word; } -.proposal-show, .investment-project-show { +.proposal-show, .investment-project-show, .budget-investment-show { .supports { padding: $line-height/2 0 0; @@ -712,6 +712,7 @@ } .remove .icon-check-circle { + color: $budget; display: block; font-size: rem-calc(70); line-height: rem-calc(70); @@ -1030,7 +1031,6 @@ .amount-spent { background: $success-bg; - color: $success-color; font-weight: normal; padding: $line-height/2; diff --git a/app/controllers/budgets/ballots_controller.rb b/app/controllers/budgets/ballots_controller.rb index 3c163253d..ce531e145 100644 --- a/app/controllers/budgets/ballots_controller.rb +++ b/app/controllers/budgets/ballots_controller.rb @@ -5,14 +5,16 @@ module Budgets before_action :load_ballot def show + authorize! :show, @ballot render template: "budgets/ballot/show" end private def load_ballot - @ballot = Budget::Ballot.where(user: current_user, budget: @budget).first_or_create + query = Budget::Ballot.where(user: current_user, budget: @budget) + @ballot = @budget.balloting? ? query.first_or_create : query.first_or_initialize end end -end \ No newline at end of file +end diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index bf8fd7574..12976de7d 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -18,7 +18,7 @@ module Budgets feature_flag :budgets has_orders %w{most_voted newest oldest}, only: :show - has_orders ->(c){ c.instance_variable_get(:@budget).balloting? ? %w{random price} : %w{random confidence_score} }, only: :index + has_orders ->(c) { c.instance_variable_get(:@budget).investments_orders }, only: :index invisible_captcha only: [:create, :update], honeypot: :subtitle, scope: :budget_investment @@ -83,7 +83,7 @@ module Budgets end def investment_params - params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :terms_of_service, :location, :tag_list) + params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :tag_list, :organization_name, :location, :terms_of_service) end def load_ballot diff --git a/app/controllers/valuation/budget_investments_controller.rb b/app/controllers/valuation/budget_investments_controller.rb index 69269f6bd..03facadb3 100644 --- a/app/controllers/valuation/budget_investments_controller.rb +++ b/app/controllers/valuation/budget_investments_controller.rb @@ -66,14 +66,14 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController def valid_price_params? if /\D/.match params[:budget_investment][:price] - @investment.errors.add(:price, I18n.t('budget.investments.wrong_price_format')) + @investment.errors.add(:price, I18n.t('budgets.investments.wrong_price_format')) end if /\D/.match params[:budget_investment][:price_first_year] - @investment.errors.add(:price_first_year, I18n.t('budget.investments.wrong_price_format')) + @investment.errors.add(:price_first_year, I18n.t('budgets.investments.wrong_price_format')) end @investment.errors.empty? end -end \ No newline at end of file +end diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index 0e3594b0a..84f04139c 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -1,17 +1,13 @@ module BudgetsHelper def budget_phases_select_options - Budget::PHASES.map { |ph| [ t("budget.phase.#{ph}"), ph ] } + Budget::PHASES.map { |ph| [ t("budgets.phase.#{ph}"), ph ] } end def budget_currency_symbol_select_options Budget::CURRENCY_SYMBOLS.map { |cs| [ cs, cs ] } end - def heading_name(heading) - heading.present? ? heading.name : t("budget.headings.none") - end - def namespaced_budget_investment_path(investment, options={}) case namespace when "management::budgets" diff --git a/app/models/budget.rb b/app/models/budget.rb index e2acf1de8..2741ac014 100644 --- a/app/models/budget.rb +++ b/app/models/budget.rb @@ -76,7 +76,7 @@ class Budget < ActiveRecord::Base end def translated_phase - I18n.t "budget.phase.#{phase}" + I18n.t "budgets.phase.#{phase}" end def formatted_amount(amount) @@ -94,6 +94,17 @@ class Budget < ActiveRecord::Base formatted_amount(amount_spent(heading)) end + def investments_orders + case phase + when 'accepting', 'reviewing' + %w{random} + when 'balloting', 'reviewing_ballots' + %w{random price} + else + %w{random confidence_score} + end + end + private def sanitize_descriptions diff --git a/app/views/admin/budgets/index.html.erb b/app/views/admin/budgets/index.html.erb index 7bf4b0659..87aaa8c66 100644 --- a/app/views/admin/budgets/index.html.erb +++ b/app/views/admin/budgets/index.html.erb @@ -25,7 +25,7 @@ <%= budget.name %> - <%= t("budget.phase.#{budget.phase}") %> + <%= t("budgets.phase.#{budget.phase}") %> <%= link_to t("admin.budgets.index.budget_investments"), admin_budget_budget_investments_path(budget_id: budget.id) %> diff --git a/app/views/budgets/ballot/_ballot.html.erb b/app/views/budgets/ballot/_ballot.html.erb index 11be78ff2..b83005185 100644 --- a/app/views/budgets/ballot/_ballot.html.erb +++ b/app/views/budgets/ballot/_ballot.html.erb @@ -1,22 +1,24 @@ -
+
+
+ <%= render 'shared/back_link' %> - <%= render 'shared/back_link' %> +

<%= t("budgets.ballots.show.title") %>

-

<%= t("budgets.ballots.show.title") %>

- -
-

- <%= t("budgets.ballots.show.voted_html", - count: @ballot.investments.count) %> -

-

- - <%= t("budgets.ballots.show.voted_info_html") %> - -

+
+

+ <%= t("budgets.ballots.show.voted_html", + count: @ballot.investments.count) %> +

+

+ + <%= t("budgets.ballots.show.voted_info_html") %> + +

+
-
+
+
<% @ballot.groups.each do |group| %>

<%= t("budgets.ballots.show.zero") %>
- <%= link_to t("budgets.ballots.show.heading_link"), - budget_investments_path(budget, heading_id: heading.id), - data: { no_turbolink: true } %>

<% end %> diff --git a/app/views/budgets/ballot/_investment_for_sidebar.html.erb b/app/views/budgets/ballot/_investment_for_sidebar.html.erb index c172e6146..059951253 100644 --- a/app/views/budgets/ballot/_investment_for_sidebar.html.erb +++ b/app/views/budgets/ballot/_investment_for_sidebar.html.erb @@ -9,7 +9,8 @@ class: "remove-investment-project", method: :delete, remote: true do %> - + <%= t('budgets.ballots.show.remove') %> + <% end %> <% end %> diff --git a/app/views/budgets/ballot/_progress_bar.html.erb b/app/views/budgets/ballot/_progress_bar.html.erb index 45c338b88..ec9d28457 100644 --- a/app/views/budgets/ballot/_progress_bar.html.erb +++ b/app/views/budgets/ballot/_progress_bar.html.erb @@ -3,7 +3,8 @@
+ id="progress" + aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
<%= @ballot.formatted_amount_spent(@heading) %> - <%= t("budget.progress_bar.available") %> + <%= t("budgets.progress_bar.available") %> <%= @ballot.formatted_amount_available(@heading) %>

diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb index 509e79d65..73fc3a697 100644 --- a/app/views/budgets/index.html.erb +++ b/app/views/budgets/index.html.erb @@ -1,7 +1,7 @@
-

<%= t('budget.index.title') %>

+

<%= t('budgets.index.title') %>

@@ -10,8 +10,8 @@
- - + + <% @budgets.each do |budget| %> diff --git a/app/views/budgets/investments/_ballot.html.erb b/app/views/budgets/investments/_ballot.html.erb index d319a8aa6..0ad43ab43 100644 --- a/app/views/budgets/investments/_ballot.html.erb +++ b/app/views/budgets/investments/_ballot.html.erb @@ -3,8 +3,8 @@ <% if ballot.has_investment?(investment) %>
- "> + ">

<%= investment.formatted_price %> @@ -27,12 +27,12 @@ <%= investment.formatted_price %>

<% if investment.should_show_ballots? %> - <%= link_to t("budget.investments.investment.add"), + <%= link_to t("budgets.investments.investment.add"), budget_ballot_lines_url(investment_id: investment.id, budget_id: investment.budget_id, investments_ids: investment_ids), class: "button button-support small expanded", - title: t('budget.investments.investment.support_title'), + title: t('budgets.investments.investment.support_title'), method: :post, remote: true %> <% end %> @@ -42,7 +42,7 @@ <% if reason.present? && !ballot.has_investment?(investment) %> -
<%= t('budget.index.name') %><%= t('budget.index.phase') %><%= Budget.human_attribute_name(:name) %><%= Budget.human_attribute_name(:phase) %>
- + <% @budget.groups.each do |group| %> diff --git a/app/views/shared/_search_form.html.erb b/app/views/shared/_search_form.html.erb index c14c41e7e..a15bc737a 100644 --- a/app/views/shared/_search_form.html.erb +++ b/app/views/shared/_search_form.html.erb @@ -3,7 +3,7 @@ <%= form_tag search_path, method: :get do %>
- " class="input-group-field" value="<%= params[:search] %>" id="search_text"> +
<%= t('budget.show.group') %><%= t('budgets.show.group') %>
- <%= t("budget.phase.#{budget.phase}") %> + <%= t("budgets.phase.#{budget.phase}") %> <%= @investments_with_valuation_open[budget.id] %> diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 0bad28cee..85c391314 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -32,6 +32,7 @@ data: - config/locales/devise_views.%{locale}.yml - config/locales/responders.%{locale}.yml - config/locales/kaminari.%{locale}.yml + - config/locales/budgets.%{locale}.yml # Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom: # `i18n-tasks normalize -p` will force move the keys according to these rules @@ -94,8 +95,6 @@ search: # - 'errors.messages.{accepted,blank,invalid,too_short,too_long}' # - '{devise,simple_form}.*' ignore_missing: - - 'budget.*' - - 'budgets.*' - 'unauthorized.*' - 'activerecord.models.proposal' - 'activerecord.models.spending_proposal' @@ -109,8 +108,8 @@ ignore_missing: ## Consider these keys used: ignore_unused: - - 'budget.*' - - 'budgets.*' + - 'budgets.phase.*' + - 'budgets.investments.index.orders.*' - 'activerecord.*' - 'activemodel.*' - 'unauthorized.*' @@ -140,11 +139,10 @@ ignore_unused: - 'users.show.filters.*' - 'debates.index.select_order' - 'debates.index.orders.*' - - 'debates.index.search_form.*' - 'proposals.index.select_order' - 'proposals.index.orders.*' - - 'proposals.index.search_form.*' - 'spending_proposals.index.search_form.*' + - '*.index.search_form.*' - 'notifications.index.comments_on*' - 'notifications.index.replies_to*' - 'notifications.index.proposal_notification*' diff --git a/config/locales/activerecord.en.yml b/config/locales/activerecord.en.yml index b4bb1a5e7..04c5cc9d0 100644 --- a/config/locales/activerecord.en.yml +++ b/config/locales/activerecord.en.yml @@ -63,6 +63,8 @@ en: external_url: "Link to additional documentation" heading_id: "Heading" title: "Title" + location: "Location" + organization_name: "If you are proposing in the name of a collective/organization, write its name" comment: body: "Comment" user: "User" diff --git a/config/locales/activerecord.es.yml b/config/locales/activerecord.es.yml index 3299e86eb..c71a34178 100644 --- a/config/locales/activerecord.es.yml +++ b/config/locales/activerecord.es.yml @@ -58,6 +58,8 @@ es: external_url: "Enlace a documentación adicional" heading_id: "Partida presupuestaria" title: "Título" + location: "Ubicación" + organization_name: "Si estás proponiendo en nombre de una organización o colectivo, escribe su nombre" comment: body: "Comentario" user: "Usuario" diff --git a/config/locales/budgets.en.yml b/config/locales/budgets.en.yml index c86720380..8330eb88b 100644 --- a/config/locales/budgets.en.yml +++ b/config/locales/budgets.en.yml @@ -16,30 +16,21 @@ en: not_verified: Only verified users can vote on proposals; %{verify_account}. organization: Organizations are not permitted to vote not_selected: Unselected investment projects can not be supported - not_enough_money: "Price is higher than the available amount left" + not_enough_money: "Price is higher than the available amount left." no_ballots_allowed: Selecting phase is closed different_heading_assigned: You have already voted a different heading groups: show: title: Select a heading - budget: phase: accepting: Accepting proposals reviewing: Reviewing proposals - selecting: Selecting - valuating: Valuating - balloting: Balloting + selecting: Selecting proposals + valuating: Valuating proposals + balloting: Balloting proposals reviewing_ballots: Reviewing Ballots - finished: Finished - groups: - index: - group_title: "Groups" - headings: - none: Whole City - all: All scopes + finished: Finished budget index: - name: Budget name - phase: Phase title: Participatory budgets investments: form: @@ -58,7 +49,6 @@ en: new: Create title: Investment title index: - available: "Available:" title: Participatory budgeting unfeasible: Unfeasible investment projects unfeasible_text: "The proposals must meet a number of criteria (legality, concreteness, be the responsibility of the city, not exceed the limit of the budget; %{definitions}) to be declared viable and reach the stage of final vote. All proposals don't meet these criteria are marked as unfeasible and published in the following list, along with its report of infeasibility." @@ -66,25 +56,17 @@ en: by_heading: "Investment projects with scope: %{heading}" search_form: button: Search - placeholder: Investment projects... + placeholder: Search investment projects... title: Search search_results: one: " containing the term '%{search_term}'" other: " containing the term '%{search_term}'" sidebar: - back: Back to select page - district: District my_ballot: My ballot - remember_city: You can also vote %{city} investment projects. - remember_city_link_html: city-wide - remember_district: You can also vote investment projects for %{district}. - remember_district_link_html: a district voted_html: one: "You voted one proposal with a cost of %{amount_spent}" other: "You voted %{count} proposals with a cost of %{amount_spent}" voted_info: You can change your vote at any time until the close of this phase. No need to spend all the money available. - votes: Supports remaining - votes_district: "You can only vote in the district %{district}" zero: You have not voted any investment project. verified_only: "To create a new budget investment %{verify}." verify_account: "verify your account" @@ -96,22 +78,13 @@ en: random: random confidence_score: highest rated price: by price - new: - back_link: Back - more_info: "Important, not to be ruled out your proposal must comply:" - recommendation_one: See the %{requirements}. - recommendation_one_link: requirements to be met by a proposal - recommendation_three: Try to go into details when describing your spending proposal so the reviewing team undertands your points. - recommendation_two: Each proposal must be submitted separately. You can make as many want. - recommendations_title: How to create a spending proposal - start_new: Create spending proposal show: author_deleted: User deleted price_explanation: Price explanation unfeasibility_explanation: Unfeasibility explanation code_html: 'Investment project code: %{code}' location_html: 'Location: %{location}' - location: Location + organization_name_html: 'Organization: %{name}' share: Share wrong_price_format: Only integer numbers investment: @@ -119,7 +92,6 @@ en: add: Add already_added: You have already added this investment project already_supported: You have already supported this. Share it! - forum: District discussion space support_title: Support this project supports: one: 1 support @@ -129,9 +101,8 @@ en: header: check_ballot: Check my ballot different_heading_assigned_html: "You have active votes in another heading: %{heading_link}" + progress_bar: + available: "Available: " show: group: Group - heading: Heading - price: Price - no_heading: No Heading phase: Actual phase diff --git a/config/locales/budgets.es.yml b/config/locales/budgets.es.yml index 4497867f9..d3cd01e26 100644 --- a/config/locales/budgets.es.yml +++ b/config/locales/budgets.es.yml @@ -11,35 +11,26 @@ es: other: "Has votado %{count} propuestas." voted_info_html: "Puedes cambiar tus votos en cualquier momento hasta el cierre de esta fase.
No hace falta que inviertas todo el dinero disponible." zero: "Todavía no has votado ninguna propuesta de inversión." - reasons_for_not_balloting: - not_logged_in: Necesitas %{signin} o %{signup} para continuar. - not_verified: Las propuestas de inversión sólo pueden ser apoyadas por usuarios verificados, %{verify_account}. - organization: Las organizaciones no pueden votar. - not_selected: No se pueden votar propuestas inviables. - not_enough_money: No hay fondos suficientes - no_ballots_allowed: El periodo de votación está cerrado. - different_heading_assigned: Ya votaste en una sección distinta del presupuesto. + reasons_for_not_balloting: + not_logged_in: Necesitas %{signin} o %{signup} para continuar. + not_verified: Las propuestas de inversión sólo pueden ser apoyadas por usuarios verificados, %{verify_account}. + organization: Las organizaciones no pueden votar. + not_selected: No se pueden votar propuestas inviables. + not_enough_money: No hay fondos suficientes. + no_ballots_allowed: El periodo de votación está cerrado. + different_heading_assigned: Ya votaste en una sección distinta del presupuesto. groups: show: title: Selecciona una partida - budget: phase: - accepting: Fase de propuestas - reviewing: Fase de revisión de propuestas - selecting: Fase de apoyos - valuating: Fase de evaluación de propuestas - balloting: Fase de votación - reviewing_ballots: Fase de revisión de resultados - finished: Resultados - groups: - index: - group_title: "Grupos" - headings: - none: Toda la ciudad - all: Todos los ámbitos + accepting: Aceptando propuestas + reviewing: Revisando propuestas + selecting: Selección de propuestas + valuating: Evaluación de propuestas + balloting: Votación de propuestas + reviewing_ballots: Contando resultados + finished: Presupuesto terminado index: - name: Nombre del presupuesto - phase: Fase title: Presupuestos participativos investments: form: @@ -58,7 +49,6 @@ es: new: Crear title: Título de la propuesta de inversión index: - available: "Disponible:" title: Presupuestos participativos unfeasible: Propuestas de inversión no viables unfeasible_text: Las propuestas presentadas deben cumplir una serie de criterios (legalidad, concreción, ser competencia del Ayuntamiento, no superar el tope del presupuesto; %{definitions}) para ser declaradas viables y llegar hasta la fase de votación final. Todas las propuestas que no cumplen estos criterios son marcadas como inviables y publicadas en la siguiente lista, junto con su informe de inviabilidad. @@ -66,25 +56,17 @@ es: by_heading: "Propuestas de inversión con ámbito: %{heading}" search_form: button: Buscar - placeholder: Propuestas de inversión... + placeholder: Buscar propuestas de inversión... title: Buscar search_results: one: " que contiene '%{search_term}'" other: " que contienen '%{search_term}'" sidebar: - back: Volver a página de selección - district: Distrito my_ballot: Mis votos - remember_city: Además puedes votar propuestas de inversión para %{city}. - remember_city_link_html: toda la ciudad - remember_district: Además puedes votar propuestas de inversión para %{district}. - remember_district_link_html: un distrito voted_html: one: "Has votado una propuesta por un valor de %{amount_spent}" other: "Has votado %{count} propuestas por un valor de %{amount_spent}" voted_info: Puedes cambiar tus votos en cualquier momento hasta el cierre de esta fase. No hace falta que gastes todo el dinero disponible. - votes: Apoyos restantes - votes_district: "Solo puedes votar en el distrito %{district}" zero: "Todavía no has votado ninguna propuesta de inversión." verified_only: "Para crear una nueva propuesta de inversión %{verify}." verify_account: "verifica tu cuenta" @@ -96,30 +78,21 @@ es: random: Aleatorias confidence_score: Mejor valoradas price: Por coste - new: - more_info: "¿Cómo funcionan los presupuestos participativos?" - recommendation_one: Consulta los %{requirements}. - recommendation_one_link: requisitos que debe cumplir una propuesta - recommendation_three: Intenta detallar lo máximo posible la propuesta para que el equipo de gobierno encargado de estudiarla tenga las menor dudas posibles. - recommendation_two: Cualquier propuesta o comentario que implique acciones ilegales será eliminada. - recommendations_title: Cómo crear una propuesta de inversión - start_new: Crear una propuesta de inversión - back_link: Volver show: author_deleted: Usuario eliminado price_explanation: Informe de coste unfeasibility_explanation: Informe de inviabilidad code_html: 'Código propuesta de gasto: %{code}' location_html: 'Ubicación: %{location}' + organization_name_html: 'Organización: %{name}' share: Compartir wrong_price_format: Solo puede incluir caracteres numéricos investment: title: Propuesta de inversión add: Añadir already_added: "Ya has añadido esta propuesta de inversión" - already_supported: Ya has apoyado este proyecto. ¡Compártelo! - forum: Espacio de debate distrital - support_title: Apoyar este proyecto + already_supported: Ya has apoyado esta propuesta. ¡Compártelo! + support_title: Apoyar esta propuesta supports: one: 1 apoyo other: "%{count} apoyos" @@ -128,9 +101,8 @@ es: header: check_ballot: Revisar mis votos different_heading_assigned_html: "Ya apoyaste propuestas de otra sección del presupuesto: %{heading_link}" + progress_bar: + available: "Disponible: " show: group: Grupo - heading: Partida - price: Cantidad - no_heading: Sin línea phase: Fase actual diff --git a/config/locales/en.yml b/config/locales/en.yml index 5600c2ad4..b19a7b0ac 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -33,15 +33,6 @@ en: application: close: Close menu: Menu - budgets: - progress_bar: - available: Available - phases: - accepting: Accepting investment projects - on_hold: On Hold - selecting: Selecting investment projects - balloting: Voting investment projects - finished: Finished comments: comment: admin: Administrator diff --git a/config/locales/es.yml b/config/locales/es.yml index d42b51915..8840a5de3 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -33,15 +33,6 @@ es: application: close: Cerrar menu: Menú - budgets: - progress_bar: - available: Disponible - phases: - accepting: Aceptación de proyectos - on_hold: En espera - selecting: Selección de proyectos - balloting: Votación de proyectos - finished: Terminado comments: comment: admin: Administrador diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index 3acc1154a..2e7ed3cc5 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -348,7 +348,7 @@ Budget::PHASES.each_with_index do |phase, i| geozones = Geozone.reorder("RANDOM()").limit([2, 5, 6, 7].sample) geozones.each do |geozone| group.headings << group.headings.create!(name: geozone.name, - geozone: geozone, + #geozone: geozone, price: rand(1 .. 100) * 100000) end diff --git a/db/migrate/20170106130838_add_organization_name_field_to_budget_investment.rb b/db/migrate/20170106130838_add_organization_name_field_to_budget_investment.rb new file mode 100644 index 000000000..dfe9eca06 --- /dev/null +++ b/db/migrate/20170106130838_add_organization_name_field_to_budget_investment.rb @@ -0,0 +1,5 @@ +class AddOrganizationNameFieldToBudgetInvestment < ActiveRecord::Migration + def change + add_column :budget_investments, :organization_name, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 7ebc5f684..6a9498399 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170103170147) do +ActiveRecord::Schema.define(version: 20170106130838) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -142,6 +142,7 @@ ActiveRecord::Schema.define(version: 20170103170147) do t.integer "group_id" t.boolean "selected", default: false t.string "location" + t.string "organization_name" end add_index "budget_investments", ["administrator_id"], name: "index_budget_investments_on_administrator_id", using: :btree diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index 8f17c27d4..3b34878af 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -23,7 +23,7 @@ feature 'Admin budgets' do visit admin_budgets_path expect(page).to have_content(budget.name) - expect(page).to have_content(I18n.t("budget.phase.#{budget.phase}")) + expect(page).to have_content(I18n.t("budgets.phase.#{budget.phase}")) end scenario 'Filters by phase' do diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index e8905408f..b5f3354d9 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -70,6 +70,7 @@ feature 'Budget Investments' do end context("Orders") do + before(:each) { budget.update(phase: 'selecting') } scenario "Default order is random" do per_page = Kaminari.config.default_per_page @@ -151,7 +152,7 @@ feature 'Budget Investments' do fill_in 'budget_investment_description', with: 'This is the description' check 'budget_investment_terms_of_service' - click_button 'Create' + click_button 'Create Investment' expect(page.status_code).to eq(200) expect(page.html).to be_empty @@ -169,7 +170,7 @@ feature 'Budget Investments' do fill_in 'budget_investment_description', with: 'This is the description' check 'budget_investment_terms_of_service' - click_button 'Create' + click_button 'Create Investment' expect(page).to have_content 'Sorry, that was too quick! Please resubmit' expect(current_path).to eq(new_budget_investment_path(budget_id: budget.id)) @@ -186,7 +187,7 @@ feature 'Budget Investments' do fill_in 'budget_investment_external_url', with: 'http://http://skyscraperpage.com/' check 'budget_investment_terms_of_service' - click_button 'Create' + click_button 'Create Investment' expect(page).to have_content 'Investment created successfully' expect(page).to have_content 'You can access it from My activity' @@ -204,9 +205,21 @@ feature 'Budget Investments' do login_as(author) visit new_budget_investment_path(budget_id: budget.id) - click_button 'Create' + click_button 'Create Investment' expect(page).to have_content error_message end + + scenario 'Ballot is not visible' do + login_as(author) + + visit budget_investments_path(budget, heading_id: heading.id) + + expect(page).to_not have_link('Check my ballot') + expect(page).to_not have_css('#progress_bar') + within('#sidebar') do + expect(page).to_not have_content('My ballot') + end + end end scenario "Show" do @@ -280,7 +293,7 @@ feature 'Budget Investments' do end - context "Phase 3 - Final Voting" do + context "Balloting Phase" do background do budget.update(phase: "balloting") @@ -403,5 +416,17 @@ feature 'Budget Investments' do end end + scenario 'Ballot is visible' do + login_as(author) + + visit budget_investments_path(budget, heading_id: heading.id) + + expect(page).to have_link('Check my ballot') + expect(page).to have_css('#progress_bar') + within('#sidebar') do + expect(page).to have_content('My ballot') + end + end + end end \ No newline at end of file diff --git a/spec/features/management/budget_investments_spec.rb b/spec/features/management/budget_investments_spec.rb index d81b95b01..02f4cf36f 100644 --- a/spec/features/management/budget_investments_spec.rb +++ b/spec/features/management/budget_investments_spec.rb @@ -35,12 +35,12 @@ feature 'Budget Investments' do fill_in 'budget_investment_external_url', with: 'http://moarparks.com' check 'budget_investment_terms_of_service' - click_button 'Create' + click_button 'Create Investment' expect(page).to have_content 'Investment created successfully.' - expect(page).to have_content '2016' - expect(page).to have_content 'Whole city' + expect(page).to have_content '2017' + #expect(page).to have_content 'Whole city' 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...' @@ -82,7 +82,6 @@ feature 'Budget Investments' do expect(page).to have_content(budget_investment1.title) expect(page).to_not have_content(budget_investment2.title) expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment1)}']", text: budget_investment1.title) - expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment1)}']", text: budget_investment1.description) end end @@ -107,7 +106,6 @@ feature 'Budget Investments' do expect(page).to_not have_content(budget_investment1.title) expect(page).to have_content(budget_investment2.title) expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment2)}']", text: budget_investment2.title) - expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment2)}']", text: budget_investment2.description) end end end @@ -135,9 +133,7 @@ feature 'Budget Investments' do within("#budget-investments") do expect(page).to have_css('.budget-investment', count: 2) expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment1)}']", text: budget_investment1.title) - expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment1)}']", text: budget_investment1.description) expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment2)}']", text: budget_investment2.title) - expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment2)}']", text: budget_investment2.description) end end diff --git a/spec/models/budget_spec.rb b/spec/models/budget_spec.rb index 17f4de4ff..1157a152b 100644 --- a/spec/models/budget_spec.rb +++ b/spec/models/budget_spec.rb @@ -64,5 +64,27 @@ describe Budget do expect(budget.heading_price(create(:budget_heading))).to eq(-1) end end + + describe "investments_orders" do + let(:budget) { create(:budget) } + it "is random when accepting and reviewing" do + budget.phase = 'accepting' + expect(budget.investments_orders).to eq(['random']) + budget.phase = 'reviewing' + expect(budget.investments_orders).to eq(['random']) + end + it "is random and price when ballotting and reviewing ballots" do + budget.phase = 'balloting' + expect(budget.investments_orders).to eq(['random', 'price']) + budget.phase = 'reviewing_ballots' + expect(budget.investments_orders).to eq(['random', 'price']) + end + it "is random and confidence_score in all other cases" do + budget.phase = 'selecting' + expect(budget.investments_orders).to eq(['random', 'confidence_score']) + budget.phase = 'valuating' + expect(budget.investments_orders).to eq(['random', 'confidence_score']) + end + end end