Merge pull request #3388 from consul/dashboard-polish

Refactor dashboard views
This commit is contained in:
Raimond Garcia
2019-03-26 12:21:18 +01:00
committed by GitHub
22 changed files with 147 additions and 184 deletions

View File

@@ -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

View File

@@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -52,10 +52,6 @@
} }
} }
.supports .counter-label {
display: block;
}
.counter-value { .counter-value {
font-size: rem-calc(20); font-size: rem-calc(20);
font-weight: bold; font-weight: bold;

View File

@@ -299,7 +299,7 @@
display: block; display: block;
width: 60px; width: 60px;
height: 60px; height: 60px;
background-image: url(quote-before.svg); background-image: url("quote_before_blue.png");
background-repeat: no-repeat; background-repeat: no-repeat;
} }
@@ -309,17 +309,16 @@
display: block; display: block;
width: 60px; width: 60px;
height: 60px; height: 60px;
background-image: url(quote-after.svg); background-image: url("quote_after_blue.png");
background-repeat: no-repeat; background-repeat: no-repeat;
} }
.icon-finger::before { .icon-finger::before {
content: ''; content: '';
background-size: cover; background-size: cover;
display: inline-block; display: inline-block;
width: 50px; width: 50px;
height: 50px; height: 50px;
background-image: url(finger.svg); background-image: url("finger.png");
background-repeat: no-repeat; background-repeat: no-repeat;
} }

View File

@@ -13,7 +13,7 @@ class Dashboard::Action < ActiveRecord::Base
acts_as_paranoid column: :hidden_at acts_as_paranoid column: :hidden_at
include ActsAsParanoidAliases 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 has_many :proposals, through: :executed_actions
enum action_type: [:proposed_action, :resource] enum action_type: [:proposed_action, :resource]
@@ -53,15 +53,15 @@ class Dashboard::Action < ActiveRecord::Base
def self.active_for(proposal) def self.active_for(proposal)
published_at = proposal.published_at&.to_date || Date.today published_at = proposal.published_at&.to_date || Date.today
active.where('required_supports <= ?', proposal.cached_votes_up) active.where("required_supports <= ?", proposal.cached_votes_up)
.where('day_offset <= ?', (Date.today - published_at).to_i) .where("day_offset <= ?", (Date.today - published_at).to_i)
.by_proposal(proposal) .by_proposal(proposal)
end end
def self.course_for(proposal) def self.course_for(proposal)
active active
.resources .resources
.where('required_supports > ?', proposal.cached_votes_up) .where("required_supports > ?", proposal.cached_votes_up)
.order(required_supports: :asc) .order(required_supports: :asc)
end end

View File

@@ -34,7 +34,7 @@
</div> </div>
<div class="row expanded margin-top"> <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") %> <%= 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> <p class="help-text"><%= t("admin.dashboard.actions.form.published_proposal_help_text") %></p>
</div> </div>

View File

@@ -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.day_offset") %></th>
<th class="text-center"><%= t("admin.dashboard.actions.index.required_supports") %></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-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> </tr>
</thead> </thead>

View File

@@ -20,28 +20,22 @@
<p class="inline"> <p class="inline">
<%= l(proposed_action.executed_actions.find_by(proposal: proposal).executed_at.to_date) %> <%= l(proposed_action.executed_actions.find_by(proposal: proposal).executed_at.to_date) %>
</p> </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 %> <% 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> </div>
</div> </div>

View File

@@ -5,10 +5,10 @@
<tbody> <tbody>
<tr> <tr>
<td style="background: #0300ff; padding: 50px; padding-top:40px; text-align: left;"> <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> <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;' %> <%= 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> <h2 style="color: #fff; font-size: 40px; line-height: 60px"><%= t("dashboard.mailer.forward.subtitle_html") %></h2>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@@ -2,10 +2,10 @@
<div class="row expanded"> <div class="row expanded">
<div class="small-12 medium-9 dashboard-mail-preview column dashboard-mail-preview"> <div class="small-12 medium-9 dashboard-mail-preview column dashboard-mail-preview">
<div class="mail-header text-left"> <div class="mail-header text-left">
<%= image_tag 'quote-before-white.png' %> <%= image_tag "quote_before_white.png" %>
<h1 class="inline"><%= proposal.title %></h1> <h1 class="inline"><%= proposal.title %></h1>
<%= image_tag 'quote-after-white.png' %> <%= image_tag "quote_after_white.png" %>
<h2><%= t("dashboard.mailer.forward.subtitle").html_safe %></h2> <h2><%= t("dashboard.mailer.forward.subtitle_html") %></h2>
</div> </div>
<div class="margin-bottom"> <div class="margin-bottom">

View File

@@ -9,7 +9,9 @@
<%= image_tag("finger.png") %> <%= image_tag("finger.png") %>
<%= t("dashboard.poster.index.poster_subtitle") %> <%= t("dashboard.poster.index.poster_subtitle") %>
</h1> </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"> <p class="text-center">
<strong><%= t("dashboard.poster.index.proposal_code", code: proposal.code) %></strong> <strong><%= t("dashboard.poster.index.proposal_code", code: proposal.code) %></strong>
@@ -23,11 +25,11 @@
</div> </div>
<div class="poster-content"> <div class="poster-content">
<h2><%= t("dashboard.poster.index.support") %></h2> <h2><%= t("dashboard.poster.index.support") %></h2>
<%= image_tag 'quote-before-blue.png' %> <%= image_tag "quote_before_blue.png" %>
<h3><%= proposal.title %></h3> <h3><%= proposal.title %></h3>
<%= image_tag 'quote-after-blue.png' %> <%= image_tag "quote_after_blue.png" %>
<p class="poster-footer"> <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> </p>
</div> </div>
</div> </div>

View File

@@ -16,7 +16,7 @@
</strong> </strong>
</h1> </h1>
<p class="intro"> <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>
<p class="text-center proposal-code"> <p class="text-center proposal-code">
<strong><%= t("dashboard.poster.index.proposal_code", code: proposal.code) %></strong> <strong><%= t("dashboard.poster.index.proposal_code", code: proposal.code) %></strong>
@@ -30,11 +30,11 @@
</div> </div>
<div class="poster-content"> <div class="poster-content">
<h2 class="text-center"><strong><%= t("dashboard.poster.index.support") %></strong></h2> <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> <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"> <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> </p>
</div> </div>
</div> </div>

View File

@@ -24,9 +24,13 @@
<div class="counter-value"> <div class="counter-value">
<%= number_with_delimiter(proposal.votes_for.size, delimiter: '.') %> <%= 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> </div>
<span class="counter-label"><%= t("layouts.dashboard.proposal_totals.current_goal") %></span>
</div> </div>
<div class="next-goal-progress"> <div class="next-goal-progress">
@@ -40,11 +44,7 @@
<div class="small-12 medium-6 large-4 column"> <div class="small-12 medium-6 large-4 column">
<div class="row"> <div class="row">
<div class="small-12 medium-12 column"> <div class="small-12 column">
</div>
<div class="small-12 medium-12 column">
<div class="proposal-link"> <div class="proposal-link">
<% if proposal.draft? %> <% if proposal.draft? %>
<%= link_to t('layouts.dashboard.proposal_totals.preview_proposal'), proposal_path(proposal), class: 'button success expanded', target: '_blank' %> <%= link_to t('layouts.dashboard.proposal_totals.preview_proposal'), proposal_path(proposal), class: 'button success expanded', target: '_blank' %>

View File

@@ -210,9 +210,10 @@ en:
show_proposal: Show proposal show_proposal: Show proposal
preview_proposal: Preview proposal preview_proposal: Preview proposal
current_goal: Current goal current_goal: Current goal
support_count: supports:
one: "%{count} support" zero: No supports
other: "%{count} supports" one: 1 Support
other: "Supports"
footer: footer:
accessibility: Accessibility accessibility: Accessibility
conditions: Terms and conditions of use conditions: Terms and conditions of use
@@ -575,12 +576,12 @@ en:
title: Poster preview title: Poster preview
poster_title: "Do not keep looking," poster_title: "Do not keep looking,"
poster_subtitle: "back me up! ;)" poster_subtitle: "back me up! ;)"
intro_text: 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 "<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. necessary support to make the city we all want."
proposal_code: "Code of the proposal: %{code}" proposal_code: "Code of the proposal: %{code}"
support: Support my proposal 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: new:
title: Poster feature title: Poster feature
options: options:
@@ -598,7 +599,7 @@ en:
sent: The email has been sent sent: The email has been sent
mailer: mailer:
forward: 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 support_button: Support this proposal
share_in: Share in share_in: Share in
hi: "Hello!" hi: "Hello!"

View File

@@ -210,9 +210,10 @@ es:
show_proposal: Ver propuesta show_proposal: Ver propuesta
preview_proposal: Previsualizar propuesta preview_proposal: Previsualizar propuesta
current_goal: Meta actual current_goal: Meta actual
support_count: supports:
one: "%{count} <span class='counter-label'>Apoyo</span>" zero: Sin apoyos
other: "%{count} <span class='counter-label'>Apoyos</span>" one: 1 Apoyo
other: "Apoyos"
footer: footer:
accessibility: Accesibilidad accessibility: Accesibilidad
conditions: Condiciones de uso conditions: Condiciones de uso
@@ -575,12 +576,12 @@ es:
title: Previsualización del poster title: Previsualización del poster
poster_title: "No te quedes mirando," poster_title: "No te quedes mirando,"
poster_subtitle: "¡apóyame! ;)" poster_subtitle: "¡apóyame! ;)"
intro_text: 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 "<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. apoyo necesario para hacer la ciudad que todos queremos."
proposal_code: "Código de la propuesta: %{code}" proposal_code: "Código de la propuesta: %{code}"
support: Apoya mi propuesta 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: new:
title: Funcionalidad de póster title: Funcionalidad de póster
options: options:
@@ -598,7 +599,7 @@ es:
sent: El e-mail ha sido enviado sent: El e-mail ha sido enviado
mailer: mailer:
forward: forward:
subtitle: Si me apoyas, <br>lo conseguiremos. subtitle_html: "Si me apoyas, <br>lo conseguiremos."
support_button: Apoyar esta propuesta support_button: Apoyar esta propuesta
share_in: Compartir en share_in: Compartir en
hi: "¡Hola!" hi: "¡Hola!"

View File

@@ -1,4 +1,4 @@
require 'rails_helper' require "rails_helper"
feature "Proposal's dashboard" do feature "Proposal's dashboard" do
let!(:proposal) { create(:proposal, :draft) } let!(:proposal) { create(:proposal, :draft) }
@@ -8,45 +8,47 @@ feature "Proposal's dashboard" do
visit proposal_dashboard_path(proposal) visit proposal_dashboard_path(proposal)
end end
scenario 'Dashboard has a link to my proposal' do scenario "Dashboard has a link to my proposal" do
expect(page).to have_link('My proposal') expect(page).to have_link("My proposal")
end end
scenario 'My proposal has a link to edit the proposal' do scenario "My proposal has a link to edit the proposal" do
expect(page).to have_link('Edit proposal') expect(page).to have_link("Edit proposal")
end end
scenario 'My proposal has a link to retire the proposal' do scenario "My proposal has a link to retire the proposal" do
expect(page).to have_link('Retire proposal') expect(page).to have_link("Retire proposal")
end end
scenario 'My proposal has a link to publish the proposal' do scenario "My proposal has a link to publish the proposal" do
expect(page).to have_link('Publish proposal') expect(page).to have_link("Publish proposal")
end end
scenario "Publish link dissapears after proposal's publication" do scenario "Publish link dissapears after proposal's publication" do
click_link 'Publish proposal' click_link "Publish proposal"
expect(page).not_to have_link('Publish proposal') expect(page).not_to have_link("Publish proposal")
end end
scenario 'Dashboard progress shows current goal', js: true do scenario "Dashboard progress shows current goal", js: true do
goal = create(:dashboard_action, :resource, :active, required_supports: proposal.votes_for.size + 1_000) goal = create(:dashboard_action, :resource, :active,
future_goal = create(:dashboard_action, :resource, :active, required_supports: proposal.votes_for.size + 2_000) 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) 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).to have_content(goal.title)
expect(page).not_to have_content(future_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(goal.title)
expect(page).to have_content(future_goal.title) expect(page).to have_content(future_goal.title)
end end
end end
scenario 'Dashboard progress show proposed actions' do scenario "Dashboard progress show proposed actions" do
action = create(:dashboard_action, :proposed_action, :active) action = create(:dashboard_action, :proposed_action, :active)
visit progress_proposal_dashboard_path(proposal) visit progress_proposal_dashboard_path(proposal)
@@ -110,8 +112,7 @@ feature "Proposal's dashboard" do
end end
end end
scenario "Dashboard progress display contains no results text when there are not scenario "Display no results text when there are not proposed_actions done" do
proposed_actions pending" do
visit progress_proposal_dashboard_path(proposal) visit progress_proposal_dashboard_path(proposal)
expect(page).to have_content("No recommended actions done") expect(page).to have_content("No recommended actions done")
@@ -241,36 +242,36 @@ feature "Proposal's dashboard" do
end end
end end
scenario 'Dashboard has a link to polls feature' do scenario "Dashboard has a link to polls feature" do
expect(page).to have_link('Polls') expect(page).to have_link("Polls")
end end
scenario 'Dashboard has a link to e-mail feature' do scenario "Dashboard has a link to e-mail feature" do
expect(page).to have_link('E-mail') expect(page).to have_link("E-mail")
end end
scenario 'Dashboard has a link to poster feature' do scenario "Dashboard has a link to poster feature" do
expect(page).to have_link('Poster') expect(page).to have_link("Poster")
end 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) feature = create(:dashboard_action, :resource, :active)
visit proposal_dashboard_path(proposal) visit proposal_dashboard_path(proposal)
expect(page).to have_link(feature.title) expect(page).to have_link(feature.title)
end 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) feature = create(:dashboard_action, :resource, :active, :admin_request)
visit proposal_dashboard_path(proposal) visit proposal_dashboard_path(proposal)
click_link(feature.title) click_link(feature.title)
click_button 'Request' click_button "Request"
expect(page).to have_content('The request for the administrator has been successfully sent.') expect(page).to have_content("The request for the administrator has been successfully sent.")
end 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) feature = create(:dashboard_action, :resource, :active, :admin_request)
visit proposal_dashboard_path(proposal) visit proposal_dashboard_path(proposal)
@@ -278,27 +279,27 @@ feature "Proposal's dashboard" do
create(:dashboard_executed_action, action: feature, proposal: proposal) create(:dashboard_executed_action, action: feature, proposal: proposal)
click_button 'Request' click_button "Request"
expect(page).to have_content('Proposal has already been taken') expect(page).to have_content("Proposal has already been taken")
end 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) feature = create(:dashboard_action, :resource, :active)
visit proposal_dashboard_path(proposal) visit proposal_dashboard_path(proposal)
click_link(feature.title) click_link(feature.title)
expect(page).not_to have_button('Request') expect(page).not_to have_button("Request")
end end
scenario 'Dashboard has a link to dashboard community', js: true do scenario "Dashboard has a link to dashboard community", js: true do
expect(page).to have_link('Community') expect(page).to have_link("Community")
click_link 'Community' click_link "Community"
expect(page).to have_content('Participants') expect(page).to have_content("Participants")
expect(page).to have_content('Debates') expect(page).to have_content("Debates")
expect(page).to have_content('Comments') expect(page).to have_content("Comments")
expect(page).to have_link('Access the community') expect(page).to have_link("Access the community")
end end
scenario "Dashboard has a link to recommended_actions", js: true do 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) expect(page).to have_content(action_5.title)
end 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) create_list(:dashboard_action, 4, :proposed_action, :active)
action_5 = create(:dashboard_action, :proposed_action, :active) action_5 = create(:dashboard_action, :proposed_action, :active)
@@ -359,7 +360,7 @@ feature "Proposal's dashboard" do
end end
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 not proposed_actions pending" do
visit recommended_actions_proposal_dashboard_path(proposal.to_param) visit recommended_actions_proposal_dashboard_path(proposal.to_param)

View File

@@ -16,88 +16,88 @@ describe Dashboard::Action do
let(:day_offset) { 0 } let(:day_offset) { 0 }
let(:required_supports) { 0 } let(:required_supports) { 0 }
let(:request_to_administrators) { true } let(:request_to_administrators) { true }
let(:action_type) { 'resource' } let(:action_type) { "resource" }
it 'is invalid when title is blank' do it "is invalid when title is blank" do
action = build(:dashboard_action, title: '') action = build(:dashboard_action, title: "")
expect(action).not_to be_valid expect(action).not_to be_valid
end end
it 'is invalid when title is too short' do it "is invalid when title is too short" do
action = build(:dashboard_action, title: 'abc') action = build(:dashboard_action, title: "abc")
expect(action).not_to be_valid expect(action).not_to be_valid
end end
it 'is invalid when title is too long' do it "is invalid when title is too long" do
action = build(:dashboard_action, title: 'a' * 81) action = build(:dashboard_action, title: "a" * 81)
expect(action).not_to be_valid expect(action).not_to be_valid
end 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) action = build(:dashboard_action, day_offset: nil)
expect(action).not_to be_valid expect(action).not_to be_valid
end 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) action = build(:dashboard_action, day_offset: -1)
expect(action).not_to be_valid expect(action).not_to be_valid
end 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) action = build(:dashboard_action, day_offset: 1.23)
expect(action).not_to be_valid expect(action).not_to be_valid
end 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) action = build(:dashboard_action, required_supports: nil)
expect(action).not_to be_valid expect(action).not_to be_valid
end 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) action = build(:dashboard_action, required_supports: -1)
expect(action).not_to be_valid expect(action).not_to be_valid
end 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) action = build(:dashboard_action, required_supports: 1.23)
expect(action).not_to be_valid expect(action).not_to be_valid
end 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) action = build(:dashboard_action, action_type: nil)
expect(action).not_to be_valid expect(action).not_to be_valid
end end
context '#active_for?' do context "#active_for?" do
it 'is active when required supports is 0 and day_offset is 0' 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) action = build(:dashboard_action, required_supports: 0, day_offset: 0)
proposal = build(:proposal) proposal = build(:proposal)
expect(action).to be_active_for(proposal) expect(action).to be_active_for(proposal)
end 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) action = build(:dashboard_action, required_supports: 0, day_offset: 10)
proposal = build(:proposal, published_at: Time.current - 10.days) proposal = build(:proposal, published_at: Time.current - 10.days)
expect(action).to be_active_for(proposal) expect(action).to be_active_for(proposal)
end 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) action = build(:dashboard_action, required_supports: 10, day_offset: 0)
proposal = build(:proposal, cached_votes_up: 10) proposal = build(:proposal, cached_votes_up: 10)
expect(action).to be_active_for(proposal) expect(action).to be_active_for(proposal)
end 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) action = build(:dashboard_action, required_supports: 0, day_offset: 10)
proposal = build(:proposal, published_at: Time.current - 9.days) proposal = build(:proposal, published_at: Time.current - 9.days)
expect(action).not_to be_active_for(proposal) expect(action).not_to be_active_for(proposal)
end 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) action = build(:dashboard_action, required_supports: 10, day_offset: 0)
proposal = build(:proposal, cached_votes_up: 9) proposal = build(:proposal, cached_votes_up: 9)
@@ -105,15 +105,15 @@ describe Dashboard::Action do
end end
end end
context '#requested_for?' do context "#requested_for?" do
it 'is not requested when no administrator task' do it "is not requested when no administrator task" do
proposal = create(:proposal) proposal = create(:proposal)
action = create(:dashboard_action, :active, :admin_request, :resource) action = create(:dashboard_action, :active, :admin_request, :resource)
expect(action).not_to be_requested_for(proposal) expect(action).not_to be_requested_for(proposal)
end end
it 'is requested when administrator task' do it "is requested when administrator task" do
proposal = create(:proposal) proposal = create(:proposal)
action = create(:dashboard_action, :active, :admin_request, :resource) action = create(:dashboard_action, :active, :admin_request, :resource)
executed_action = create(:dashboard_executed_action, proposal: proposal, action: action) executed_action = create(:dashboard_executed_action, proposal: proposal, action: action)
@@ -123,15 +123,15 @@ describe Dashboard::Action do
end end
end end
context '#executed_for?' do context "#executed_for?" do
it 'is not executed when no administrator task' do it "is not executed when no administrator task" do
proposal = create(:proposal) proposal = create(:proposal)
action = create(:dashboard_action, :active, :admin_request, :resource) action = create(:dashboard_action, :active, :admin_request, :resource)
expect(action).not_to be_executed_for(proposal) expect(action).not_to be_executed_for(proposal)
end end
it 'is not executed when pending administrator task' do it "is not executed when pending administrator task" do
proposal = create(:proposal) proposal = create(:proposal)
action = create(:dashboard_action, :active, :admin_request, :resource) action = create(:dashboard_action, :active, :admin_request, :resource)
executed_action = create(:dashboard_executed_action, proposal: proposal, action: action) 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) expect(action).not_to be_executed_for(proposal)
end end
it 'is executed when done administrator task' do it "is executed when done administrator task" do
proposal = create(:proposal) proposal = create(:proposal)
action = create(:dashboard_action, :active, :admin_request, :resource) action = create(:dashboard_action, :active, :admin_request, :resource)
executed_action = create(:dashboard_executed_action, proposal: proposal, action: action) executed_action = create(:dashboard_executed_action, proposal: proposal, action: action)
@@ -150,12 +150,14 @@ describe Dashboard::Action do
end end
end end
context '#active_for' do context "#active_for" do
let!(:active_action) { create :dashboard_action, :active, day_offset: 0, required_supports: 0 } 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!(:inactive_action) { create :dashboard_action, :inactive }
let!(:future_action) { create :dashboard_action, :active, day_offset: 300, required_supports: 0 } let!(:future_action) { create :dashboard_action, :active, day_offset: 300,
let!(:action_for_published_proposal) { create :dashboard_action, required_supports: 0 }
let!(:action_published_proposal) { create :dashboard_action,
:active, :active,
day_offset: 0, day_offset: 0,
required_supports: 0, required_supports: 0,
@@ -185,11 +187,11 @@ describe Dashboard::Action do
end end
it "actions with published_proposal: true, are not included on draft proposal" do 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 end
it "actions with published_proposal: true, are included on published proposal" do 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 end
it "actions with published_proposal: false, are included on draft proposal" do it "actions with published_proposal: false, are included on draft proposal" do
@@ -201,9 +203,10 @@ describe Dashboard::Action do
end end
end end
context '#course_for' do context "#course_for" do
let!(:proposed_action) { create :dashboard_action, :active, required_supports: 0 } 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!(:resource) { create :dashboard_action, :active, :resource, required_supports: 10_000 }
let!(:achieved_resource) { create :dashboard_action, :active, :resource, required_supports: 0 } let!(:achieved_resource) { create :dashboard_action, :active, :resource, required_supports: 0 }
let(:proposal) { create :proposal } let(:proposal) { create :proposal }