Merge pull request #3388 from consul/dashboard-polish
Refactor dashboard views
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Livello_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="40px" height="40px" viewBox="0 0 40 40" enable-background="new 0 0 40 40" xml:space="preserve">
|
||||
<g style="fill:#0300ff;">
|
||||
<path d="M9.223,5.404c-4.342,0-7.979,3.634-7.979,7.977c0,4.342,3.028,7.27,6.865,7.27c0.809,0,1.617-0.102,2.02-0.303
|
||||
c-0.898,3.602-4.307,7.642-7.512,9.387c-0.008,0.003-0.013,0.008-0.019,0.011c-0.024,0.013-0.048,0.031-0.071,0.044l0.003,0.002
|
||||
c-0.354,0.19-0.604,0.553-0.604,0.983c0,0.388,0.207,0.713,0.505,0.916l-0.025,0.024l4.196,2.649l0.013-0.011
|
||||
c0.189,0.143,0.413,0.242,0.669,0.242c0.184,0,0.35-0.055,0.504-0.133l0.021,0.02c6.26-4.443,10.401-11.206,10.401-18.78
|
||||
C18.207,9.139,13.967,5.404,9.223,5.404z"/>
|
||||
<path d="M29.77,5.404c-4.342,0-7.979,3.634-7.979,7.977c0,4.342,3.028,7.27,6.865,7.27c0.809,0,1.617-0.102,2.021-0.303
|
||||
c-0.899,3.602-4.308,7.642-7.513,9.387c-0.008,0.003-0.013,0.008-0.019,0.011c-0.024,0.013-0.048,0.031-0.071,0.044l0.004,0.002
|
||||
c-0.355,0.19-0.605,0.553-0.605,0.983c0,0.388,0.208,0.713,0.505,0.916l-0.024,0.024l4.195,2.649l0.014-0.011
|
||||
c0.188,0.143,0.412,0.242,0.668,0.242c0.184,0,0.35-0.055,0.504-0.133l0.021,0.02c6.26-4.443,10.401-11.206,10.401-18.78
|
||||
C38.754,9.139,34.514,5.404,29.77,5.404z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.5 KiB |
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Livello_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="40px" height="40px" viewBox="0 0 40 40" enable-background="new 0 0 40 40" xml:space="preserve">
|
||||
<path style="fill:#0300ff;" d="M11.572,19.713c-0.809,0-1.617,0.101-2.02,0.303c0.899-3.602,4.307-7.642,7.513-9.387c0.007-0.003,0.012-0.008,0.018-0.011
|
||||
c0.024-0.013,0.048-0.031,0.071-0.044l-0.003-0.002c0.355-0.19,0.605-0.552,0.605-0.983c0-0.388-0.208-0.713-0.505-0.916
|
||||
l0.025-0.024l-4.196-2.65L13.067,6.01c-0.189-0.143-0.413-0.242-0.668-0.242c-0.184,0-0.35,0.054-0.504,0.132l-0.021-0.019
|
||||
c-6.26,4.442-10.401,11.206-10.401,18.78c0,6.562,4.241,10.297,8.985,10.297c4.342,0,7.978-3.634,7.978-7.978
|
||||
C18.437,22.641,15.409,19.713,11.572,19.713z"/>
|
||||
<path style="fill:#0300ff;" d="M32.119,19.713c-0.809,0-1.617,0.101-2.02,0.303c0.897-3.602,4.307-7.642,7.512-9.387c0.008-0.003,0.013-0.008,0.019-0.011
|
||||
c0.024-0.013,0.048-0.031,0.071-0.044l-0.003-0.002c0.354-0.19,0.604-0.552,0.604-0.983c0-0.388-0.206-0.713-0.505-0.916
|
||||
l0.025-0.024l-4.196-2.65L33.613,6.01c-0.188-0.143-0.412-0.242-0.668-0.242c-0.184,0-0.35,0.054-0.504,0.132L32.42,5.881
|
||||
c-6.26,4.442-10.4,11.206-10.4,18.78c0,6.562,4.242,10.297,8.984,10.297c4.344,0,7.979-3.634,7.979-7.978
|
||||
C38.984,22.641,35.956,19.713,32.119,19.713z"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
@@ -52,10 +52,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
.supports .counter-label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.counter-value {
|
||||
font-size: rem-calc(20);
|
||||
font-weight: bold;
|
||||
|
||||
@@ -299,7 +299,7 @@
|
||||
display: block;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
background-image: url(quote-before.svg);
|
||||
background-image: url("quote_before_blue.png");
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
@@ -309,17 +309,16 @@
|
||||
display: block;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
background-image: url(quote-after.svg);
|
||||
background-image: url("quote_after_blue.png");
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
|
||||
.icon-finger::before {
|
||||
content: '';
|
||||
background-size: cover;
|
||||
display: inline-block;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
background-image: url(finger.svg);
|
||||
background-image: url("finger.png");
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class Dashboard::Action < ActiveRecord::Base
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
has_many :executed_actions, dependent: :restrict_with_error, class_name: 'Dashboard::ExecutedAction'
|
||||
has_many :executed_actions, dependent: :restrict_with_error, class_name: "Dashboard::ExecutedAction"
|
||||
has_many :proposals, through: :executed_actions
|
||||
|
||||
enum action_type: [:proposed_action, :resource]
|
||||
@@ -53,15 +53,15 @@ class Dashboard::Action < ActiveRecord::Base
|
||||
def self.active_for(proposal)
|
||||
published_at = proposal.published_at&.to_date || Date.today
|
||||
|
||||
active.where('required_supports <= ?', proposal.cached_votes_up)
|
||||
.where('day_offset <= ?', (Date.today - published_at).to_i)
|
||||
active.where("required_supports <= ?", proposal.cached_votes_up)
|
||||
.where("day_offset <= ?", (Date.today - published_at).to_i)
|
||||
.by_proposal(proposal)
|
||||
end
|
||||
|
||||
def self.course_for(proposal)
|
||||
active
|
||||
.resources
|
||||
.where('required_supports > ?', proposal.cached_votes_up)
|
||||
.where("required_supports > ?", proposal.cached_votes_up)
|
||||
.order(required_supports: :asc)
|
||||
end
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
</div>
|
||||
|
||||
<div class="row expanded margin-top">
|
||||
<div class="small-12 medium-12 column">
|
||||
<div class="small-12 column">
|
||||
<%= f.check_box :published_proposal, label: t("admin.dashboard.actions.form.published_proposal") %>
|
||||
<p class="help-text"><%= t("admin.dashboard.actions.form.published_proposal_help_text") %></p>
|
||||
</div>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<th class="text-center"><%= t("admin.dashboard.actions.index.day_offset") %></th>
|
||||
<th class="text-center"><%= t("admin.dashboard.actions.index.required_supports") %></th>
|
||||
<th class="text-center"><%= t("admin.dashboard.actions.index.order") %></th>
|
||||
<th class="text-right"><%= t("admin.actions.actions") %></th>
|
||||
<th class="text-right small-3"><%= t("admin.actions.actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
||||
@@ -20,28 +20,22 @@
|
||||
<p class="inline">
|
||||
<%= l(proposed_action.executed_actions.find_by(proposal: proposal).executed_at.to_date) %>
|
||||
</p>
|
||||
<% if proposed_action.description.present? %>
|
||||
<a data-toggle="proposed_action_description_<%= dom_id(proposed_action) %>">
|
||||
<small><%= t("dashboard.recommended_actions.show_description") %></small>
|
||||
</a>
|
||||
<div id="proposed_action_description_<%= dom_id(proposed_action) %>" class="hide" data-toggler=".hide">
|
||||
<%= proposed_action.description.html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if proposed_action.description.present? %>
|
||||
<a data-toggle="proposed_action_description_<%= dom_id(proposed_action) %>">
|
||||
<small><%= t("dashboard.recommended_actions.show_description") %></small>
|
||||
</a>
|
||||
<div id="proposed_action_description_<%= dom_id(proposed_action) %>" class="hide" data-toggler=".hide">
|
||||
<%= proposed_action.description.html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% proposed_action.links.each do |link| %>
|
||||
<p><%= link_to link.label, link.url, target: "_blank" %></p>
|
||||
<% end %>
|
||||
<%= render partial: 'document', collection: proposed_action.documents %>
|
||||
<% end %>
|
||||
|
||||
<% if proposed_action.description.present? %>
|
||||
<a data-toggle="proposed_action_description_<%= dom_id(proposed_action) %>">
|
||||
<small><%= t("dashboard.recommended_actions.show_description") %></small>
|
||||
</a>
|
||||
<div id="proposed_action_description_<%= dom_id(proposed_action) %>" class="hide" data-toggler=".hide">
|
||||
<%= proposed_action.description.html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% proposed_action.links.each do |link| %>
|
||||
<p><%= link_to link.label, link.url, target: "_blank" %></p>
|
||||
<% end %>
|
||||
|
||||
<%= render partial: 'document', collection: proposed_action.documents %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="background: #0300ff; padding: 50px; padding-top:40px; text-align: left;">
|
||||
<%= image_tag 'quote-before-white.png', style: 'max-width: 40px; vertical-align: top;' %>
|
||||
<%= image_tag "quote_before_white.png", style: "max-width: 40px; vertical-align: top;" %>
|
||||
<h1 style="color: #fff; font-size: 60px; line-height: 90px; display: inline;"><%= @proposal.title %></h1>
|
||||
<%= image_tag 'quote-after-white.png', style: 'max-width: 40px; vertical-align: top;' %>
|
||||
<h2 style="color: #fff; font-size: 40px; line-height: 60px"><%= t("dashboard.mailer.forward.subtitle").html_safe %></h2>
|
||||
<%= image_tag "quote_after_white.png", style: "max-width: 40px; vertical-align: top;" %>
|
||||
<h2 style="color: #fff; font-size: 40px; line-height: 60px"><%= t("dashboard.mailer.forward.subtitle_html") %></h2>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<div class="row expanded">
|
||||
<div class="small-12 medium-9 dashboard-mail-preview column dashboard-mail-preview">
|
||||
<div class="mail-header text-left">
|
||||
<%= image_tag 'quote-before-white.png' %>
|
||||
<%= image_tag "quote_before_white.png" %>
|
||||
<h1 class="inline"><%= proposal.title %></h1>
|
||||
<%= image_tag 'quote-after-white.png' %>
|
||||
<h2><%= t("dashboard.mailer.forward.subtitle").html_safe %></h2>
|
||||
<%= image_tag "quote_after_white.png" %>
|
||||
<h2><%= t("dashboard.mailer.forward.subtitle_html") %></h2>
|
||||
</div>
|
||||
|
||||
<div class="margin-bottom">
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
<%= image_tag("finger.png") %>
|
||||
<%= t("dashboard.poster.index.poster_subtitle") %>
|
||||
</h1>
|
||||
<p class="intro"><%= t("dashboard.poster.index.intro_text", org: Setting["org_name"]).html_safe %></p>
|
||||
<p class="intro">
|
||||
<%= t("dashboard.poster.index.intro_text_html", org: Setting["org_name"]) %>
|
||||
</p>
|
||||
|
||||
<p class="text-center">
|
||||
<strong><%= t("dashboard.poster.index.proposal_code", code: proposal.code) %></strong>
|
||||
@@ -23,11 +25,11 @@
|
||||
</div>
|
||||
<div class="poster-content">
|
||||
<h2><%= t("dashboard.poster.index.support") %></h2>
|
||||
<%= image_tag 'quote-before-blue.png' %>
|
||||
<%= image_tag "quote_before_blue.png" %>
|
||||
<h3><%= proposal.title %></h3>
|
||||
<%= image_tag 'quote-after-blue.png' %>
|
||||
<%= image_tag "quote_after_blue.png" %>
|
||||
<p class="poster-footer">
|
||||
<%= t("dashboard.poster.index.footer", link: Setting["url"]).html_safe %>
|
||||
<%= t("dashboard.poster.index.footer_html", link: proposal_url(proposal)) %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
</strong>
|
||||
</h1>
|
||||
<p class="intro">
|
||||
<%= t("dashboard.poster.index.intro_text", org: Setting["org_name"]).html_safe %>
|
||||
<%= t("dashboard.poster.index.intro_text_html", org: Setting["org_name"]) %>
|
||||
</p>
|
||||
<p class="text-center proposal-code">
|
||||
<strong><%= t("dashboard.poster.index.proposal_code", code: proposal.code) %></strong>
|
||||
@@ -30,11 +30,11 @@
|
||||
</div>
|
||||
<div class="poster-content">
|
||||
<h2 class="text-center"><strong><%= t("dashboard.poster.index.support") %></strong></h2>
|
||||
<%= wicked_pdf_image_tag 'quote-before-blue.png' %>
|
||||
<%= wicked_pdf_image_tag "quote_before_blue.png" %>
|
||||
<h3><strong><%= proposal.title %></strong></h3>
|
||||
<%= wicked_pdf_image_tag 'quote-after-blue.png' %>
|
||||
<%= wicked_pdf_image_tag "quote_after_blue.png" %>
|
||||
<p class="poster-footer">
|
||||
<%= t("dashboard.poster.index.footer", link: Setting["url"]).html_safe %>
|
||||
<%= t("dashboard.poster.index.footer_html", link: proposal_url(proposal)) %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -24,9 +24,13 @@
|
||||
<div class="counter-value">
|
||||
<%= number_with_delimiter(proposal.votes_for.size, delimiter: '.') %>
|
||||
/
|
||||
<%= t("layouts.dashboard.proposal_totals.support_count", count: number_with_delimiter(next_goal_supports, delimiter: '.')).html_safe %>
|
||||
<%= number_with_delimiter(next_goal_supports, delimiter: '.') %>
|
||||
</div>
|
||||
<div class="counter-label">
|
||||
<%= t("layouts.dashboard.proposal_totals.supports", count: proposal.votes_for.size) %>
|
||||
<br>
|
||||
<%= t("layouts.dashboard.proposal_totals.current_goal") %>
|
||||
</div>
|
||||
<span class="counter-label"><%= t("layouts.dashboard.proposal_totals.current_goal") %></span>
|
||||
</div>
|
||||
|
||||
<div class="next-goal-progress">
|
||||
@@ -40,11 +44,7 @@
|
||||
|
||||
<div class="small-12 medium-6 large-4 column">
|
||||
<div class="row">
|
||||
<div class="small-12 medium-12 column">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-12 column">
|
||||
<div class="small-12 column">
|
||||
<div class="proposal-link">
|
||||
<% if proposal.draft? %>
|
||||
<%= link_to t('layouts.dashboard.proposal_totals.preview_proposal'), proposal_path(proposal), class: 'button success expanded', target: '_blank' %>
|
||||
|
||||
@@ -210,9 +210,10 @@ en:
|
||||
show_proposal: Show proposal
|
||||
preview_proposal: Preview proposal
|
||||
current_goal: Current goal
|
||||
support_count:
|
||||
one: "%{count} support"
|
||||
other: "%{count} supports"
|
||||
supports:
|
||||
zero: No supports
|
||||
one: 1 Support
|
||||
other: "Supports"
|
||||
footer:
|
||||
accessibility: Accessibility
|
||||
conditions: Terms and conditions of use
|
||||
@@ -575,12 +576,12 @@ en:
|
||||
title: Poster preview
|
||||
poster_title: "Do not keep looking,"
|
||||
poster_subtitle: "back me up! ;)"
|
||||
intro_text:
|
||||
<strong>I am participating in %{org}</strong> with my own citizen proposal and only if you also add you can I achieve the
|
||||
necessary support to make Madrid the city we all want.
|
||||
intro_text_html:
|
||||
"<strong>I am participating in %{org}</strong> with my own citizen proposal and only if you also add you can I achieve the
|
||||
necessary support to make the city we all want."
|
||||
proposal_code: "Code of the proposal: %{code}"
|
||||
support: Support my proposal
|
||||
footer: Visit %{link} and support this proposal. We need to be many. Decide your too. Thank you!
|
||||
footer_html: "<strong>Visit %{link} and support this proposal.</strong> We need to be many. Decide your too. Thank you!"
|
||||
new:
|
||||
title: Poster feature
|
||||
options:
|
||||
@@ -598,7 +599,7 @@ en:
|
||||
sent: The email has been sent
|
||||
mailer:
|
||||
forward:
|
||||
subtitle: If you support me, <br>we will achieve it.
|
||||
subtitle_html: "If you support me, <br>we will achieve it."
|
||||
support_button: Support this proposal
|
||||
share_in: Share in
|
||||
hi: "Hello!"
|
||||
|
||||
@@ -210,9 +210,10 @@ es:
|
||||
show_proposal: Ver propuesta
|
||||
preview_proposal: Previsualizar propuesta
|
||||
current_goal: Meta actual
|
||||
support_count:
|
||||
one: "%{count} <span class='counter-label'>Apoyo</span>"
|
||||
other: "%{count} <span class='counter-label'>Apoyos</span>"
|
||||
supports:
|
||||
zero: Sin apoyos
|
||||
one: 1 Apoyo
|
||||
other: "Apoyos"
|
||||
footer:
|
||||
accessibility: Accesibilidad
|
||||
conditions: Condiciones de uso
|
||||
@@ -575,12 +576,12 @@ es:
|
||||
title: Previsualización del poster
|
||||
poster_title: "No te quedes mirando,"
|
||||
poster_subtitle: "¡apóyame! ;)"
|
||||
intro_text:
|
||||
<strong>Estoy participando en %{org}</strong> con mi propia propuesta ciudadana y sólo si tú también te sumas podré lograr el
|
||||
apoyo necesario para hacer de madrid la ciudad que todos queremos.
|
||||
intro_text_html:
|
||||
"<strong>Estoy participando en %{org}</strong> con mi propia propuesta ciudadana y sólo si tú también te sumas podré lograr el
|
||||
apoyo necesario para hacer la ciudad que todos queremos."
|
||||
proposal_code: "Código de la propuesta: %{code}"
|
||||
support: Apoya mi propuesta
|
||||
footer: <strong>Entra en %{link} y apoya esta propuesta.</strong> Necesitamos ser muchos. Decide tu también. ¡Gracias!
|
||||
footer_html: "<strong>Entra en %{link} y apoya esta propuesta.</strong> Necesitamos ser muchos. Decide tu también. ¡Gracias!"
|
||||
new:
|
||||
title: Funcionalidad de póster
|
||||
options:
|
||||
@@ -598,7 +599,7 @@ es:
|
||||
sent: El e-mail ha sido enviado
|
||||
mailer:
|
||||
forward:
|
||||
subtitle: Si me apoyas, <br>lo conseguiremos.
|
||||
subtitle_html: "Si me apoyas, <br>lo conseguiremos."
|
||||
support_button: Apoyar esta propuesta
|
||||
share_in: Compartir en
|
||||
hi: "¡Hola!"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature "Proposal's dashboard" do
|
||||
let!(:proposal) { create(:proposal, :draft) }
|
||||
@@ -8,45 +8,47 @@ feature "Proposal's dashboard" do
|
||||
visit proposal_dashboard_path(proposal)
|
||||
end
|
||||
|
||||
scenario 'Dashboard has a link to my proposal' do
|
||||
expect(page).to have_link('My proposal')
|
||||
scenario "Dashboard has a link to my proposal" do
|
||||
expect(page).to have_link("My proposal")
|
||||
end
|
||||
|
||||
scenario 'My proposal has a link to edit the proposal' do
|
||||
expect(page).to have_link('Edit proposal')
|
||||
scenario "My proposal has a link to edit the proposal" do
|
||||
expect(page).to have_link("Edit proposal")
|
||||
end
|
||||
|
||||
scenario 'My proposal has a link to retire the proposal' do
|
||||
expect(page).to have_link('Retire proposal')
|
||||
scenario "My proposal has a link to retire the proposal" do
|
||||
expect(page).to have_link("Retire proposal")
|
||||
end
|
||||
|
||||
scenario 'My proposal has a link to publish the proposal' do
|
||||
expect(page).to have_link('Publish proposal')
|
||||
scenario "My proposal has a link to publish the proposal" do
|
||||
expect(page).to have_link("Publish proposal")
|
||||
end
|
||||
|
||||
scenario "Publish link dissapears after proposal's publication" do
|
||||
click_link 'Publish proposal'
|
||||
expect(page).not_to have_link('Publish proposal')
|
||||
click_link "Publish proposal"
|
||||
expect(page).not_to have_link("Publish proposal")
|
||||
end
|
||||
|
||||
scenario 'Dashboard progress shows current goal', js: true do
|
||||
goal = create(:dashboard_action, :resource, :active, required_supports: proposal.votes_for.size + 1_000)
|
||||
future_goal = create(:dashboard_action, :resource, :active, required_supports: proposal.votes_for.size + 2_000)
|
||||
scenario "Dashboard progress shows current goal", js: true do
|
||||
goal = create(:dashboard_action, :resource, :active,
|
||||
required_supports: proposal.votes_for.size + 1_000)
|
||||
future_goal = create(:dashboard_action, :resource, :active,
|
||||
required_supports: proposal.votes_for.size + 2_000)
|
||||
|
||||
visit progress_proposal_dashboard_path(proposal)
|
||||
|
||||
within 'div#goals-section' do
|
||||
within "div#goals-section" do
|
||||
expect(page).to have_content(goal.title)
|
||||
expect(page).not_to have_content(future_goal.title)
|
||||
|
||||
find(:css, '#see_complete_course_link').click
|
||||
find(:css, "#see_complete_course_link").click
|
||||
|
||||
expect(page).to have_content(goal.title)
|
||||
expect(page).to have_content(future_goal.title)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Dashboard progress show proposed actions' do
|
||||
scenario "Dashboard progress show proposed actions" do
|
||||
action = create(:dashboard_action, :proposed_action, :active)
|
||||
|
||||
visit progress_proposal_dashboard_path(proposal)
|
||||
@@ -110,8 +112,7 @@ feature "Proposal's dashboard" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Dashboard progress display contains no results text when there are not
|
||||
proposed_actions pending" do
|
||||
scenario "Display no results text when there are not proposed_actions done" do
|
||||
visit progress_proposal_dashboard_path(proposal)
|
||||
|
||||
expect(page).to have_content("No recommended actions done")
|
||||
@@ -241,36 +242,36 @@ feature "Proposal's dashboard" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Dashboard has a link to polls feature' do
|
||||
expect(page).to have_link('Polls')
|
||||
scenario "Dashboard has a link to polls feature" do
|
||||
expect(page).to have_link("Polls")
|
||||
end
|
||||
|
||||
scenario 'Dashboard has a link to e-mail feature' do
|
||||
expect(page).to have_link('E-mail')
|
||||
scenario "Dashboard has a link to e-mail feature" do
|
||||
expect(page).to have_link("E-mail")
|
||||
end
|
||||
|
||||
scenario 'Dashboard has a link to poster feature' do
|
||||
expect(page).to have_link('Poster')
|
||||
scenario "Dashboard has a link to poster feature" do
|
||||
expect(page).to have_link("Poster")
|
||||
end
|
||||
|
||||
scenario 'Dashboard has a link to resources on main menu' do
|
||||
scenario "Dashboard has a link to resources on main menu" do
|
||||
feature = create(:dashboard_action, :resource, :active)
|
||||
|
||||
visit proposal_dashboard_path(proposal)
|
||||
expect(page).to have_link(feature.title)
|
||||
end
|
||||
|
||||
scenario 'Request resource with admin request', js: true do
|
||||
scenario "Request resource with admin request", js: true do
|
||||
feature = create(:dashboard_action, :resource, :active, :admin_request)
|
||||
|
||||
visit proposal_dashboard_path(proposal)
|
||||
click_link(feature.title)
|
||||
|
||||
click_button 'Request'
|
||||
expect(page).to have_content('The request for the administrator has been successfully sent.')
|
||||
click_button "Request"
|
||||
expect(page).to have_content("The request for the administrator has been successfully sent.")
|
||||
end
|
||||
|
||||
scenario 'Request already requested resource with admin request', js: true do
|
||||
scenario "Request already requested resource with admin request", js: true do
|
||||
feature = create(:dashboard_action, :resource, :active, :admin_request)
|
||||
|
||||
visit proposal_dashboard_path(proposal)
|
||||
@@ -278,27 +279,27 @@ feature "Proposal's dashboard" do
|
||||
|
||||
create(:dashboard_executed_action, action: feature, proposal: proposal)
|
||||
|
||||
click_button 'Request'
|
||||
expect(page).to have_content('Proposal has already been taken')
|
||||
click_button "Request"
|
||||
expect(page).to have_content("Proposal has already been taken")
|
||||
end
|
||||
|
||||
scenario 'Resource without admin request do not have a request link', js: true do
|
||||
scenario "Resource without admin request do not have a request link", js: true do
|
||||
feature = create(:dashboard_action, :resource, :active)
|
||||
|
||||
visit proposal_dashboard_path(proposal)
|
||||
click_link(feature.title)
|
||||
|
||||
expect(page).not_to have_button('Request')
|
||||
expect(page).not_to have_button("Request")
|
||||
end
|
||||
|
||||
scenario 'Dashboard has a link to dashboard community', js: true do
|
||||
expect(page).to have_link('Community')
|
||||
click_link 'Community'
|
||||
scenario "Dashboard has a link to dashboard community", js: true do
|
||||
expect(page).to have_link("Community")
|
||||
click_link "Community"
|
||||
|
||||
expect(page).to have_content('Participants')
|
||||
expect(page).to have_content('Debates')
|
||||
expect(page).to have_content('Comments')
|
||||
expect(page).to have_link('Access the community')
|
||||
expect(page).to have_content("Participants")
|
||||
expect(page).to have_content("Debates")
|
||||
expect(page).to have_content("Comments")
|
||||
expect(page).to have_link("Access the community")
|
||||
end
|
||||
|
||||
scenario "Dashboard has a link to recommended_actions", js: true do
|
||||
@@ -321,7 +322,7 @@ feature "Proposal's dashboard" do
|
||||
expect(page).to have_content(action_5.title)
|
||||
end
|
||||
|
||||
scenario "On recommended actions section do not display from the fourth proposed actions", js: true do
|
||||
scenario "On recommended actions section display four proposed actions", js: true do
|
||||
create_list(:dashboard_action, 4, :proposed_action, :active)
|
||||
action_5 = create(:dashboard_action, :proposed_action, :active)
|
||||
|
||||
@@ -359,7 +360,7 @@ feature "Proposal's dashboard" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "On recommended actions section contains no_results_text when there are
|
||||
scenario "On recommended actions section contains no results text when there are
|
||||
not proposed_actions pending" do
|
||||
visit recommended_actions_proposal_dashboard_path(proposal.to_param)
|
||||
|
||||
|
||||
@@ -16,88 +16,88 @@ describe Dashboard::Action do
|
||||
let(:day_offset) { 0 }
|
||||
let(:required_supports) { 0 }
|
||||
let(:request_to_administrators) { true }
|
||||
let(:action_type) { 'resource' }
|
||||
let(:action_type) { "resource" }
|
||||
|
||||
it 'is invalid when title is blank' do
|
||||
action = build(:dashboard_action, title: '')
|
||||
it "is invalid when title is blank" do
|
||||
action = build(:dashboard_action, title: "")
|
||||
expect(action).not_to be_valid
|
||||
end
|
||||
|
||||
it 'is invalid when title is too short' do
|
||||
action = build(:dashboard_action, title: 'abc')
|
||||
it "is invalid when title is too short" do
|
||||
action = build(:dashboard_action, title: "abc")
|
||||
expect(action).not_to be_valid
|
||||
end
|
||||
|
||||
it 'is invalid when title is too long' do
|
||||
action = build(:dashboard_action, title: 'a' * 81)
|
||||
it "is invalid when title is too long" do
|
||||
action = build(:dashboard_action, title: "a" * 81)
|
||||
expect(action).not_to be_valid
|
||||
end
|
||||
|
||||
it 'is invalid when day_offset is not defined' do
|
||||
it "is invalid when day_offset is not defined" do
|
||||
action = build(:dashboard_action, day_offset: nil)
|
||||
expect(action).not_to be_valid
|
||||
end
|
||||
|
||||
it 'is invalid when day_offset is negative' do
|
||||
it "is invalid when day_offset is negative" do
|
||||
action = build(:dashboard_action, day_offset: -1)
|
||||
expect(action).not_to be_valid
|
||||
end
|
||||
|
||||
it 'is invalid when day_offset not an integer' do
|
||||
it "is invalid when day_offset not an integer" do
|
||||
action = build(:dashboard_action, day_offset: 1.23)
|
||||
expect(action).not_to be_valid
|
||||
end
|
||||
|
||||
it 'is invalid when required_supports is nil' do
|
||||
it "is invalid when required_supports is nil" do
|
||||
action = build(:dashboard_action, required_supports: nil)
|
||||
expect(action).not_to be_valid
|
||||
end
|
||||
|
||||
it 'is invalid when required_supports is negative' do
|
||||
it "is invalid when required_supports is negative" do
|
||||
action = build(:dashboard_action, required_supports: -1)
|
||||
expect(action).not_to be_valid
|
||||
end
|
||||
|
||||
it 'is invalid when required_supports is not an integer' do
|
||||
it "is invalid when required_supports is not an integer" do
|
||||
action = build(:dashboard_action, required_supports: 1.23)
|
||||
expect(action).not_to be_valid
|
||||
end
|
||||
|
||||
it 'is invalid when action_type is nil' do
|
||||
it "is invalid when action_type is nil" do
|
||||
action = build(:dashboard_action, action_type: nil)
|
||||
expect(action).not_to be_valid
|
||||
end
|
||||
|
||||
context '#active_for?' do
|
||||
it 'is active when required supports is 0 and day_offset is 0' do
|
||||
context "#active_for?" do
|
||||
it "is active when required supports is 0 and day_offset is 0" do
|
||||
action = build(:dashboard_action, required_supports: 0, day_offset: 0)
|
||||
proposal = build(:proposal)
|
||||
|
||||
expect(action).to be_active_for(proposal)
|
||||
end
|
||||
|
||||
it 'is active when published after day_offset' do
|
||||
it "is active when published after day_offset" do
|
||||
action = build(:dashboard_action, required_supports: 0, day_offset: 10)
|
||||
proposal = build(:proposal, published_at: Time.current - 10.days)
|
||||
|
||||
expect(action).to be_active_for(proposal)
|
||||
end
|
||||
|
||||
it 'is active when have enough supports' do
|
||||
it "is active when have enough supports" do
|
||||
action = build(:dashboard_action, required_supports: 10, day_offset: 0)
|
||||
proposal = build(:proposal, cached_votes_up: 10)
|
||||
|
||||
expect(action).to be_active_for(proposal)
|
||||
end
|
||||
|
||||
it 'is not active when not enough time published' do
|
||||
it "is not active when not enough time published" do
|
||||
action = build(:dashboard_action, required_supports: 0, day_offset: 10)
|
||||
proposal = build(:proposal, published_at: Time.current - 9.days)
|
||||
|
||||
expect(action).not_to be_active_for(proposal)
|
||||
end
|
||||
|
||||
it 'is not active when not enough supports' do
|
||||
it "is not active when not enough supports" do
|
||||
action = build(:dashboard_action, required_supports: 10, day_offset: 0)
|
||||
proposal = build(:proposal, cached_votes_up: 9)
|
||||
|
||||
@@ -105,15 +105,15 @@ describe Dashboard::Action do
|
||||
end
|
||||
end
|
||||
|
||||
context '#requested_for?' do
|
||||
it 'is not requested when no administrator task' do
|
||||
context "#requested_for?" do
|
||||
it "is not requested when no administrator task" do
|
||||
proposal = create(:proposal)
|
||||
action = create(:dashboard_action, :active, :admin_request, :resource)
|
||||
|
||||
expect(action).not_to be_requested_for(proposal)
|
||||
end
|
||||
|
||||
it 'is requested when administrator task' do
|
||||
it "is requested when administrator task" do
|
||||
proposal = create(:proposal)
|
||||
action = create(:dashboard_action, :active, :admin_request, :resource)
|
||||
executed_action = create(:dashboard_executed_action, proposal: proposal, action: action)
|
||||
@@ -123,15 +123,15 @@ describe Dashboard::Action do
|
||||
end
|
||||
end
|
||||
|
||||
context '#executed_for?' do
|
||||
it 'is not executed when no administrator task' do
|
||||
context "#executed_for?" do
|
||||
it "is not executed when no administrator task" do
|
||||
proposal = create(:proposal)
|
||||
action = create(:dashboard_action, :active, :admin_request, :resource)
|
||||
|
||||
expect(action).not_to be_executed_for(proposal)
|
||||
end
|
||||
|
||||
it 'is not executed when pending administrator task' do
|
||||
it "is not executed when pending administrator task" do
|
||||
proposal = create(:proposal)
|
||||
action = create(:dashboard_action, :active, :admin_request, :resource)
|
||||
executed_action = create(:dashboard_executed_action, proposal: proposal, action: action)
|
||||
@@ -140,7 +140,7 @@ describe Dashboard::Action do
|
||||
expect(action).not_to be_executed_for(proposal)
|
||||
end
|
||||
|
||||
it 'is executed when done administrator task' do
|
||||
it "is executed when done administrator task" do
|
||||
proposal = create(:proposal)
|
||||
action = create(:dashboard_action, :active, :admin_request, :resource)
|
||||
executed_action = create(:dashboard_executed_action, proposal: proposal, action: action)
|
||||
@@ -150,12 +150,14 @@ describe Dashboard::Action do
|
||||
end
|
||||
end
|
||||
|
||||
context '#active_for' do
|
||||
context "#active_for" do
|
||||
let!(:active_action) { create :dashboard_action, :active, day_offset: 0, required_supports: 0 }
|
||||
let!(:not_enough_supports_action) { create :dashboard_action, :active, day_offset: 0, required_supports: 10_000 }
|
||||
let!(:not_enough_supports_action) { create :dashboard_action, :active, day_offset: 0,
|
||||
required_supports: 10_000 }
|
||||
let!(:inactive_action) { create :dashboard_action, :inactive }
|
||||
let!(:future_action) { create :dashboard_action, :active, day_offset: 300, required_supports: 0 }
|
||||
let!(:action_for_published_proposal) { create :dashboard_action,
|
||||
let!(:future_action) { create :dashboard_action, :active, day_offset: 300,
|
||||
required_supports: 0 }
|
||||
let!(:action_published_proposal) { create :dashboard_action,
|
||||
:active,
|
||||
day_offset: 0,
|
||||
required_supports: 0,
|
||||
@@ -185,11 +187,11 @@ describe Dashboard::Action do
|
||||
end
|
||||
|
||||
it "actions with published_proposal: true, are not included on draft proposal" do
|
||||
expect(described_class.active_for(draft_proposal)).not_to include(action_for_published_proposal)
|
||||
expect(described_class.active_for(draft_proposal)).not_to include(action_published_proposal)
|
||||
end
|
||||
|
||||
it "actions with published_proposal: true, are included on published proposal" do
|
||||
expect(described_class.active_for(proposal)).to include(action_for_published_proposal)
|
||||
expect(described_class.active_for(proposal)).to include(action_published_proposal)
|
||||
end
|
||||
|
||||
it "actions with published_proposal: false, are included on draft proposal" do
|
||||
@@ -201,9 +203,10 @@ describe Dashboard::Action do
|
||||
end
|
||||
end
|
||||
|
||||
context '#course_for' do
|
||||
context "#course_for" do
|
||||
let!(:proposed_action) { create :dashboard_action, :active, required_supports: 0 }
|
||||
let!(:inactive_resource) { create :dashboard_action, :inactive, :resource, required_supports: 0 }
|
||||
let!(:inactive_resource) { create :dashboard_action, :inactive, :resource,
|
||||
required_supports: 0 }
|
||||
let!(:resource) { create :dashboard_action, :active, :resource, required_supports: 10_000 }
|
||||
let!(:achieved_resource) { create :dashboard_action, :active, :resource, required_supports: 0 }
|
||||
let(:proposal) { create :proposal }
|
||||
|
||||