From c887cb73669c330b37d9246bcb612617cea8ea60 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 21 Sep 2017 17:35:21 +0200 Subject: [PATCH 01/26] improves html markup on communities and topics views --- app/views/communities/show.html.erb | 21 ++++---- app/views/topics/_comments.html.erb | 4 +- app/views/topics/_form.html.erb | 10 ++-- app/views/topics/_informative_text.html.erb | 10 ++-- app/views/topics/_recommendations.html.erb | 18 +++---- app/views/topics/_topic.html.erb | 12 +---- app/views/topics/edit.html.erb | 7 +-- app/views/topics/new.html.erb | 9 ++-- app/views/topics/show.html.erb | 58 ++++++++++++++------- 9 files changed, 77 insertions(+), 72 deletions(-) diff --git a/app/views/communities/show.html.erb b/app/views/communities/show.html.erb index 8190ff6b6..59fa73646 100644 --- a/app/views/communities/show.html.erb +++ b/app/views/communities/show.html.erb @@ -3,20 +3,21 @@
- <%= back_link_to community_back_link_path(@community) %> -

<%= community_text(@community) %>

-

<%= community_title(@community) %>

-

<%= community_description(@community) %>

+ <%= community_text(@community) %> +

<%= link_to community_title(@community), community_back_link_path(@community) %>

+
+ +
+

<%= community_description(@community) %>

- -
- <%= render 'participants' %> diff --git a/app/views/topics/_comments.html.erb b/app/views/topics/_comments.html.erb index 03568ed48..db22c8097 100644 --- a/app/views/topics/_comments.html.erb +++ b/app/views/topics/_comments.html.erb @@ -13,12 +13,12 @@ <% if user_signed_in? %> <%= render 'comments/form', {commentable: @topic, parent_id: nil, toggeable: false} %> <% else %> -
+
<%= t("topics.show.login_to_comment", signin: link_to(t("votes.signin"), new_user_session_path), signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %> -
+ <% end %> diff --git a/app/views/topics/_form.html.erb b/app/views/topics/_form.html.erb index b0f3dcd28..a03458216 100644 --- a/app/views/topics/_form.html.erb +++ b/app/views/topics/_form.html.erb @@ -3,19 +3,15 @@ <%= render 'shared/errors', resource: @topic %>
-
<%= f.label :title, t("community.topic.form.topic_title") %> <%= f.text_field :title, label: false %> -
-
+ <%= f.label :description, t("community.topic.form.topic_description") %> - <%= f.text_area :description, label: false %> -
-
+ <%= f.text_area :description, label: false, rows: "5" %> + <%= f.submit(class: "button", value: t("community.topic.form.#{action_name}.submit_button")) %>
-
<% end %> diff --git a/app/views/topics/_informative_text.html.erb b/app/views/topics/_informative_text.html.erb index aeb5ad773..6a8475d8f 100644 --- a/app/views/topics/_informative_text.html.erb +++ b/app/views/topics/_informative_text.html.erb @@ -1,11 +1,13 @@ -

<%= t("community.show.create_first_community_topic.first_theme") %>

+

<%= t("community.show.create_first_community_topic.first_theme") %>

<% if user_signed_in? %> - <%= t("community.show.create_first_community_topic.first_theme_not_logged_in") %> +
+ <%= t("community.show.create_first_community_topic.first_theme_not_logged_in") %> +
<% else %>
<%= t("community.show.create_first_community_topic.sub_first_theme", - link: link_to(t("community.show.create_first_community_topic.sign_link", - org_name: setting['org_name']), new_user_session_path)).html_safe %> + sign_in: link_to(t("community.show.create_first_community_topic.sign_in"), new_user_session_path), + sign_up: link_to(t("community.show.create_first_community_topic.sign_up"), new_user_registration_path)).html_safe %>
<% end %> diff --git a/app/views/topics/_recommendations.html.erb b/app/views/topics/_recommendations.html.erb index 022b7eb93..ff86b877b 100644 --- a/app/views/topics/_recommendations.html.erb +++ b/app/views/topics/_recommendations.html.erb @@ -1,13 +1,7 @@ -
+

<%= t("community.topic.sidebar.recommendations_title") %>

- - -

<%= t("community.topic.sidebar.recommendations_title") %>

- - - -
+ diff --git a/app/views/topics/_topic.html.erb b/app/views/topics/_topic.html.erb index fe225d501..4082bf3f7 100644 --- a/app/views/topics/_topic.html.erb +++ b/app/views/topics/_topic.html.erb @@ -1,6 +1,6 @@
- -
+ +

<%= link_to topic.title, community_topic_path(@community, topic) %>

@@ -14,12 +14,4 @@

- -
- <% if topic.author == current_user %> - <%= link_to t("community.show.topic.edit_button"), edit_community_topic_path(@community.id, topic), class: 'button small hollow' %> - <%= link_to t("community.show.topic.destroy_button"), community_topic_path(@community.id, topic), method: :delete, class: 'button hollow alert small' %> - <% end %> -
-
diff --git a/app/views/topics/edit.html.erb b/app/views/topics/edit.html.erb index 15c026ca8..e305acd13 100644 --- a/app/views/topics/edit.html.erb +++ b/app/views/topics/edit.html.erb @@ -1,4 +1,4 @@ -
+
<%= back_link_to community_path(@community) %> @@ -6,6 +6,7 @@ <%= render "form" %>
- <%= render "recommendations" %> - +
+ <%= render "recommendations" %> +
diff --git a/app/views/topics/new.html.erb b/app/views/topics/new.html.erb index c1f1c42da..8f9d541e2 100644 --- a/app/views/topics/new.html.erb +++ b/app/views/topics/new.html.erb @@ -1,11 +1,12 @@ -
- +
+
<%= back_link_to community_path(@community) %>

<%= t("community.topic.create") %>

<%= render 'form' %>
- <%= render "recommendations" %> - +
+ <%= render "recommendations" %> +
diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index 914839bdd..7640578e9 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -1,27 +1,47 @@ -
-
+
+
+
- <%= back_link_to community_path(@community) %> -
+ <%= back_link_to community_path(@community), t("community.show.back", + community: community_text(@community), + proposal: community_title(@community)) %> -

<%= community_text(@community) %> <%= community_title(@community) %>

-

<%= @topic.title %>

-
-

<%= @topic.description %>

- <%= render '/shared/author_info', resource: @topic %> +

<%= @topic.title %>

-  •  - <%= l @topic.created_at.to_date %> -  •  -   -
+
+ <%= render '/shared/author_info', resource: @topic %> -
- <%= render "topics/filter_subnav" %> -
- <%= render "topics/comments" %> +  •  + <%= l @topic.created_at.to_date %> +  •  +   + <%= link_to t("community.show.topic.comments", count: @topic.comments_count), + community_topic_path(@community, @topic, anchor: "comments") %>
+
+

<%= @topic.description %>

+
+ + <% if @topic.author == current_user %> + + <% end %> +
+ + +
+ <%= render "topics/filter_subnav" %> +
+ <%= render "topics/comments" %>
-
From 0fa59401e49784327503b730d6ed527bd8f67613 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 21 Sep 2017 17:39:32 +0200 Subject: [PATCH 02/26] improves i18n for community --- app/views/topics/_form.html.erb | 2 +- config/locales/en/community.yml | 18 ++++++++++-------- config/locales/es/community.yml | 18 ++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/app/views/topics/_form.html.erb b/app/views/topics/_form.html.erb index a03458216..0011df486 100644 --- a/app/views/topics/_form.html.erb +++ b/app/views/topics/_form.html.erb @@ -7,7 +7,7 @@ <%= f.label :title, t("community.topic.form.topic_title") %> <%= f.text_field :title, label: false %> - <%= f.label :description, t("community.topic.form.topic_description") %> + <%= f.label :description, t("community.topic.form.topic_text") %> <%= f.text_area :description, label: false, rows: "5" %> <%= f.submit(class: "button", value: t("community.topic.form.#{action_name}.submit_button")) %> diff --git a/config/locales/en/community.yml b/config/locales/en/community.yml index 068c98998..c4c679edb 100644 --- a/config/locales/en/community.yml +++ b/config/locales/en/community.yml @@ -14,29 +14,31 @@ en: proposal: Participate in the community of this proposal. An active community can help to improve the content of the proposal and boost its dissemination to get more support. investment: Participate in the community of this budget investment. An active community can help to improve the content of the budget investment and boost its dissemination to get more support. create_first_community_topic: - first_theme_not_logged_in: No issue yet available, participate creating the first one. Click on the create new topic button. + first_theme_not_logged_in: No issue available, participate creating the first one. first_theme: Create the first community topic - sub_first_theme: To create a theme you have to %{link} - sign_link: "access %{org_name}" + sub_first_theme: "To create a theme you must to %{sign_in} o %{sign_up}." + sign_in: "sign in" + sign_up: "sign up" tab: participants: Participants sidebar: participate: Participate new_topic: Create topic - disabled_info_title: You need to be logged to create a new topic topic: - edit_button: Edit - destroy_button: Destroy + edit: Edit topic + destroy: Destroy topic comments: one: 1 comment other: "%{count} comments" zero: No comments + author: Author + back: Back to %{community} %{proposal} topic: create: Create a topic edit: Edit Topic form: - topic_title: Topic Title - topic_description: Description + topic_title: Topic title + topic_text: Topic text new: submit_button: Create topic edit: diff --git a/config/locales/es/community.yml b/config/locales/es/community.yml index 8013c116c..f0f61b037 100644 --- a/config/locales/es/community.yml +++ b/config/locales/es/community.yml @@ -14,29 +14,31 @@ es: proposal: Participa en la comunidad de esta propuesta. Una comunidad activa puede ayudar a mejorar el contenido de la propuesta así como a dinamizar su difusión para conseguir más apoyos. investment: Participa en la comunidad de este proyecto de inversión. Una comunidad activa puede ayudar a mejorar el contenido del proyecto de inversión así como a dinamizar su difusión para conseguir más apoyos. create_first_community_topic: - first_theme_not_logged_in: Aún no hay ningun tema disponible, participa creando el primero. Haz click en el botón crear nuevo tema. + first_theme_not_logged_in: No hay ningún tema disponible, participa creando el primero. first_theme: Crea el primer tema de la comunidad - sub_first_theme: Para crear un tema tienes que %{link} - sign_link: "acceder a %{org_name}" + sub_first_theme: "Para crear un tema debes %{sign_in} o %{sign_up}." + sign_in: "iniciar sesión" + sign_up: "registrarte" tab: participants: Participantes sidebar: participate: Participa new_topic: Crea un tema - disabled_info_title: Necesitas estar logueado para crear un nuevo tema topic: - edit_button: Editar - destroy_button: Eliminar + edit: Editar tema + destroy: Eliminar tema comments: one: 1 Comentario other: "%{count} Comentarios" zero: Sin comentarios + author: Autor + back: Volver a %{community} %{proposal} topic: create: Crear un tema edit: Editar tema form: - topic_title: Titulo del tema - topic_description: Descripción + topic_title: Título del tema + topic_description: Texto del tema new: submit_button: Crear tema edit: From 363f2a59acc153df6511e7ea6fc907bcb7595fff Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 21 Sep 2017 17:39:55 +0200 Subject: [PATCH 03/26] improves styles for community --- app/assets/stylesheets/layout.scss | 6 +++++- app/assets/stylesheets/pages.scss | 3 +-- app/assets/stylesheets/participation.scss | 6 +----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 9ecf74442..ffcd1e7f9 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -278,7 +278,7 @@ a { .icon-angle-left { clear: both; color: $text-medium; - float: left; + display: inline-block; } .tabs-content { @@ -324,6 +324,10 @@ a { vertical-align: top; } +.uppercase { + text-transform: uppercase; +} + // 02. Header // ---------- diff --git a/app/assets/stylesheets/pages.scss b/app/assets/stylesheets/pages.scss index 7114b01d6..d3db7e9b2 100644 --- a/app/assets/stylesheets/pages.scss +++ b/app/assets/stylesheets/pages.scss @@ -44,8 +44,7 @@ // 03. Content // ---------------------- -.more-info-content, -.communities-show { +.more-info-content { h3 { color: $brand; diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 3d90ee128..8f85040fd 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -249,9 +249,7 @@ .proposal-form, .budget-investment-form, .spending-proposal-form, -.document-form, -.topic-new, -.topic-form { +.document-form { .icon-debates, .icon-proposals, @@ -300,8 +298,6 @@ } .proposal-form, -.topic-form, -.topic-new, .document-form { .recommendations li::before { From c400c83fa2d2812977238be698c48fdc5f1350f4 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 21 Sep 2017 17:41:35 +0200 Subject: [PATCH 04/26] removes unnecessary methods on topics helper --- app/helpers/topics_helper.rb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/helpers/topics_helper.rb b/app/helpers/topics_helper.rb index 1d5f1964f..488eed517 100644 --- a/app/helpers/topics_helper.rb +++ b/app/helpers/topics_helper.rb @@ -1,11 +1,2 @@ module TopicsHelper - - def disabled_create_topic - "disabled" unless current_user - end - - def disabled_info_title - t("community.show.sidebar.disabled_info_title") unless current_user - end - end From 2948251fc293fc69757911c88542929cc470cd3e Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 21 Sep 2017 18:31:30 +0200 Subject: [PATCH 05/26] updates specs --- spec/features/communities_spec.rb | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/spec/features/communities_spec.rb b/spec/features/communities_spec.rb index 2909f416e..7cd3d814c 100644 --- a/spec/features/communities_spec.rb +++ b/spec/features/communities_spec.rb @@ -27,15 +27,6 @@ feature 'Communities' do expect(page).not_to have_selector(".button.disabled", text: "Create topic") end - scenario 'Should display disabled create topic button when user is not logged' do - proposal = create(:proposal) - community = proposal.community - - visit community_path(community) - - expect(page).to have_selector(".button.disabled", text: "Create topic") - end - scenario 'Should display without_topics_text and participants when there are not topics' do proposal = create(:proposal) community = proposal.community @@ -100,7 +91,7 @@ feature 'Communities' do expect(topic2.title).to appear_before(topic1.title) end - scenario 'Should display topic edit button when author is logged' do + scenario 'Should display topic edit button on topic show when author is logged' do proposal = create(:proposal) community = proposal.community user = create(:user) @@ -108,15 +99,11 @@ feature 'Communities' do topic2 = create(:topic, community: community) login_as(user) - visit community_path(community) + visit community_topic_path(community, topic1) + expect(page).to have_link("Edit topic", href: edit_community_topic_path(community, topic1)) - within "#topic_#{topic1.id}" do - expect(page).to have_link("Edit", href: edit_community_topic_path(community, topic1)) - end - - within "#topic_#{topic2.id}" do - expect(page).not_to have_link("Edit", href: edit_community_topic_path(community, topic2)) - end + visit community_topic_path(community, topic2) + expect(page).not_to have_link("Edit topic", href: edit_community_topic_path(community, topic2)) end scenario 'Should display participant when there is topics' do From 864c022b081db9c17cc43601566e401d45882a57 Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 6 Dec 2017 15:37:46 +0100 Subject: [PATCH 06/26] adds margin to maps on show views --- app/views/budgets/investments/_investment_show.html.erb | 4 +++- app/views/proposals/show.html.erb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index eab4de525..5704ac1a7 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -46,7 +46,9 @@ <%= safe_html_with_links investment.description.html_safe %> <% if feature?(:map) && map_location_available?(@investment.map_location) %> - <%= render_map(@investment.map_location, "budget_investment", false, nil) %> +
+ <%= render_map(@investment.map_location, "budget_investment", false, nil) %> +
<% end %> <% if investment.external_url.present? %> diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index ade0972d8..13da25cfc 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -69,7 +69,9 @@ <%= safe_html_with_links @proposal.description %> <% if feature?(:map) && map_location_available?(@proposal.map_location) %> - <%= render_map(@proposal.map_location, "proposal", false, nil) %> +
+ <%= render_map(@proposal.map_location, "proposal", false, nil) %> +
<% end %> <% if @proposal.external_url.present? %> From 83c23c35c465445f516a8aea4c28c7c0cae4ac0a Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 6 Dec 2017 15:40:50 +0100 Subject: [PATCH 07/26] changes title text for public interests list --- config/locales/en/general.yml | 4 ++-- config/locales/es/general.yml | 4 ++-- spec/features/users_spec.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 6e87e6983..5c18a27f5 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -13,8 +13,8 @@ en: phone_number_label: Phone number public_activity_label: Keep my list of activities public public_interests_label: Keep my interests public - public_interests_my_title_list: List of interests (tags of elements you follow) - public_interests_user_title_list: List of interests (tags of elements this user follows) + public_interests_my_title_list: Tags of elements you follow + public_interests_user_title_list: Tags of elements this user follows public_interests_my_empty_list: You do not follow any elements yet. public_interests_user_empty_list: This user does not follow any elements yet. save_changes_submit: Save changes diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 0d0b4b849..46fd2df53 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -13,8 +13,8 @@ es: phone_number_label: Teléfono public_activity_label: Mostrar públicamente mi lista de actividades public_interests_label: Mostrar públicamente mis intereses - public_interests_my_title_list: Lista de intereses (etiquetas de los elementos que sigues) - public_interests_user_title_list: Lista de intereses (etiquetas de los elementos seguidos este usuario) + public_interests_my_title_list: Etiquetas de los elementos que sigues + public_interests_user_title_list: Etiquetas de los elementos que sigue este usuario public_interests_my_empty_list: Aún no sigues ningún elemento. public_interests_user_empty_list: Este usuario no sigue ningún elemento todavía. save_changes_submit: Guardar cambios diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index 5a73209df..c4f2eef58 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -314,7 +314,7 @@ feature 'Users' do @user.update(public_interests: true) visit user_path(@user) - expect(page).to have_content("List of interests (tags of elements this user follows)") + expect(page).to have_content("Tags of elements this user follows") end scenario 'Should display custom interests title when user is visiting own user page' do @@ -322,7 +322,7 @@ feature 'Users' do login_as(@user) visit user_path(@user) - expect(page).to have_content("List of interests (tags of elements you follow)") + expect(page).to have_content("Tags of elements you follow") end scenario 'Should display generic empty interests list message when visited user has not interests defined' do From cbaf1ae6c1b4b6598635d7126ecd15eac3ced671 Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 6 Dec 2017 20:44:43 +0100 Subject: [PATCH 08/26] adds setting to allow images for proposals and investment projects --- config/locales/en/settings.yml | 1 + config/locales/es/settings.yml | 1 + db/dev_seeds.rb | 1 + db/seeds.rb | 1 + 4 files changed, 4 insertions(+) diff --git a/config/locales/en/settings.yml b/config/locales/en/settings.yml index 2295660ac..86368c0e3 100644 --- a/config/locales/en/settings.yml +++ b/config/locales/en/settings.yml @@ -43,6 +43,7 @@ en: recommendations: Recommendeds community: Community on proposals and investments map: Proposals and budget investments geolocation + allow_images: Allow upload and show images map_latitude: Latitude map_longitude: Longitude map_zoom: Zoom diff --git a/config/locales/es/settings.yml b/config/locales/es/settings.yml index ae31d0a4a..421b1c0d4 100644 --- a/config/locales/es/settings.yml +++ b/config/locales/es/settings.yml @@ -43,6 +43,7 @@ es: recommendations: Recomendaciones community: Comunidad en propuestas y proyectos de inversión map: Geolocalización de propuestas y proyectos de inversión + allow_images: Permitir subir y mostrar imágenes map_latitude: Latitud map_longitude: Longitud map_zoom: Zoom diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index 8476f7693..027ea4991 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -50,6 +50,7 @@ section "Creating Settings" do Setting.create(key: 'feature.user.recommendations', value: "true") Setting.create(key: 'feature.community', value: "true") Setting.create(key: 'feature.map', value: "true") + Setting.create(key: 'feature.allow_images', value: "true") Setting.create(key: 'feature.public_stats', value: "true") Setting.create(key: 'per_page_code_head', value: "") Setting.create(key: 'per_page_code_body', value: "") diff --git a/db/seeds.rb b/db/seeds.rb index 6ef55067c..62c182b58 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -83,6 +83,7 @@ Setting['feature.legislation'] = true Setting['feature.user.recommendations'] = true Setting['feature.community'] = true Setting['feature.map'] = nil +Setting['feature.allow_images'] = true # Spending proposals feature flags Setting['feature.spending_proposal_features.voting_allowed'] = nil From 1d6877b797d60fb0a95fb15a3eb8116b4b2fe215 Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 6 Dec 2017 20:59:34 +0100 Subject: [PATCH 09/26] adds setting allow_images to specs --- spec/features/budgets/investments_spec.rb | 10 +++++++++- spec/features/proposals_spec.rb | 11 ++++++++++- spec/shared/features/nested_imageable.rb | 7 +++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index fa7749a4b..ed11c5138 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -9,6 +9,14 @@ feature 'Budget Investments' do let(:group) { create(:budget_group, name: "Health", budget: budget) } let!(:heading) { create(:budget_heading, name: "More hospitals", group: group) } + before do + Setting['feature.allow_images'] = true + end + + after do + Setting['feature.allow_images'] = nil + end + scenario 'Index' do investments = [create(:budget_investment, heading: heading), create(:budget_investment, heading: heading), @@ -37,7 +45,7 @@ feature 'Budget Investments' do visit budget_investments_path(budget, heading_id: heading.id) within("#budget_investment_#{investment.id}") do - expect(page).to have_css("div.no-image") + expect(page).to_not have_css("div.with-image") end within("#budget_investment_#{investment_with_image.id}") do expect(page).to have_css("img[alt='#{investment_with_image.image.title}']") diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 192e7949f..d5d3c84d0 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -4,6 +4,15 @@ require 'rails_helper' feature 'Proposals' do context 'Index' do + + before do + Setting['feature.allow_images'] = true + end + + after do + Setting['feature.allow_images'] = nil + end + scenario 'Lists featured and regular proposals' do featured_proposals = create_featured_proposals proposals = [create(:proposal), create(:proposal), create(:proposal)] @@ -55,7 +64,7 @@ feature 'Proposals' do visit proposals_path(proposal) within("#proposal_#{proposal.id}") do - expect(page).to have_css("div.no-image") + expect(page).to_not have_css("div.with-image") end within("#proposal_#{proposal_with_image.id}") do expect(page).to have_css("img[alt='#{proposal_with_image.image.title}']") diff --git a/spec/shared/features/nested_imageable.rb b/spec/shared/features/nested_imageable.rb index 947887afa..721c7e694 100644 --- a/spec/shared/features/nested_imageable.rb +++ b/spec/shared/features/nested_imageable.rb @@ -9,6 +9,9 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p let!(:imageable) { create(imageable_factory_name) } before do + + Setting['feature.allow_images'] = true + imageable_path_arguments&.each do |argument_name, path_to_value| arguments.merge!("#{argument_name}": imageable.send(path_to_value)) end @@ -16,6 +19,10 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p imageable.update(author: user) if imageable.respond_to?(:author) end + after do + Setting['feature.allow_images'] = nil + end + describe "at #{path}" do scenario "Should show new image link when imageable has not an associated image defined" do From 39def428b5d46bc05b377e5d2db09b771e6e79cb Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 6 Dec 2017 21:00:34 +0100 Subject: [PATCH 10/26] improves layout for items list with images --- app/assets/stylesheets/participation.scss | 29 ------------------- app/views/budgets/investments/_form.html.erb | 8 +++-- .../budgets/investments/_investment.html.erb | 28 +++++++++++------- app/views/polls/_poll_group.html.erb | 2 -- app/views/proposals/_form.html.erb | 8 +++-- app/views/proposals/_proposal.html.erb | 26 ++++++++++------- 6 files changed, 42 insertions(+), 59 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 848cd539a..5acfa53d0 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -655,29 +655,6 @@ .budget-investments-list .budget-investment, .proposals-list .proposal { - .no-image { - background: $brand; - } -} - -.budget-investments-list .budget-investment, -.proposals-list .proposal { - - @include breakpoint(small) { - - .no-image { - width: 100%; - max-width: rem-calc(300); - margin: 0 auto; - - &::before { - content: ''; - display: block; - padding-top: 100%; - } - } - } - @include breakpoint(medium) { .panel { @@ -685,12 +662,6 @@ &.with-image { padding: 0 $line-height / 2 0 0; } - - .no-image { - height: 100%; - min-height: rem-calc(245); - width: rem-calc(140); - } } .column:first-child { diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb index b3bbf4e14..fffafcb0d 100644 --- a/app/views/budgets/investments/_form.html.erb +++ b/app/views/budgets/investments/_form.html.erb @@ -21,9 +21,11 @@ <%= f.text_field :external_url %>
-
- <%= render 'images/nested_image', imageable: @investment, f: f %> -
+ <% if feature?(:allow_images) %> +
+ <%= render 'images/nested_image', imageable: @investment, f: f %> +
+ <% end %>
<%= render 'documents/nested_documents', documentable: @investment, f: f %> diff --git a/app/views/budgets/investments/_investment.html.erb b/app/views/budgets/investments/_investment.html.erb index ecfdcb3c7..7b37a9ceb 100644 --- a/app/views/budgets/investments/_investment.html.erb +++ b/app/views/budgets/investments/_investment.html.erb @@ -1,18 +1,20 @@
-
+
+ + <% if feature?(:allow_images) && investment.image.present? %>
- <% if investment.image.present? %> - <%= image_tag investment.image_url(:thumb), alt: investment.image.title %> - <% else %> -
- <% end %> + <%= image_tag investment.image_url(:thumb), alt: investment.image.title %>
+ <% else %> +
+
+ <% end %>
<% cache [locale_and_user_status(investment), 'index', investment, investment.author] do %> @@ -55,7 +57,8 @@ <% if investment.should_show_votes? %>
+ class="small-12 medium-3 column text-center" + <%= 'data-equalizer-watch' if feature?(:allow_images) && investment.image.present? %>> <%= render partial: '/budgets/investments/votes', locals: { investment: investment, investment_votes: investment_votes, @@ -64,7 +67,8 @@
<% elsif investment.should_show_vote_count? %>
+ class="small-12 medium-3 column text-center" + <%= 'data-equalizer-watch' if feature?(:allow_images) && investment.image.present? %>>
<%= t("budgets.investments.investment.supports", @@ -74,7 +78,8 @@
<% elsif investment.should_show_ballots? %>
+ class="small-12 medium-3 column text-center" + <%= 'data-equalizer-watch' if feature?(:allow_images) && investment.image.present? %>> <%= render partial: '/budgets/investments/ballot', locals: { investment: investment, investment_ids: investment_ids, @@ -83,13 +88,14 @@
<% elsif investment.should_show_price? %>
+ class="supports small-12 medium-3 column text-center" + <%= 'data-equalizer-watch' if feature?(:allow_images) && investment.image.present? %>>

<%= investment.formatted_price %>

<% else %> -
+
>
<% end %> <% end %> diff --git a/app/views/polls/_poll_group.html.erb b/app/views/polls/_poll_group.html.erb index 93174e157..033aff23e 100644 --- a/app/views/polls/_poll_group.html.erb +++ b/app/views/polls/_poll_group.html.erb @@ -10,8 +10,6 @@
<% if poll.image.present? %> <%= image_tag poll.image_url(:large), alt: poll.image.title %> - <% else %> -
<% end %>
diff --git a/app/views/proposals/_form.html.erb b/app/views/proposals/_form.html.erb index 2390b62f6..6bf8c274a 100644 --- a/app/views/proposals/_form.html.erb +++ b/app/views/proposals/_form.html.erb @@ -46,9 +46,11 @@ <%= f.text_field :external_url, placeholder: t("proposals.form.proposal_external_url"), label: false %>
-
- <%= render 'images/nested_image', imageable: @proposal, f: f %> -
+ <% if feature?(:allow_images) %> +
+ <%= render 'images/nested_image', imageable: @proposal, f: f %> +
+ <% end %>
<%= render 'documents/nested_documents', documentable: @proposal, f: f %> diff --git a/app/views/proposals/_proposal.html.erb b/app/views/proposals/_proposal.html.erb index 2f5c22c3c..9473984bb 100644 --- a/app/views/proposals/_proposal.html.erb +++ b/app/views/proposals/_proposal.html.erb @@ -1,21 +1,23 @@
Proposal.votes_needed_for_success) %>" data-type="proposal"> -
+
-
-
-
- <% if proposal.image.present? %> + <% if feature?(:allow_images) && proposal.image.present? %> +
+ +
+
<%= image_tag proposal.image_url(:thumb), alt: proposal.image.title %> - <% else %> -
- <% end %> +
-
-
+
+ <% else %> +
+
+ <% end %>
<% cache [locale_and_user_status(proposal), 'index', proposal, proposal.author] do %>

<%= link_to proposal.title, namespaced_proposal_path(proposal) %>

@@ -60,7 +62,9 @@
-
+
> <% if proposal.successful? %>
From 04e9ef62302940f6289ffa3ab245f32b337d39cc Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 6 Dec 2017 21:05:35 +0100 Subject: [PATCH 11/26] fixes i18n for new topic form --- config/locales/en/community.yml | 4 ++-- config/locales/es/community.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/locales/en/community.yml b/config/locales/en/community.yml index a0a1e53ae..d7a892aa8 100644 --- a/config/locales/en/community.yml +++ b/config/locales/en/community.yml @@ -37,8 +37,8 @@ en: create: Create a topic edit: Edit Topic form: - topic_title: Topic title - topic_text: Topic text + topic_title: Title + topic_text: Initial text new: submit_button: Create topic edit: diff --git a/config/locales/es/community.yml b/config/locales/es/community.yml index ccb8f3cfa..f08a4918a 100644 --- a/config/locales/es/community.yml +++ b/config/locales/es/community.yml @@ -37,8 +37,8 @@ es: create: Crear un tema edit: Editar tema form: - topic_title: Título del tema - topic_description: Texto del tema + topic_title: Título + topic_text: Texto inicial new: submit_button: Crear tema edit: From e9ad4b49fbab77869c3595d96d23a82d307b8732 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 7 Dec 2017 11:12:46 +0100 Subject: [PATCH 12/26] improves styles for follow button --- .../investments/_investment_show.html.erb | 3 +++ app/views/follows/_follow_button.html.erb | 17 ++++++----------- app/views/proposals/show.html.erb | 3 +++ config/locales/en/general.yml | 1 + config/locales/es/general.yml | 1 + 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index 5704ac1a7..fc42e1a3a 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -131,6 +131,9 @@ } %> <% if current_user %> + + + <%= render 'follows/follow_button', follow: find_or_build_follow(current_user, investment) %> <% end %> diff --git a/app/views/follows/_follow_button.html.erb b/app/views/follows/_follow_button.html.erb index 547e880b9..1d32228ce 100644 --- a/app/views/follows/_follow_button.html.erb +++ b/app/views/follows/_follow_button.html.erb @@ -1,24 +1,19 @@ - +
- <% if follow.followable.followed_by?(current_user) %> - - <%= link_to t('shared.unfollow'), + <%= link_to t('shared.following'), follow_path(follow), method: :delete, remote: true, title: unfollow_text(follow.followable), - class: 'button hollow' %> + class: 'button expanded' %> <% else %> - - <%= link_to t('shared.follow'), + <%= link_to follow_text(follow.followable), follows_path(followable_id: follow.followable.id, followable_type: follow.followable.class.name), method: :post, remote: true, title: follow_text(follow.followable), - class: 'button hollow' %> - + class: 'button hollow expanded' %> <% end %> - - \ No newline at end of file +
diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index 13da25cfc..aa8b0aee3 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -182,6 +182,9 @@ } %> <% if current_user %> + + + <%= render 'follows/follow_button', follow: find_or_build_follow(current_user, @proposal) %> <% end %> diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 5c18a27f5..a654f0a2a 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -569,6 +569,7 @@ en: collective: Collective flag: Flag as inappropriate follow: "Follow" + following: "Following" follow_entity: "Follow %{entity}" followable: budget_investment: diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 46fd2df53..201f13443 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -566,6 +566,7 @@ es: collective: Colectivo flag: Denunciar como inapropiado follow: "Seguir" + following: "Siguiendo" follow_entity: "Seguir %{entity}" followable: budget_investment: From d273ba2ba5e2c9651e897a000784a221c3c3a0cb Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 7 Dec 2017 13:40:12 +0100 Subject: [PATCH 13/26] improves following page, shows public interest only in this view --- app/assets/stylesheets/layout.scss | 69 +++++++++++-------- app/helpers/followables_helper.rb | 2 +- .../users/_budget_investment_follow.html.erb | 3 + app/views/users/_following.html.erb | 49 +++++++------ app/views/users/_proposal_follow.html.erb | 6 ++ app/views/users/show.html.erb | 2 - 6 files changed, 72 insertions(+), 59 deletions(-) create mode 100644 app/views/users/_budget_investment_follow.html.erb create mode 100644 app/views/users/_proposal_follow.html.erb diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index a2ddea800..007b4939c 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -2043,36 +2043,6 @@ table { .activity { - .accordion li { - margin-bottom: $line-height / 2; - - .accordion-title { - border-bottom: 1px solid $border; - background: #f8f9fb; - font-size: $small-font-size; - padding: $line-height / 2; - } - - .accordion-content { - padding: 0; - } - } - - .accordion .title { - display: block; - line-height: $line-height; - } - - .accordion .icon { - font-size: rem-calc(20); - float: left; - margin-right: $line-height / 3; - - &.icon-debates { - margin-top: rem-calc(3); - } - } - .retired { text-decoration: line-through; } @@ -2082,6 +2052,45 @@ table { li { margin-right: $line-height / 4; + + span { + background: none; + border: 1px solid #ececec; + } + } +} + +.following { + + .follow-list { + list-style-type: circle; + padding: $line-height / 2; + + li { + margin-bottom: $line-height / 2; + margin-left: $line-height; + } + } + + h3 { + font-size: rem-calc(24); + margin-top: $line-height; + padding-left: rem-calc(30); + position: relative; + + span { + left: 0; + position: absolute; + top: 2px; + } + } + + .interests { + + @include breakpoint(medium) { + border-left: 1px solid #ececec; + padding-left: $line-height; + } } } diff --git a/app/helpers/followables_helper.rb b/app/helpers/followables_helper.rb index e63e2b1a5..f185ab25a 100644 --- a/app/helpers/followables_helper.rb +++ b/app/helpers/followables_helper.rb @@ -13,7 +13,7 @@ module FollowablesHelper def render_follow(follow) followable = follow.followable - partial = followable_class_name(followable) + partial = followable_class_name(followable) + "_follow" locals = {followable_class_name(followable).to_sym => followable} render partial, locals diff --git a/app/views/users/_budget_investment_follow.html.erb b/app/views/users/_budget_investment_follow.html.erb new file mode 100644 index 000000000..be6555ed7 --- /dev/null +++ b/app/views/users/_budget_investment_follow.html.erb @@ -0,0 +1,3 @@ +
  • + <%= link_to budget_investment.title, budget_investment_path(budget_investment.budget, budget_investment) %> +
  • diff --git a/app/views/users/_following.html.erb b/app/views/users/_following.html.erb index a5e78a3b6..1ee5c412a 100644 --- a/app/views/users/_following.html.erb +++ b/app/views/users/_following.html.erb @@ -1,30 +1,27 @@ -
      +
      +
      + - <% @follows.each do |followable_type, follows| %> + <% @follows.each do |followable_type, follows| %> -
    • +

      + + <%= followable_type_title(followable_type) %> +

      - - - - - - <%= followable_type_title(followable_type) %> - - + + <% end %> +
    • -
      - - - <% follows.each do |follow| %> - <%= render_follow(follow) %> - <% end %> - -
      -
      - - - - <% end %> - -
    +
    + <%= render 'interests', user: @user if valid_interests_access? %> +
    +
    diff --git a/app/views/users/_proposal_follow.html.erb b/app/views/users/_proposal_follow.html.erb new file mode 100644 index 000000000..1df5cfa72 --- /dev/null +++ b/app/views/users/_proposal_follow.html.erb @@ -0,0 +1,6 @@ +
  • + <%= link_to proposal.title, proposal, proposal.retired? ? { class: 'retired' } : {} %> + <% if proposal.retired? %> + <%= t('users.proposals.retired') %> + <% end %> +
  • diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 4e6b6f0e5..08e400bba 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -48,8 +48,6 @@
    <% end %> - <%= render 'interests', user: @user if valid_interests_access? %> -
    From 36c61643e53d05830a398ab4829c083e85fa8249 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 7 Dec 2017 13:48:02 +0100 Subject: [PATCH 14/26] removes unused keys --- config/locales/en/general.yml | 1 - config/locales/es/general.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index a654f0a2a..39cb7d919 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -614,7 +614,6 @@ en: target_blank_html: " (link opens in new window)" you_are_in: "You are in" unflag: Unflag - unfollow: "Unfollow" unfollow_entity: "Unfollow %{entity}" outline: budget: Participatory budget diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 201f13443..8b4821966 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -611,7 +611,6 @@ es: target_blank_html: " (se abre en ventana nueva)" you_are_in: "Estás en" unflag: Deshacer denuncia - unfollow: "Dejar de seguir" unfollow_entity: "Dejar de seguir %{entity}" outline: budget: Presupuestos participativos From 377a1d9f01da8c64e0006d6386011321cf1cda64 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 7 Dec 2017 16:31:05 +0100 Subject: [PATCH 15/26] improves following view and updates specs --- app/helpers/users_helper.rb | 8 -- app/views/users/_interests.html.erb | 8 -- app/views/users/show.html.erb | 8 +- config/locales/en/general.yml | 2 - config/locales/es/general.yml | 2 - spec/features/users_spec.rb | 126 ++++++++-------------------- 6 files changed, 43 insertions(+), 111 deletions(-) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index da340bb46..980dd1e39 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -64,12 +64,4 @@ module UsersHelper end end - def empty_interests_message_text(user) - if current_user == user - t('account.show.public_interests_my_empty_list') - else - t('account.show.public_interests_user_empty_list') - end - end - end diff --git a/app/views/users/_interests.html.erb b/app/views/users/_interests.html.erb index a0d110346..3b830e1ac 100644 --- a/app/views/users/_interests.html.erb +++ b/app/views/users/_interests.html.erb @@ -2,18 +2,10 @@

    <%= interests_title_text(user) %>

    <% if user.interests.any? %> -
      <% user.interests.each do |interest| %>
    • <%= interest %>
    • <% end %>
    - - <% else %> - -
    - <%= empty_interests_message_text(user) %> -
    - <% end %>
    diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 08e400bba..a4f739a28 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -38,16 +38,20 @@ <% end %> <% end %> <% end %> - <%= t("users.show.no_activity") if @activity_counts.values.inject(&:+) == 0 %> + <% if @activity_counts.values.inject(&:+) == 0 %> +
    + <%= t("users.show.no_activity") %> +
    + <% end %> + <%= render "activity_page" %> <% else %>
    <%= t('users.show.private_activity') %>
    <% end %> -
    diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 39cb7d919..982a40815 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -15,8 +15,6 @@ en: public_interests_label: Keep my interests public public_interests_my_title_list: Tags of elements you follow public_interests_user_title_list: Tags of elements this user follows - public_interests_my_empty_list: You do not follow any elements yet. - public_interests_user_empty_list: This user does not follow any elements yet. save_changes_submit: Save changes subscription_to_website_newsletter_label: Receive by email website relevant information email_on_direct_message_label: Receive emails about direct messages diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 8b4821966..b22423741 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -15,8 +15,6 @@ es: public_interests_label: Mostrar públicamente mis intereses public_interests_my_title_list: Etiquetas de los elementos que sigues public_interests_user_title_list: Etiquetas de los elementos que sigue este usuario - public_interests_my_empty_list: Aún no sigues ningún elemento. - public_interests_user_empty_list: Este usuario no sigue ningún elemento todavía. save_changes_submit: Guardar cambios subscription_to_website_newsletter_label: Recibir emails con información interesante sobre la web email_on_direct_message_label: Recibir emails con mensajes privados diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index c4f2eef58..0ca1f0266 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -259,6 +259,9 @@ feature 'Users' do end scenario 'User can display public page' do + proposal = create(:proposal, tag_list: "Sport") + create(:follow, :followed_proposal, followable: proposal, user: @user) + login_as(@user) visit account_path @@ -267,22 +270,29 @@ feature 'Users' do logout - visit user_path(@user) + visit user_path(@user, filter: 'follows', page: '1') + expect(page).to have_css('#public_interests') end scenario 'Is always visible for the owner' do + proposal = create(:proposal, tag_list: "Sport") + create(:follow, :followed_proposal, followable: proposal, user: @user) + login_as(@user) visit account_path uncheck 'account_public_interests' click_button 'Save changes' - visit user_path(@user) + visit user_path(@user, filter: 'follows', page: '1') expect(page).to have_css('#public_interests') end scenario 'Is always visible for admins' do + proposal = create(:proposal, tag_list: "Sport") + create(:follow, :followed_proposal, followable: proposal, user: @user) + login_as(@user) visit account_path @@ -292,11 +302,14 @@ feature 'Users' do logout login_as(create(:administrator).user) - visit user_path(@user) + visit user_path(@user, filter: 'follows', page: '1') expect(page).to have_css('#public_interests') end scenario 'Is always visible for moderators' do + proposal = create(:proposal, tag_list: "Sport") + create(:follow, :followed_proposal, followable: proposal, user: @user) + login_as(@user) visit account_path @@ -306,39 +319,30 @@ feature 'Users' do logout login_as(create(:moderator).user) - visit user_path(@user) + visit user_path(@user, filter: 'follows', page: '1') expect(page).to have_css('#public_interests') end scenario 'Should display generic interests title' do + proposal = create(:proposal, tag_list: "Sport") + create(:follow, :followed_proposal, followable: proposal, user: @user) + @user.update(public_interests: true) - visit user_path(@user) + visit user_path(@user, filter: 'follows', page: '1') expect(page).to have_content("Tags of elements this user follows") end scenario 'Should display custom interests title when user is visiting own user page' do + proposal = create(:proposal, tag_list: "Sport") + create(:follow, :followed_proposal, followable: proposal, user: @user) + @user.update(public_interests: true) login_as(@user) - visit user_path(@user) + visit user_path(@user, filter: 'follows', page: '1') expect(page).to have_content("Tags of elements you follow") end - - scenario 'Should display generic empty interests list message when visited user has not interests defined' do - @user.update(public_interests: true) - visit user_path(@user) - - expect(page).to have_content("This user does not follow any elements yet.") - end - - scenario 'Should display custom empty interests list message when user has not interests defined and user is visiting own user page' do - @user.update(public_interests: true) - login_as(@user) - visit user_path(@user) - - expect(page).to have_content("You do not follow any elements yet.") - end end feature 'Special comments' do @@ -418,22 +422,22 @@ feature 'Users' do expect(page).to have_content('1 Following') end - scenario 'Display accordion proposal tab when user is following one proposal at least' do + scenario 'Display proposal tab when user is following one proposal at least' do proposal = create(:proposal) create(:follow, followable: proposal, user: @user) visit user_path(@user, filter: "follows") - expect(page).to have_link('Citizen proposals', href: "#") + expect(page).to have_link('Citizen proposals', href: "#citizen_proposals") end - scenario 'Not display accordion proposal tab when user is not following any proposal' do + scenario 'Not display proposal tab when user is not following any proposal' do visit user_path(@user, filter: "follows") - expect(page).not_to have_link('Citizen proposals', href: "#") + expect(page).not_to have_link('Citizen proposals', href: "#citizen_proposals") end - scenario 'Display proposal with action buttons inside accordion proposal tab when current user is proposal author', :js do + scenario 'Display proposals with link to proposal' do proposal = create(:proposal, author: @user) create(:follow, followable: proposal, user: @user) login_as @user @@ -442,35 +446,7 @@ feature 'Users' do click_link 'Citizen proposals' expect(page).to have_content proposal.title - expect(page).to have_link "Send notification" - expect(page).to have_link "Retire" end - - scenario 'Display proposal with action buttons inside accordion proposal tab when there is no logged user', :js do - proposal = create(:proposal, author: @user) - create(:follow, followable: proposal, user: @user) - - visit user_path(@user, filter: "follows") - click_link 'Citizen proposals' - - expect(page).to have_content proposal.title - expect(page).not_to have_link "Send notification" - expect(page).not_to have_link "Retire" - end - - scenario 'Display proposal without action buttons inside accordion proposal tab when current user is not proposal author', :js do - proposal = create(:proposal) - create(:follow, followable: proposal, user: @user) - login_as @user - - visit user_path(@user, filter: "follows") - click_link 'Citizen proposals' - - expect(page).to have_content proposal.title - expect(page).not_to have_link "Send notification" - expect(page).not_to have_link "Retire" - end - end describe 'Budget Investments' do @@ -484,35 +460,22 @@ feature 'Users' do expect(page).to have_content('1 Following') end - scenario 'Display accordion budget investment tab when user is following one budget investment at least' do + scenario 'Display budget investment tab when user is following one budget investment at least' do budget_investment = create(:budget_investment) create(:follow, followable: budget_investment, user: @user) - visit user_path(@user, filter: "follow") + visit user_path(@user, filter: "follows") - expect(page).to have_link('Investments', href: "#") + expect(page).to have_link('Investments', href: "#investments") end - scenario 'Not display accordion budget investment tab when user is not following any budget investment' do - visit user_path(@user, filter: "follow") + scenario 'Not display budget investment tab when user is not following any budget investment' do + visit user_path(@user, filter: "follows") - expect(page).not_to have_link('Investments', href: "#") + expect(page).not_to have_link('Investments', href: "#investments") end - scenario 'Display budget investment with action buttons inside accordion budget investment tab when current user is a verified user and author', :js do - user = create(:user, :level_two) - budget_investment = create(:budget_investment, author: user) - create(:follow, followable: budget_investment, user: user) - login_as user - - visit user_path(user, filter: "follows") - click_link 'Investments' - - expect(page).to have_link budget_investment.title - expect(page).to have_link "Delete" - end - - scenario 'Display budget investment with action buttons inside accordion budget investment tab when there is no logged user', :js do + scenario 'Display budget investment with link to budget investment' do user = create(:user, :level_two) budget_investment = create(:budget_investment, author: user) create(:follow, followable: budget_investment, user: user) @@ -521,22 +484,7 @@ feature 'Users' do click_link 'Investments' expect(page).to have_link budget_investment.title - expect(page).not_to have_link "Delete" end - - scenario 'Display budget investment without action buttons inside accordion budget investment tab when current user is not budget investment author', :js do - user = create(:user, :level_two) - budget_investment = create(:budget_investment) - create(:follow, followable: budget_investment, user: user) - login_as user - - visit user_path(user, filter: "follows") - click_link 'Investments' - - expect(page).to have_link budget_investment.title - expect(page).not_to have_link "Delete" - end - end end From e4b20efd04c95b65935caea0c6d15c9a9bb5661a Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 13 Dec 2017 12:24:08 +0100 Subject: [PATCH 16/26] adds timestamps to polls --- db/migrate/20171212193323_add_timestamps_to_polls.rb | 5 +++++ db/schema.rb | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20171212193323_add_timestamps_to_polls.rb diff --git a/db/migrate/20171212193323_add_timestamps_to_polls.rb b/db/migrate/20171212193323_add_timestamps_to_polls.rb new file mode 100644 index 000000000..9c955b278 --- /dev/null +++ b/db/migrate/20171212193323_add_timestamps_to_polls.rb @@ -0,0 +1,5 @@ +class AddTimestampsToPolls < ActiveRecord::Migration + def change + add_timestamps :polls, null: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 4d426cf9e..b9bfe1c21 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171127230716) do +ActiveRecord::Schema.define(version: 20171212193323) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -798,6 +798,8 @@ ActiveRecord::Schema.define(version: 20171127230716) do t.datetime "hidden_at" t.boolean "results_enabled", default: false t.boolean "stats_enabled", default: false + t.datetime "created_at" + t.datetime "updated_at" end add_index "polls", ["starts_at", "ends_at"], name: "index_polls_on_starts_at_and_ends_at", using: :btree From 1c863d7d84cfc9fde311885929641fa161029004 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 13 Dec 2017 14:11:22 +0100 Subject: [PATCH 17/26] Use activerecord model name on followable specs --- spec/shared/features/followable.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/spec/shared/features/followable.rb b/spec/shared/features/followable.rb index fc42a3ce7..440ed125a 100644 --- a/spec/shared/features/followable.rb +++ b/spec/shared/features/followable.rb @@ -28,7 +28,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa visit send(followable_path, arguments) within "##{dom_id(followable)}" do - expect(page).to have_link("Follow") + expect(page).to have_link("Follow #{followable.model_name.human.downcase}") end end @@ -37,8 +37,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa login_as(user) visit send(followable_path, arguments) - - expect(page).to have_link("Follow") + expect(page).to have_link("Follow #{followable.model_name.human.downcase}") end scenario "Should display unfollow after user clicks on follow button", :js do @@ -47,7 +46,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa visit send(followable_path, arguments) within "##{dom_id(followable)}" do - click_link "Follow" + click_link("Follow #{followable.model_name.human.downcase}") expect(page).not_to have_link "Follow" expect(page).to have_link "Unfollow" @@ -60,7 +59,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa visit send(followable_path, arguments) within "##{dom_id(followable)}" do - click_link "Follow" + click_link("Follow #{followable.model_name.human.downcase}") end expect(page).to have_content strip_tags(t("shared.followable.#{followable_class_name}.create.notice_html")) @@ -83,10 +82,10 @@ shared_examples "followable" do |followable_class_name, followable_path, followa visit send(followable_path, arguments) within "##{dom_id(followable)}" do - click_link "Unfollow" + click_link("Unfollow #{followable.model_name.human.downcase}") expect(page).not_to have_link "Unfollow" - expect(page).to have_link "Follow" + expect(page).to have_link("Follow #{followable.model_name.human.downcase}") end end @@ -97,7 +96,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa visit send(followable_path, arguments) within "##{dom_id(followable)}" do - click_link "Unfollow" + click_link("Unfollow #{followable.model_name.human.downcase}") end expect(page).to have_content strip_tags(t("shared.followable.#{followable_class_name}.destroy.notice_html")) From f376707b2d8b276ea2e088c885b5500e166c77e7 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 13 Dec 2017 14:11:52 +0100 Subject: [PATCH 18/26] Fix style of method with parameters call using parenthesis --- spec/shared/features/followable.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/shared/features/followable.rb b/spec/shared/features/followable.rb index 440ed125a..55d47e53c 100644 --- a/spec/shared/features/followable.rb +++ b/spec/shared/features/followable.rb @@ -48,8 +48,8 @@ shared_examples "followable" do |followable_class_name, followable_path, followa within "##{dom_id(followable)}" do click_link("Follow #{followable.model_name.human.downcase}") - expect(page).not_to have_link "Follow" - expect(page).to have_link "Unfollow" + expect(page).not_to have_link("Follow") + expect(page).to have_link("Following") end end @@ -72,7 +72,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa visit send(followable_path, arguments) - expect(page).to have_link("Unfollow") + expect(page).to have_link("Following") end scenario "Should update follow button and show destroy notice after user clicks on unfollow button", :js do @@ -84,7 +84,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa within "##{dom_id(followable)}" do click_link("Unfollow #{followable.model_name.human.downcase}") - expect(page).not_to have_link "Unfollow" + expect(page).not_to have_link("Unfollow") expect(page).to have_link("Follow #{followable.model_name.human.downcase}") end end From 8bfaee72676300fe3b7413163c10c38c5db5198f Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 13 Dec 2017 14:21:20 +0100 Subject: [PATCH 19/26] Fix missing parenthesis on i18n.l method call --- app/views/topics/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index 7640578e9..30e6ad44a 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -12,7 +12,7 @@ <%= render '/shared/author_info', resource: @topic %>  •  - <%= l @topic.created_at.to_date %> + <%= l(@topic.created_at.to_date) %>  •    <%= link_to t("community.show.topic.comments", count: @topic.comments_count), From 34f07bcc824e220bf73d75a72b0f42ee1fcdd05f Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 13 Dec 2017 14:30:43 +0100 Subject: [PATCH 20/26] Add feature allow_images flag to installation specs --- spec/controllers/installation_controller_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/controllers/installation_controller_spec.rb b/spec/controllers/installation_controller_spec.rb index 68c2e7c07..cf3d1ac47 100644 --- a/spec/controllers/installation_controller_spec.rb +++ b/spec/controllers/installation_controller_spec.rb @@ -18,7 +18,8 @@ describe InstallationController, type: :request do 'user.recommendations' => nil, 'community' => nil, 'map' => 't', - 'spending_proposal_features.voting_allowed' => 't' + 'spending_proposal_features.voting_allowed' => 't', + 'allow_images' => 't' } end @@ -41,6 +42,7 @@ describe InstallationController, type: :request do Setting['feature.community'] = true Setting['feature.map'] = nil Setting['feature.spending_proposal_features.voting_allowed'] = nil + Setting['feature.allow_images'] = true end specify "with query string inside query params" do From 8c9585480bcca6a8647f3cdfc64a4d351343e91c Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 13 Dec 2017 14:40:38 +0100 Subject: [PATCH 21/26] Remove no longer needed topics helper module file --- app/helpers/topics_helper.rb | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 app/helpers/topics_helper.rb diff --git a/app/helpers/topics_helper.rb b/app/helpers/topics_helper.rb deleted file mode 100644 index 488eed517..000000000 --- a/app/helpers/topics_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module TopicsHelper -end From a6a71c996a55a76ced1c3982479f431877a343e3 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 13 Dec 2017 19:39:54 +0100 Subject: [PATCH 22/26] adds rake task to initialise all polls' timestamps --- lib/tasks/polls.rake | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 lib/tasks/polls.rake diff --git a/lib/tasks/polls.rake b/lib/tasks/polls.rake new file mode 100644 index 000000000..cf10afffd --- /dev/null +++ b/lib/tasks/polls.rake @@ -0,0 +1,6 @@ +namespace :polls do + desc "Adds created_at and updated_at values to existing polls" + task initialize_timestamps: :environment do + Poll.update_all(created_at: Time.current, updated_at: Time.current) + end +end From 831ca1dd6740c22b92ca6720ecf4bc520c3dc422 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Dec 2017 13:50:42 +0100 Subject: [PATCH 23/26] Redirect anonymous user to sign in on create topic link --- app/helpers/communities_helper.rb | 3 +++ app/views/communities/show.html.erb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/helpers/communities_helper.rb b/app/helpers/communities_helper.rb index 22bc76617..744749a68 100644 --- a/app/helpers/communities_helper.rb +++ b/app/helpers/communities_helper.rb @@ -32,4 +32,7 @@ module CommunitiesHelper community.from_proposal? ? t("community.sidebar.description.proposal") : t("community.sidebar.description.investment") end + def create_topic_link(community) + current_user.present? ? new_community_topic_path(community.id) : new_user_session_path + end end diff --git a/app/views/communities/show.html.erb b/app/views/communities/show.html.erb index 59fa73646..4da0369b9 100644 --- a/app/views/communities/show.html.erb +++ b/app/views/communities/show.html.erb @@ -17,7 +17,7 @@
    @@ -30,7 +30,7 @@
    From a71ad644c52ce1784f6227c75f7949a0b18f5b23 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Dec 2017 13:51:10 +0100 Subject: [PATCH 24/26] Fix community topics specs --- spec/features/communities_spec.rb | 1 - spec/features/topics_specs.rb | 15 +++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/spec/features/communities_spec.rb b/spec/features/communities_spec.rb index 7cd3d814c..725364074 100644 --- a/spec/features/communities_spec.rb +++ b/spec/features/communities_spec.rb @@ -24,7 +24,6 @@ feature 'Communities' do expect(page).to have_content proposal.title expect(page).to have_content "Participate in the community of this proposal" expect(page).to have_link("Create topic", href: new_community_topic_path(community)) - expect(page).not_to have_selector(".button.disabled", text: "Create topic") end scenario 'Should display without_topics_text and participants when there are not topics' do diff --git a/spec/features/topics_specs.rb b/spec/features/topics_specs.rb index 0ba674844..a4c8c8ff9 100644 --- a/spec/features/topics_specs.rb +++ b/spec/features/topics_specs.rb @@ -4,13 +4,16 @@ feature 'Topics' do context 'New' do - scenario 'Should display disabled button to new topic page without user logged', :js do + scenario 'Create new topic link should redirect to sign up for anonymous users', :js do proposal = create(:proposal) community = proposal.community + logout visit community_path(community) + click_link "Create topic" - expect(page).to have_selector(".button.expanded.disabled") + expect(page).to have_content "Sign in with:" + expect(current_path).to eq(new_user_session_path) end scenario 'Can access to new topic page with user logged', :js do @@ -34,8 +37,8 @@ feature 'Topics' do click_link "Create topic" - expect(page).to have_content "Topic Title" - expect(page).to have_content "Description" + expect(page).to have_content "Title" + expect(page).to have_content "Initial text" expect(page).to have_content "Recommendations to create a topic" expect(page).to have_content "Do not write the topic title or whole sentences in capital letters. On the internet that is considered shouting. And no one likes to be yelled at." expect(page).to have_content "Any topic or comment that implies an illegal action will be eliminated, also those that intend to sabotage the spaces of the subject, everything else is allowed." @@ -128,9 +131,9 @@ feature 'Topics' do user = create(:user) topic = create(:topic, community: community, author: user) login_as(user) - visit community_path(community) + visit community_topic_path(community, topic) - click_link "Destroy" + click_link "Destroy topic" expect(page).to have_content "Topic deleted successfully." expect(page).not_to have_content topic.title From 996199c92e7078b97229612a53d494d3f1d0f4bd Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Dec 2017 14:18:18 +0100 Subject: [PATCH 25/26] Update Changelog unreleased section --- CHANGELOG.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f39815c8..d9f4f81f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased](https://github.com/consul/consul/compare/v0.11...consul:master) +### Added +- Added Images to Budget Investment's Milestones https://github.com/consul/consul/pull/2186 +- New setting `feature.allow_images` to allow upload and show images for both (proposals and budget investment projects). Set it manually through console with `Setting['feature.allow_images'] = true` +- Related Content List https://github.com/consul/consul/pull/2184 + +### Changed +- Design improvements https://github.com/consul/consul/pull/2170 +- Adds timestamps to polls https://github.com/consul/consul/pull/2180 (Run `rake polls:initialize_timestamps` to initialize attributes created_at and updated_at with the current time for all existing polls, or manually through console set correct values) + +### Deprecated + +### Removed + +### Fixed +- Notifications for hidden resources https://github.com/consul/consul/pull/2172 + +### Security + ## [0.11.0](https://github.com/consul/consul/compare/v0.10...v0.11) - 2017-12-05 ### Added From 7399e5fab12fddcc39a787b0c4ccc52226ac7120 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Dec 2017 15:14:18 +0100 Subject: [PATCH 26/26] Update unreleased section of Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9f4f81f1..ffc2bd922 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - Design improvements https://github.com/consul/consul/pull/2170 - Adds timestamps to polls https://github.com/consul/consul/pull/2180 (Run `rake polls:initialize_timestamps` to initialize attributes created_at and updated_at with the current time for all existing polls, or manually through console set correct values) +- Improved Community design https://github.com/consul/consul/pull/1904 ### Deprecated