diff --git a/Gemfile b/Gemfile
index 5efa7d67b..383de2122 100644
--- a/Gemfile
+++ b/Gemfile
@@ -25,7 +25,7 @@ gem 'devise', '~> 3.5.6'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-facebook', '~> 3.0.0'
-gem 'omniauth-google-oauth2', '~> 0.3.0'
+gem 'omniauth-google-oauth2', '~> 0.4.0'
gem 'kaminari'
gem 'ancestry'
@@ -59,6 +59,7 @@ gem 'tolk' # Web interface for translations
gem 'browser'
gem 'turnout'
gem 'redcarpet'
+
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
diff --git a/Gemfile.lock b/Gemfile.lock
index 6ffbb5c1d..18fa95bd9 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -201,14 +201,14 @@ GEM
terminal-table (>= 1.5.1)
initialjs-rails (0.2.0.1)
railties (>= 3.1, < 5.0)
- jquery-rails (4.1.0)
- rails-dom-testing (~> 1.0)
+ jquery-rails (4.1.1)
+ rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (5.0.5)
railties (>= 3.2.16)
json (1.8.3)
- jwt (1.5.1)
+ jwt (1.5.3)
kaminari (0.16.3)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
@@ -239,19 +239,19 @@ GEM
mini_portile2 (~> 2.0.0.rc2)
nori (2.6.0)
oauth (0.5.0)
- oauth2 (1.1.0)
+ oauth2 (1.0.0)
faraday (>= 0.8, < 0.10)
- jwt (~> 1.0, < 1.5.2)
+ jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
- rack (>= 1.2, < 3)
+ rack (~> 1.2)
omniauth (1.3.1)
hashie (>= 1.2, < 4)
rack (>= 1.0, < 3)
omniauth-facebook (3.0.0)
omniauth-oauth2 (~> 1.2)
- omniauth-google-oauth2 (0.3.1)
- jwt (~> 1.0)
+ omniauth-google-oauth2 (0.4.1)
+ jwt (~> 1.5.2)
multi_json (~> 1.3)
omniauth (>= 1.1.1)
omniauth-oauth2 (>= 1.3.1)
@@ -311,7 +311,7 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.15.0)
- rake (11.0.1)
+ rake (11.1.1)
redcarpet (3.3.4)
referer-parser (0.3.0)
request_store (1.3.0)
@@ -471,7 +471,7 @@ DEPENDENCIES
newrelic_rpm (~> 3.14)
omniauth
omniauth-facebook (~> 3.0.0)
- omniauth-google-oauth2 (~> 0.3.0)
+ omniauth-google-oauth2 (~> 0.4.0)
omniauth-twitter
paranoia
pg
diff --git a/app/assets/fonts/icons.eot b/app/assets/fonts/icons.eot
index 7323d578f..5fe0c1d3d 100644
Binary files a/app/assets/fonts/icons.eot and b/app/assets/fonts/icons.eot differ
diff --git a/app/assets/fonts/icons.svg b/app/assets/fonts/icons.svg
index e272b9550..51044c3e2 100644
--- a/app/assets/fonts/icons.svg
+++ b/app/assets/fonts/icons.svg
@@ -48,4 +48,5 @@
+
diff --git a/app/assets/fonts/icons.ttf b/app/assets/fonts/icons.ttf
index 4db54078d..b0b156581 100644
Binary files a/app/assets/fonts/icons.ttf and b/app/assets/fonts/icons.ttf differ
diff --git a/app/assets/fonts/icons.woff b/app/assets/fonts/icons.woff
index 33d2d4dee..edcc9bc61 100644
Binary files a/app/assets/fonts/icons.woff and b/app/assets/fonts/icons.woff differ
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index aa27109d9..7fc81e03e 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -41,6 +41,7 @@
//= require registration_form
//= require suggest
//= require forms
+//= require valuation_spending_proposal_form
var initialize_modules = function() {
App.Comments.initialize();
@@ -57,6 +58,7 @@ var initialize_modules = function() {
App.RegistrationForm.initialize();
App.Suggest.initialize();
App.Forms.initialize();
+ App.ValuationSpendingProposalForm.initialize();
};
$(function(){
diff --git a/app/assets/javascripts/valuation_spending_proposal_form.js.coffee b/app/assets/javascripts/valuation_spending_proposal_form.js.coffee
new file mode 100644
index 000000000..fa0bc2106
--- /dev/null
+++ b/app/assets/javascripts/valuation_spending_proposal_form.js.coffee
@@ -0,0 +1,32 @@
+App.ValuationSpendingProposalForm =
+
+ showFeasibleFields: ->
+ $('#valuation_spending_proposal_edit_form #not_feasible_fields').hide('down')
+ $('#valuation_spending_proposal_edit_form #feasible_fields').show()
+
+ showNotFeasibleFields: ->
+ $('#valuation_spending_proposal_edit_form #feasible_fields').hide('down')
+ $('#valuation_spending_proposal_edit_form #not_feasible_fields').show()
+
+ showAllFields: ->
+ $('#valuation_spending_proposal_edit_form #feasible_fields').show('down')
+ $('#valuation_spending_proposal_edit_form #not_feasible_fields').show('down')
+
+ showFeasibilityFields: ->
+ feasible = $("#valuation_spending_proposal_edit_form input[type=radio][name='spending_proposal[feasible]']:checked").val()
+ if feasible == 'true'
+ App.ValuationSpendingProposalForm.showFeasibleFields()
+ else if feasible == 'false'
+ App.ValuationSpendingProposalForm.showNotFeasibleFields()
+
+
+ showFeasibilityFieldsOnChange: ->
+ $("#valuation_spending_proposal_edit_form input[type=radio][name='spending_proposal[feasible]']").change ->
+ App.ValuationSpendingProposalForm.showAllFields()
+ App.ValuationSpendingProposalForm.showFeasibilityFields()
+
+
+ initialize: ->
+ App.ValuationSpendingProposalForm.showFeasibilityFields()
+ App.ValuationSpendingProposalForm.showFeasibilityFieldsOnChange()
+ false
\ No newline at end of file
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index 822e4cd4c..68065e82a 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -11,4 +11,4 @@
@import "annotator.min";
@import "annotator_overrides";
@import "jquery-ui/datepicker";
-@import "datepicker_overrides";
\ No newline at end of file
+@import "datepicker_overrides";
diff --git a/app/assets/stylesheets/icons.scss b/app/assets/stylesheets/icons.scss
index b13b09f46..2c06f745a 100644
--- a/app/assets/stylesheets/icons.scss
+++ b/app/assets/stylesheets/icons.scss
@@ -160,3 +160,6 @@
.icon-no-notification:before {
content: "\78";
}
+.icon-whatsapp:before {
+ content: "\50";
+}
diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss
index a9eedbcfe..75f8cf741 100644
--- a/app/assets/stylesheets/layout.scss
+++ b/app/assets/stylesheets/layout.scss
@@ -421,10 +421,6 @@ header {
}
}
- span {
- color: $border;
- }
-
.input-group {
padding-top: $line-height/4;
@@ -879,7 +875,7 @@ img.avatar, img.admin-avatar, img.moderator-avatar, img.initialjs-avatar {
}
.user-deleted {
- top: -9px;
+ top: -4px;
}
.user-permissions {
@@ -1388,7 +1384,7 @@ table {
}
}
- .date {
+ .date-of-birth {
select {
float: left;
@@ -1550,6 +1546,7 @@ table {
.comment {
margin: $line-height/4 0;
+ position: relative;
p {
margin-bottom: 0;
@@ -1727,6 +1724,7 @@ table {
td {
padding-left: $line-height*1.5;
position: relative;
+ word-break: break-all;
&:before {
color: $brand;
diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss
index bc6aa3694..6a12477eb 100644
--- a/app/assets/stylesheets/participation.scss
+++ b/app/assets/stylesheets/participation.scss
@@ -337,6 +337,20 @@
.debate-show, .proposal-show {
+ .social-share-full .social-share-button {
+ display:inline;
+ }
+
+ .whatsapp:before {
+ background-color: #43d854;
+ color: white;
+ font-size: 1.7em;
+ margin-left: rem-calc(0.5);
+ padding: rem-calc(9.5) rem-calc(9.8);
+ vertical-align: rem-calc(10);
+ }
+
+
.edit-debate, .edit-proposal {
margin-bottom: 0;
}
diff --git a/app/controllers/admin/spending_proposals_controller.rb b/app/controllers/admin/spending_proposals_controller.rb
index afa24f54c..25707e66e 100644
--- a/app/controllers/admin/spending_proposals_controller.rb
+++ b/app/controllers/admin/spending_proposals_controller.rb
@@ -15,7 +15,7 @@ class Admin::SpendingProposalsController < Admin::BaseController
def edit
@admins = Administrator.includes(:user).all
- @valuators = Valuator.includes(:user).all.order("users.username ASC")
+ @valuators = Valuator.includes(:user).all.order("description ASC").order("users.email ASC")
@tags = ActsAsTaggableOn::Tag.spending_proposal_tags
end
diff --git a/app/controllers/admin/valuators_controller.rb b/app/controllers/admin/valuators_controller.rb
index 35c449299..4561e7579 100644
--- a/app/controllers/admin/valuators_controller.rb
+++ b/app/controllers/admin/valuators_controller.rb
@@ -19,9 +19,15 @@ class Admin::ValuatorsController < Admin::BaseController
end
def create
- @valuator.user_id = params[:user_id]
+ @valuator = Valuator.new(create_params)
@valuator.save
redirect_to admin_valuators_path
end
+
+ private
+ def create_params
+ params[:valuator][:description] = nil if params[:valuator][:description].blank?
+ params.require(:valuator).permit(:user_id, :description)
+ end
end
diff --git a/app/helpers/valuators_helper.rb b/app/helpers/valuators_helper.rb
new file mode 100644
index 000000000..752713ed3
--- /dev/null
+++ b/app/helpers/valuators_helper.rb
@@ -0,0 +1,7 @@
+module ValuatorsHelper
+
+ def valuator_label(valuator)
+ truncate([valuator.name, valuator.email, valuator.description].compact.join(' - '), length: 100)
+ end
+
+end
\ No newline at end of file
diff --git a/app/models/valuator.rb b/app/models/valuator.rb
index ab0ea6ece..c7cb6e4a8 100644
--- a/app/models/valuator.rb
+++ b/app/models/valuator.rb
@@ -6,4 +6,8 @@ class Valuator < ActiveRecord::Base
has_many :spending_proposals, through: :valuation_assignments
validates :user_id, presence: true, uniqueness: true
+
+ def description_or_email
+ description.present? ? description : email
+ end
end
diff --git a/app/views/admin/spending_proposals/edit.html.erb b/app/views/admin/spending_proposals/edit.html.erb
index 1dcf5c109..59180eb16 100644
--- a/app/views/admin/spending_proposals/edit.html.erb
+++ b/app/views/admin/spending_proposals/edit.html.erb
@@ -32,7 +32,7 @@
<%= f.label :valuator_ids, t("admin.spending_proposals.edit.assigned_valuators") %>
<%= f.collection_check_boxes :valuator_ids, @valuators, :id, :email do |b| %>
- <%= b.label(title: b.object.name) { b.check_box + b.text } %>
+ <%= b.label(title: valuator_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %>
<% end %>
diff --git a/app/views/admin/valuators/_valuator.html.erb b/app/views/admin/valuators/_valuator.html.erb
index 68c2ae46d..0c64fcef0 100644
--- a/app/views/admin/valuators/_valuator.html.erb
+++ b/app/views/admin/valuators/_valuator.html.erb
@@ -1,7 +1,24 @@
-<%= valuator.name %>
- •
-<%= valuator.email %>
-<% unless valuator.persisted? %>
- <%= link_to t('admin.valuators.valuator.add'),{ controller: "admin/valuators", action: :create, user_id: valuator.user_id },
- method: :post, class: "button small success float-right" %>
-<% end %>
+
<%= t('admin.valuators.valuator.user_found') %>:
+
+
+
+ <%= valuator.name %>
+ •
+ <%= valuator.email %>
+
+
+
+ <% unless @valuator.persisted? %>
+ <%= form_for @valuator, url: admin_valuators_path do |f| %>
+
+
+ <%= f.text_field :description, label: false, placeholder: t('admin.valuators.valuator.description_placeholder') %>
+ <%= f.hidden_field :user_id %>
+
+
+ <%= f.submit t('admin.valuators.valuator.add'), class: "button success float-left" %>
+
+
+ <% end %>
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/admin/valuators/index.html.erb b/app/views/admin/valuators/index.html.erb
index ba5881192..f3abe5e03 100644
--- a/app/views/admin/valuators/index.html.erb
+++ b/app/views/admin/valuators/index.html.erb
@@ -16,7 +16,13 @@
<% @valuators.each do |valuator| %>
-
- <%= render 'valuator', valuator: valuator %>
+ <%= valuator.name %>
+ •
+ <%= valuator.email %>
+ <% if valuator.description.present? %>
+ •
+ <%= valuator.description %>
+ <% end %>
<% end %>
diff --git a/app/views/admin/valuators/search.js.erb b/app/views/admin/valuators/search.js.erb
index e899668ee..4068c146e 100644
--- a/app/views/admin/valuators/search.js.erb
+++ b/app/views/admin/valuators/search.js.erb
@@ -1 +1 @@
-$("#search-result").html("<%= j render 'valuator', valuator: @valuator %>
");
+$("#search-result").html("<%= j render 'valuator', valuator: @valuator %>");
diff --git a/app/views/admin/valuators/user_not_found.js.erb b/app/views/admin/valuators/user_not_found.js.erb
index c28e72e01..1425577f4 100644
--- a/app/views/admin/valuators/user_not_found.js.erb
+++ b/app/views/admin/valuators/user_not_found.js.erb
@@ -1 +1 @@
-$("#search-result").html("<%= j t('admin.valuators.search.user_not_found') %>
");
+$("#search-result").html("<%= j t('admin.valuators.search.user_not_found') %>
");
diff --git a/app/views/debates/show.html.erb b/app/views/debates/show.html.erb
index 93ca49862..941530e58 100644
--- a/app/views/debates/show.html.erb
+++ b/app/views/debates/show.html.erb
@@ -54,8 +54,14 @@
<%= t("debates.show.share") %>
- <%= social_share_button_tag(@debate.title) %>
-
+
+ <%= social_share_button_tag(@debate.title) %>
+ <% if browser.mobile? %>
+
+
+
+ <% end %>
+
<% end %>
diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb
index 3a7434d75..5231439be 100644
--- a/app/views/proposals/show.html.erb
+++ b/app/views/proposals/show.html.erb
@@ -86,7 +86,14 @@
<%= t("proposals.show.share") %>
- <%= social_share_button_tag(@proposal.title) %>
+
+ <%= social_share_button_tag(@proposal.title) %>
+ <% if browser.mobile? %>
+
+
+
+ <% end %>
+
diff --git a/app/views/valuation/spending_proposals/edit.html.erb b/app/views/valuation/spending_proposals/edit.html.erb
index 337f8fa16..edd17504d 100644
--- a/app/views/valuation/spending_proposals/edit.html.erb
+++ b/app/views/valuation/spending_proposals/edit.html.erb
@@ -1,7 +1,7 @@
<%= link_to "#{t('valuation.spending_proposals.show.heading')} #{@spending_proposal.id}", valuation_spending_proposal_path(@spending_proposal), class: 'back' %>
<%= t("valuation.spending_proposals.edit.dossier") %>
-<%= form_for(@spending_proposal, url: valuate_valuation_spending_proposal_path(@spending_proposal)) do |f| %>
+<%= form_for(@spending_proposal, url: valuate_valuation_spending_proposal_path(@spending_proposal), html: {id: "valuation_spending_proposal_edit_form"}) do |f| %>
<%= render 'shared/errors', resource: @spending_proposal %>
-
-
- <%= f.label :feasible_explanation, t("valuation.spending_proposals.edit.feasible_explanation_html") %>
- <%= f.text_area :feasible_explanation, label: false, rows: 3 %>
+
+
+
+
+ <%= f.label :feasible_explanation, t("valuation.spending_proposals.edit.feasible_explanation_html") %>
+ <%= f.text_area :feasible_explanation, label: false, rows: 3 %>
+
+
-
-
- <%= f.label :price, "#{t('valuation.spending_proposals.edit.price_html', currency: t('valuation.spending_proposals.edit.currency'))}" %>
- <%= f.number_field :price, label: false, max: 1000000000000000 %>
+
+
+
+
+ <%= f.label :price, "#{t('valuation.spending_proposals.edit.price_html', currency: t('valuation.spending_proposals.edit.currency'))}" %>
+ <%= f.number_field :price, label: false, max: 1000000000000000 %>
+
+
+
+ <%= f.label :price_first_year, "#{t('valuation.spending_proposals.edit.price_first_year_html', currency: t('valuation.spending_proposals.edit.currency'))}" %>
+ <%= f.number_field :price_first_year, label: false, max: 1000000000000000 %>
+
-
- <%= f.label :price_first_year, "#{t('valuation.spending_proposals.edit.price_first_year_html', currency: t('valuation.spending_proposals.edit.currency'))}" %>
- <%= f.number_field :price_first_year, label: false, max: 1000000000000000 %>
+
+
+ <%= f.label :price_explanation, t("valuation.spending_proposals.edit.price_explanation_html") %>
+ <%= f.text_area :price_explanation, label: false, rows: 3 %>
+
-
-
-
- <%= f.label :price_explanation, t("valuation.spending_proposals.edit.price_explanation_html") %>
- <%= f.text_area :price_explanation, label: false, rows: 3 %>
+
+
+ <%= f.label :time_scope, t("valuation.spending_proposals.edit.time_scope_html") %>
+ <%= f.text_field :time_scope, label: false %>
+
-
-
-
- <%= f.label :time_scope, t("valuation.spending_proposals.edit.time_scope_html") %>
- <%= f.text_field :time_scope, label: false %>
-
diff --git a/app/views/verification/residence/new.html.erb b/app/views/verification/residence/new.html.erb
index 2a2a425a9..23c79ca0e 100644
--- a/app/views/verification/residence/new.html.erb
+++ b/app/views/verification/residence/new.html.erb
@@ -40,18 +40,32 @@
-
+
<%= f.label t("verification.residence.new.document_type_label") %>
<%= f.select :document_type, document_types, prompt: "", label: false %>
- <%= f.label t("verification.residence.new.document_number") %>
+
+
+ <%= f.label t("verification.residence.new.document_number") %>
+
+
+
+
+ <%= t("verification.residence.new.document_number_help_title") %>
+
+
+
+ <%= t("verification.residence.new.document_number_help_text_html") %>
+
+
<%= f.text_field :document_number, label: false %>
-
+
<%= f.label t("verification.residence.new.date_of_birth") %>
<%= f.date_select :date_of_birth,
prompt: true,
@@ -62,7 +76,9 @@
<%= f.label t("verification.residence.new.postal_code") %>
<%= t("verification.residence.new.postal_code_note") %>
- <%= f.text_field :postal_code, label: false %>
+
+ <%= f.text_field :postal_code, label: false %>
+
@@ -78,8 +94,8 @@
<% end %>
-
- <%= f.submit t("verification.residence.new.verify_residence"), class: "button success" %>
+
+ <%= f.submit t("verification.residence.new.verify_residence"), class: "button success expanded" %>
<% end %>
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml
index 4c09952ef..b02626487 100755
--- a/config/locales/admin.en.yml
+++ b/config/locales/admin.en.yml
@@ -77,7 +77,9 @@ en:
index:
title: Valuators
valuator:
- add: Add
+ description_placeholder: 'Description (optional)'
+ user_found: User found
+ add: Add to valuators
search:
email_placeholder: Search user by email
search: Search
diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml
index 922191d49..abda1e94f 100644
--- a/config/locales/admin.es.yml
+++ b/config/locales/admin.es.yml
@@ -77,7 +77,9 @@ es:
index:
title: Evaluadores
valuator:
- add: Añadir
+ description_placeholder: "Descripción (opcional)"
+ user_found: Usuario encontrado
+ add: Añadir como evaluador
search:
email_placeholder: Buscar usuario por email
search: Buscar
diff --git a/config/locales/settings.en.yml b/config/locales/settings.en.yml
index c51eb7831..756debb24 100755
--- a/config/locales/settings.en.yml
+++ b/config/locales/settings.en.yml
@@ -1,5 +1,6 @@
en:
settings:
+ comments_body_max_length: "Comments body max length"
official_level_1_name: "Level 1 public official"
official_level_2_name: "Level 2 public official"
official_level_3_name: "Level 3 public official"
diff --git a/config/locales/settings.es.yml b/config/locales/settings.es.yml
index 98ff6ae39..36d4edf63 100644
--- a/config/locales/settings.es.yml
+++ b/config/locales/settings.es.yml
@@ -1,5 +1,6 @@
es:
settings:
+ comments_body_max_length: "Longitud máxima de los comentarios"
official_level_1_name: "Cargos públicos de nivel 1"
official_level_2_name: "Cargos públicos de nivel 2"
official_level_3_name: "Cargos públicos de nivel 3"
diff --git a/config/locales/verification.en.yml b/config/locales/verification.en.yml
index 4c78108ba..24c9ae928 100755
--- a/config/locales/verification.en.yml
+++ b/config/locales/verification.en.yml
@@ -54,6 +54,8 @@ en:
accept_terms_text_title: I accept the terms and conditions of access of the Census
date_of_birth: Date of birth
document_number: Document number
+ document_number_help_title: Help
+ document_number_help_text_html: '
DNI: 12345678A
Passport: AAA000001
Residence card: X1234567P'
document_type:
passport: Passport
residence_card: Residence card
diff --git a/config/locales/verification.es.yml b/config/locales/verification.es.yml
index 7434ec5b7..be676ab0f 100644
--- a/config/locales/verification.es.yml
+++ b/config/locales/verification.es.yml
@@ -54,6 +54,8 @@ es:
accept_terms_text_title: Acepto los términos de acceso al Padrón
date_of_birth: Fecha de nacimiento
document_number: Número de documento
+ document_number_help_title: Ayuda
+ document_number_help_text_html: '
DNI: 12345678A
Pasaporte: AAA000001
Tarjeta de residencia: X1234567P'
document_type:
passport: Pasaporte
residence_card: Tarjeta de residencia
diff --git a/db/migrate/20160315092854_add_description_to_valuators.rb b/db/migrate/20160315092854_add_description_to_valuators.rb
new file mode 100644
index 000000000..d5527dc36
--- /dev/null
+++ b/db/migrate/20160315092854_add_description_to_valuators.rb
@@ -0,0 +1,5 @@
+class AddDescriptionToValuators < ActiveRecord::Migration
+ def change
+ add_column :valuators, :description, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 79034e405..96e2c8427 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -435,6 +435,7 @@ ActiveRecord::Schema.define(version: 20160315084335) do
create_table "valuators", force: :cascade do |t|
t.integer "user_id"
+ t.string "description"
end
add_index "valuators", ["user_id"], name: "index_valuators_on_user_id", using: :btree
diff --git a/spec/features/admin/valuators_spec.rb b/spec/features/admin/valuators_spec.rb
index a4b17f699..d95432474 100644
--- a/spec/features/admin/valuators_spec.rb
+++ b/spec/features/admin/valuators_spec.rb
@@ -20,9 +20,12 @@ feature 'Admin valuators' do
click_button 'Search'
expect(page).to have_content @user.name
- click_link 'Add'
+ fill_in 'valuator_description', with: 'environmental expert'
+ click_button 'Add to valuators'
+
within("#valuators") do
expect(page).to have_content @user.name
+ expect(page).to have_content 'environmental expert'
end
end
diff --git a/spec/features/valuation/spending_proposals_spec.rb b/spec/features/valuation/spending_proposals_spec.rb
index 7de8d9b66..8af416dc2 100644
--- a/spec/features/valuation/spending_proposals_spec.rb
+++ b/spec/features/valuation/spending_proposals_spec.rb
@@ -288,6 +288,60 @@ feature 'Valuation spending proposals' do
expect(find "#spending_proposal_feasible_nil").to be_checked
end
+ scenario 'Feasibility selection makes proper fields visible', :js do
+ feasible_true_fields = ['Price (€)','Cost during the first year (€)','Price explanation','Time scope']
+ feasible_false_fields = ['Feasibility explanation']
+ feasible_any_fields = ['Valuation finished','Internal comments']
+ feasible_nil_fields = feasible_true_fields + feasible_false_fields + feasible_any_fields
+
+ visit edit_valuation_spending_proposal_path(@spending_proposal)
+
+ expect(find "#spending_proposal_feasible_nil").to be_checked
+
+ feasible_nil_fields.each do |field|
+ expect(page).to have_content(field)
+ end
+
+ choose 'spending_proposal_feasible_true'
+
+ feasible_false_fields.each do |field|
+ expect(page).to_not have_content(field)
+ end
+
+ (feasible_true_fields + feasible_any_fields).each do |field|
+ expect(page).to have_content(field)
+ end
+
+ choose 'spending_proposal_feasible_false'
+
+ feasible_true_fields.each do |field|
+ expect(page).to_not have_content(field)
+ end
+
+ (feasible_false_fields + feasible_any_fields).each do |field|
+ expect(page).to have_content(field)
+ end
+
+ click_button 'Save changes'
+
+ visit edit_valuation_spending_proposal_path(@spending_proposal)
+
+ expect(find "#spending_proposal_feasible_false").to be_checked
+ feasible_true_fields.each do |field|
+ expect(page).to_not have_content(field)
+ end
+
+ (feasible_false_fields + feasible_any_fields).each do |field|
+ expect(page).to have_content(field)
+ end
+
+ choose 'spending_proposal_feasible_nil'
+
+ feasible_nil_fields.each do |field|
+ expect(page).to have_content(field)
+ end
+ end
+
scenario 'Finish valuation' do
visit valuation_spending_proposal_path(@spending_proposal)
click_link 'Edit dossier'
diff --git a/spec/models/valuator_spec.rb b/spec/models/valuator_spec.rb
new file mode 100644
index 000000000..326eda7dc
--- /dev/null
+++ b/spec/models/valuator_spec.rb
@@ -0,0 +1,18 @@
+require 'rails_helper'
+
+describe Valuator do
+
+ describe "#description_or_email" do
+ it "should return description if present" do
+ valuator = create(:valuator, description: "Urbanism manager")
+
+ expect(valuator.description_or_email).to eq("Urbanism manager")
+ end
+
+ it "should return email if not description present" do
+ valuator = create(:valuator)
+
+ expect(valuator.description_or_email).to eq(valuator.email)
+ end
+ end
+end