Merge pull request #855 from consul/districts-and-categories
Categories and Geozones
This commit is contained in:
BIN
app/assets/images/map.jpg
Normal file
BIN
app/assets/images/map.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 59 KiB |
@@ -623,19 +623,28 @@ footer {
|
||||
}
|
||||
}
|
||||
|
||||
.tag-cloud {
|
||||
.categories {
|
||||
|
||||
h3 {
|
||||
border-top: 2px solid $brand;
|
||||
a {
|
||||
background: $highlight;
|
||||
border-radius: rem-calc(6);
|
||||
display: inline-block;
|
||||
font-family: $font-family-sans-serif;
|
||||
font-size: rem-calc(16);
|
||||
margin: -1px 0 rem-calc(12);
|
||||
padding-top: $line-height/4;
|
||||
text-transform: uppercase;
|
||||
font-size: $small-font-size;
|
||||
margin-bottom: $line-height/3;
|
||||
padding: $line-height/4 $line-height/3;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
h3.sidebar-title {
|
||||
border-top: 2px solid $brand;
|
||||
display: inline-block;
|
||||
font-size: rem-calc(16);
|
||||
margin: -1px 0 rem-calc(12);
|
||||
padding-top: $line-height/4;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
// 05. Auth pages
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ img.left { display: none !important; }
|
||||
|
||||
li.name { display: none !important; }
|
||||
|
||||
li.kind { display: none !important; }
|
||||
|
||||
p.proposal-info span:nth-child(3) { display: none !important; }
|
||||
|
||||
.top-links { display: none !important; }
|
||||
|
||||
@@ -25,8 +25,8 @@ module CommentableActions
|
||||
|
||||
def new
|
||||
@resource = resource_model.new
|
||||
set_geozone
|
||||
set_resource_instance
|
||||
load_featured_tags
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -38,14 +38,14 @@ module CommentableActions
|
||||
redirect_path = url_for(controller: controller_name, action: :show, id: @resource.id)
|
||||
redirect_to redirect_path, notice: t("flash.actions.create.#{resource_name.underscore}")
|
||||
else
|
||||
load_featured_tags
|
||||
load_categories
|
||||
load_geozones
|
||||
set_resource_instance
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
load_featured_tags
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -53,12 +53,19 @@ module CommentableActions
|
||||
if resource.save_with_captcha
|
||||
redirect_to resource, notice: t("flash.actions.update.#{resource_name.underscore}")
|
||||
else
|
||||
load_featured_tags
|
||||
load_categories
|
||||
load_geozones
|
||||
set_resource_instance
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def map
|
||||
@resource = resource_model.new
|
||||
@tag_cloud = tag_cloud
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def track_event
|
||||
@@ -69,8 +76,16 @@ module CommentableActions
|
||||
resource_model.last_week.tag_counts.order("#{resource_name.pluralize}_count": :desc, name: :asc).limit(5)
|
||||
end
|
||||
|
||||
def load_featured_tags
|
||||
@featured_tags = ActsAsTaggableOn::Tag.where(featured: true)
|
||||
def load_geozones
|
||||
@geozones = Geozone.all.order(name: :asc)
|
||||
end
|
||||
|
||||
def set_geozone
|
||||
@resource.geozone = Geozone.find(params[resource_name.to_sym].try(:[], :geozone_id)) if params[resource_name.to_sym].try(:[], :geozone_id).present?
|
||||
end
|
||||
|
||||
def load_categories
|
||||
@categories = ActsAsTaggableOn::Tag.where("kind = 'category'").order(:name)
|
||||
end
|
||||
|
||||
def parse_tag_filter
|
||||
@@ -112,10 +127,6 @@ module CommentableActions
|
||||
end
|
||||
end
|
||||
|
||||
def method_name
|
||||
|
||||
end
|
||||
|
||||
def search_finish_date
|
||||
params[:advanced_search][:date_max].try(:to_date) || Date.today
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ class DebatesController < ApplicationController
|
||||
before_action :parse_advanced_search_terms, only: :index
|
||||
before_action :parse_tag_filter, only: :index
|
||||
before_action :set_search_order, only: :index
|
||||
before_action :authenticate_user!, except: [:index, :show]
|
||||
before_action :authenticate_user!, except: [:index, :show, :map]
|
||||
|
||||
feature_flag :debates
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ class Management::ProposalsController < Management::BaseController
|
||||
before_action :check_verified_user, except: :print
|
||||
before_action :set_proposal, only: [:vote, :show]
|
||||
before_action :parse_search_terms, only: :index
|
||||
before_action :load_categories, only: [:new, :edit]
|
||||
before_action :load_geozones, only: [:edit]
|
||||
|
||||
has_orders %w{confidence_score hot_score created_at most_commented random}, only: [:index, :print]
|
||||
has_orders %w{most_voted newest}, only: :show
|
||||
@@ -43,7 +45,7 @@ class Management::ProposalsController < Management::BaseController
|
||||
managed_user
|
||||
end
|
||||
|
||||
### Duplicated in application_controller. Move to a concenrn.
|
||||
### Duplicated in application_controller. Move to a concern.
|
||||
def set_proposal_votes(proposals)
|
||||
@proposal_votes = current_user ? current_user.proposal_votes(proposals) : {}
|
||||
end
|
||||
|
||||
@@ -6,7 +6,9 @@ class ProposalsController < ApplicationController
|
||||
before_action :parse_advanced_search_terms, only: :index
|
||||
before_action :parse_tag_filter, only: :index
|
||||
before_action :set_search_order, only: :index
|
||||
before_action :authenticate_user!, except: [:index, :show]
|
||||
before_action :load_categories, only: [:index, :new, :edit, :map]
|
||||
before_action :load_geozones, only: [:edit, :map]
|
||||
before_action :authenticate_user!, except: [:index, :show, :map]
|
||||
|
||||
has_orders %w{hot_score confidence_score created_at relevance}, only: :index
|
||||
has_orders %w{most_voted newest oldest}, only: :show
|
||||
@@ -35,7 +37,7 @@ class ProposalsController < ApplicationController
|
||||
private
|
||||
|
||||
def proposal_params
|
||||
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :captcha, :captcha_key)
|
||||
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :captcha, :captcha_key, :geozone_id)
|
||||
end
|
||||
|
||||
def resource_model
|
||||
|
||||
@@ -3,8 +3,8 @@ module Abilities
|
||||
include CanCan::Ability
|
||||
|
||||
def initialize(user)
|
||||
can :read, Debate
|
||||
can :read, Proposal
|
||||
can [:read, :map], Debate
|
||||
can [:read, :map], Proposal
|
||||
can :read, Comment
|
||||
can :read, SpendingProposal
|
||||
can :read, Legislation
|
||||
|
||||
@@ -14,6 +14,7 @@ class Debate < ActiveRecord::Base
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
||||
belongs_to :geozone
|
||||
has_many :comments, as: :commentable
|
||||
|
||||
validates :title, presence: true
|
||||
|
||||
@@ -14,6 +14,7 @@ class Proposal < ActiveRecord::Base
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
||||
belongs_to :geozone
|
||||
has_many :comments, as: :commentable
|
||||
|
||||
validates :title, presence: true
|
||||
@@ -42,7 +43,7 @@ class Proposal < ActiveRecord::Base
|
||||
scope :sort_by_relevance , -> { all }
|
||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||
scope :last_week, -> { where("created_at >= ?", 7.days.ago)}
|
||||
|
||||
|
||||
pg_search_scope :pg_search, {
|
||||
against: {
|
||||
title: 'A',
|
||||
@@ -70,6 +71,7 @@ class Proposal < ActiveRecord::Base
|
||||
}
|
||||
tag_list.each{ |tag| values[tag] = 'D' }
|
||||
values[author.username] = 'D'
|
||||
values[geozone.name] = 'D' if geozone.present?
|
||||
values
|
||||
end
|
||||
|
||||
|
||||
@@ -15,14 +15,11 @@
|
||||
<div class="small-12 column">
|
||||
<%= f.label :tag_list, t("debates.form.tags_label") %>
|
||||
<p class="note"><%= t("debates.form.tags_instructions") %></p>
|
||||
<span class="tags">
|
||||
<% @featured_tags.each do |tag| %>
|
||||
<a class="js-add-tag-link"><%= tag.name %></a>
|
||||
<% end %>
|
||||
</span>
|
||||
<%= f.text_field :tag_list, value: @debate.tag_list.to_s, label: false, placeholder: t("debates.form.tags_placeholder"), class: 'js-tag-list' %>
|
||||
</div>
|
||||
|
||||
<%= f.text_field :tag_list, value: @debate.tag_list.to_s,
|
||||
label: false,
|
||||
placeholder: t("debates.form.tags_placeholder") %>
|
||||
</div>
|
||||
<div class="small-12 column">
|
||||
<% if @debate.new_record? %>
|
||||
<%= f.label :terms_of_service do %>
|
||||
@@ -44,6 +41,4 @@
|
||||
<%= f.submit(class: "button radius", value: t("debates.#{action_name}.form.submit_button")) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% end %>
|
||||
@@ -47,5 +47,6 @@
|
||||
<%= render "shared/tag_cloud", taggable: 'debate' %>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
1
app/views/debates/map.html.erb
Normal file
1
app/views/debates/map.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<%= render 'shared/map', new_url_path: new_debate_path %>
|
||||
9
app/views/proposals/_categories.html.erb
Normal file
9
app/views/proposals/_categories.html.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<div class="sidebar-divider"></div>
|
||||
<h3 class="sidebar-title"><%= t("shared.tags_cloud.categories") %></h3>
|
||||
<br>
|
||||
|
||||
<div id="categories" class="categories">
|
||||
<% @categories.each do |category| %>
|
||||
<%= link_to category.name, proposals_path(search: category.name) %>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -39,15 +39,27 @@
|
||||
<%= f.text_field :external_url, placeholder: t("proposals.form.proposal_external_url"), label: false %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= f.label :geozone_id, t("spending_proposals.form.geozone") %>
|
||||
<%= f.select :geozone_id, geozone_select_options, {include_blank: t("geozones.none"), label: false} %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.label :tag_list, t("proposals.form.tags_label") %>
|
||||
<p class="note"><%= t("proposals.form.tags_instructions") %></p>
|
||||
<span class="tags">
|
||||
<% @featured_tags.each do |tag| %>
|
||||
|
||||
<div id="category_tags" class="tags">
|
||||
<%= f.label :category_tag_list, t("proposals.form.tag_category_label") %>
|
||||
<% @categories.each do |tag| %>
|
||||
<a class="js-add-tag-link"><%= tag.name %></a>
|
||||
<% end %>
|
||||
</span>
|
||||
<%= f.text_field :tag_list, value: @proposal.tag_list.to_s, label: false, placeholder: t("proposals.form.tags_placeholder"), class: 'js-tag-list' %>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<%= f.text_field :tag_list, value: @proposal.tag_list.to_s,
|
||||
label: false,
|
||||
placeholder: t("proposals.form.tags_placeholder"),
|
||||
class: 'js-tag-list' %>
|
||||
</div>
|
||||
|
||||
<% if current_user.unverified? %>
|
||||
@@ -79,4 +91,4 @@
|
||||
<%= f.submit(class: "button radius", value: t("proposals.#{action_name}.form.submit_button")) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
6
app/views/proposals/_geozones.html.erb
Normal file
6
app/views/proposals/_geozones.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<div class="sidebar-divider"></div>
|
||||
<h3 class="sidebar-title"><%= t("shared.tags_cloud.districts") %></h3>
|
||||
<br>
|
||||
<%= link_to map_proposals_path, id: 'map' do %>
|
||||
<%= image_tag("map.jpg") %>
|
||||
<% end %>
|
||||
@@ -54,7 +54,10 @@
|
||||
<aside class="sidebar" role="complementary">
|
||||
<%= link_to t("proposals.index.start_proposal"), new_proposal_path, class: 'button radius expand' %>
|
||||
<%= render "shared/tag_cloud", taggable: 'proposal' %>
|
||||
<%= render 'categories' %>
|
||||
<%= render 'geozones' %>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
1
app/views/proposals/map.html.erb
Normal file
1
app/views/proposals/map.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<%= render 'shared/map', new_url_path: new_proposal_path %>
|
||||
@@ -64,6 +64,8 @@
|
||||
|
||||
<%= render 'shared/tags', taggable: @proposal %>
|
||||
|
||||
<%= render 'shared/geozone', geozonable: @proposal %>
|
||||
|
||||
<div class="js-moderator-proposal-actions margin">
|
||||
<%= render 'proposals/actions', proposal: @proposal %>
|
||||
</div>
|
||||
|
||||
3
app/views/shared/_geozone.html.erb
Normal file
3
app/views/shared/_geozone.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<span id="geozone">
|
||||
<%= geozone_name(geozonable) %>
|
||||
</span>
|
||||
52
app/views/shared/_map.html.erb
Normal file
52
app/views/shared/_map.html.erb
Normal file
@@ -0,0 +1,52 @@
|
||||
<div class="row">
|
||||
<div class="small-12 medium-9 column margin-top">
|
||||
|
||||
<h1><%= t("map.title") %></h1>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-3 column">
|
||||
<ul id="geozones" class="no-bullet">
|
||||
<% @geozones.each do |geozone| %>
|
||||
<li><%= link_to geozone.name, proposals_path(search: geozone.name) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="show-for-medium-up medium-9 column text-center">
|
||||
<%= image_tag("map.jpg", usemap: "#map") %>
|
||||
</div>
|
||||
|
||||
<map name="map" id="html_map">
|
||||
<% @geozones.each do |geozone| %>
|
||||
<area shape="poly"
|
||||
coords="<%= geozone.html_map_coordinates %>"
|
||||
href="<%= polymorphic_url(@resource, search: geozone.name) %>"
|
||||
title="<%= geozone.name %>"
|
||||
alt="<%= geozone.name %>">
|
||||
<% end %>
|
||||
</map>
|
||||
</div>
|
||||
|
||||
<h2><%= t("map.proposal_for_district") %></h2>
|
||||
|
||||
<%= form_for(@resource, url: new_url_path, method: :get ) do |f| %>
|
||||
<div class="small-12 medium-4">
|
||||
<%= f.label :geozone_id, t("map.select_district") %>
|
||||
<%= f.select :geozone_id, geozone_select_options,
|
||||
{include_blank: t("geozones.none"), label: false} %>
|
||||
</div>
|
||||
|
||||
<div class="actions small-12">
|
||||
<%= f.submit(class: "button radius", value: t("map.start_proposal")) %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-3 column">
|
||||
<aside class="sidebar" role="complementary">
|
||||
<%= link_to t("map.start_proposal"),
|
||||
new_proposal_path, class: 'button radius expand' %>
|
||||
<%= render "shared/tag_cloud", taggable: 'proposal' %>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,7 +1,8 @@
|
||||
<div id="tag-cloud" class="tag-cloud">
|
||||
<div class="sidebar-divider"></div>
|
||||
<h3><%= t("shared.tags_cloud.tags") %></h3>
|
||||
<h3 class="sidebar-title"><%= t("shared.tags_cloud.tags") %></h3>
|
||||
<br>
|
||||
|
||||
<% tag_cloud @tag_cloud, %w[s m l] do |tag, css_class| %>
|
||||
<%= link_to taggable_path(taggable, tag.name), class: css_class do %>
|
||||
<%= tag.name %>
|
||||
@@ -9,3 +10,4 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%- limit ||= nil %>
|
||||
|
||||
<% if taggable.tags.any? %>
|
||||
<span class='tags'>
|
||||
<span id="tags" class='tags'>
|
||||
<% taggable.tag_list_with_limit(limit).each do |tag| %>
|
||||
<%= link_to sanitize(tag.name), send("#{taggable.class.to_s.downcase.pluralize}_path", tag: tag.name) %>
|
||||
<% end %>
|
||||
|
||||
@@ -84,7 +84,7 @@ en:
|
||||
form:
|
||||
debate_text: Initial debate text
|
||||
debate_title: Debate title
|
||||
tags_instructions: Tag this debate. You can choose from our suggestions or enter your own.
|
||||
tags_instructions: Tag this debate.
|
||||
tags_label: Topics
|
||||
tags_placeholder: Enter the tags you would like to use, separated by commas (',')
|
||||
index:
|
||||
@@ -225,6 +225,11 @@ en:
|
||||
one: Someone replied to your comment on
|
||||
other: There are %{count} new replies to your comment on
|
||||
title: Notifications
|
||||
map:
|
||||
title: "Districts"
|
||||
proposal_for_district: "Start a proposal for your district"
|
||||
select_district: Scope of operation
|
||||
start_proposal: Create a proposal
|
||||
omniauth:
|
||||
facebook:
|
||||
sign_in: Sign in with Facebook
|
||||
@@ -259,7 +264,8 @@ en:
|
||||
proposal_title: Proposal title
|
||||
proposal_video_url: Link to external video
|
||||
proposal_video_url_note: You may add a link to YouTube or Vimeo
|
||||
tags_instructions: Tag this proposal. You can choose from our tags or add your own.
|
||||
tag_category_label: "Categories"
|
||||
tags_instructions: "Tag this proposal. You can choose from proposed categories or add your own"
|
||||
tags_label: Tags
|
||||
tags_placeholder: Enter the tags you would like to use, separated by commas (',')
|
||||
index:
|
||||
@@ -360,6 +366,8 @@ en:
|
||||
print_button: Print this info
|
||||
tags_cloud:
|
||||
tags: Trending
|
||||
districts: "Districts"
|
||||
categories: "Categories"
|
||||
unflag: Unflag
|
||||
simple_captcha:
|
||||
label: Enter the text from the image in the box below
|
||||
|
||||
@@ -84,7 +84,7 @@ es:
|
||||
form:
|
||||
debate_text: Texto inicial del debate
|
||||
debate_title: Título del debate
|
||||
tags_instructions: Etiqueta este debate. Puedes elegir entre nuestras propuestas o introducir las que desees.
|
||||
tags_instructions: Etiqueta este debate.
|
||||
tags_label: Temas
|
||||
tags_placeholder: "Escribe las etiquetas que desees separadas por coma (',')"
|
||||
index:
|
||||
@@ -225,6 +225,11 @@ es:
|
||||
one: Hay una respuesta nueva a tu comentario en
|
||||
other: Hay %{count} nuevas respuestas a tu comentario en
|
||||
title: Notificaciones
|
||||
map:
|
||||
title: "Distritos"
|
||||
proposal_for_district: "Crea una propuesta para tu distrito"
|
||||
select_district: "Ámbito de actuación"
|
||||
start_proposal: Crea una propuesta
|
||||
omniauth:
|
||||
facebook:
|
||||
sign_in: Entra con Facebook
|
||||
@@ -259,8 +264,9 @@ es:
|
||||
proposal_title: Título de la propuesta
|
||||
proposal_video_url: Enlace a vídeo externo
|
||||
proposal_video_url_note: Puedes añadir un enlace a YouTube o Vimeo
|
||||
tags_instructions: Etiqueta esta propuesta. Puedes elegir entre nuestras sugerencias o introducir las que desees.
|
||||
tags_instructions: "Etiqueta esta propuesta. Puedes elegir entre las categorías propuestas o introducir las que desees"
|
||||
tags_label: Temas
|
||||
tag_category_label: "Categorías"
|
||||
tags_placeholder: "Escribe las etiquetas que desees separadas por una coma (',')"
|
||||
index:
|
||||
featured_proposals: Destacadas
|
||||
@@ -360,6 +366,8 @@ es:
|
||||
print_button: Imprimir esta información
|
||||
tags_cloud:
|
||||
tags: Tendencias
|
||||
districts: "Distritos"
|
||||
categories: "Categorías"
|
||||
unflag: Deshacer denuncia
|
||||
simple_captcha:
|
||||
label: Introduce el texto de la imagen en la siguiente caja
|
||||
|
||||
@@ -27,10 +27,6 @@ Rails.application.routes.draw do
|
||||
patch :do_finish_signup, to: 'users/registrations#do_finish_signup'
|
||||
end
|
||||
|
||||
# The priority is based upon order of creation: first created -> highest priority.
|
||||
# See how all your routes lay out with "rake routes".
|
||||
|
||||
# You can have the root of your site routed with "root"
|
||||
root 'welcome#index'
|
||||
get '/welcome', to: 'welcome#welcome'
|
||||
get '/highlights', to: 'welcome#highlights', as: :highlights
|
||||
@@ -42,6 +38,10 @@ Rails.application.routes.draw do
|
||||
put :flag
|
||||
put :unflag
|
||||
end
|
||||
|
||||
collection do
|
||||
get :map
|
||||
end
|
||||
end
|
||||
|
||||
resources :proposals do
|
||||
@@ -51,6 +51,10 @@ Rails.application.routes.draw do
|
||||
put :flag
|
||||
put :unflag
|
||||
end
|
||||
|
||||
collection do
|
||||
get :map
|
||||
end
|
||||
end
|
||||
|
||||
resources :comments, only: [:create, :show], shallow: true do
|
||||
@@ -229,55 +233,6 @@ Rails.application.routes.draw do
|
||||
resources :spending_proposals, only: [:new, :create, :show]
|
||||
end
|
||||
|
||||
# Example of regular route:
|
||||
# get 'products/:id' => 'catalog#view'
|
||||
|
||||
# Example of named route that can be invoked with purchase_url(id: product.id)
|
||||
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
||||
|
||||
# Example resource route (maps HTTP verbs to controller actions automatically):
|
||||
# resources :products
|
||||
|
||||
# Example resource route with options:
|
||||
# resources :products do
|
||||
# member do
|
||||
# get 'short'
|
||||
# post 'toggle'
|
||||
# end
|
||||
#
|
||||
# collection do
|
||||
# get 'sold'
|
||||
# end
|
||||
# end
|
||||
|
||||
# Example resource route with sub-resources:
|
||||
# resources :products do
|
||||
# resources :comments, :sales
|
||||
# resource :seller
|
||||
# end
|
||||
|
||||
# Example resource route with more complex sub-resources:
|
||||
# resources :products do
|
||||
# resources :comments
|
||||
# resources :sales do
|
||||
# get 'recent', on: :collection
|
||||
# end
|
||||
# end
|
||||
|
||||
# Example resource route with concerns:
|
||||
# concern :toggleable do
|
||||
# post 'toggle'
|
||||
# end
|
||||
# resources :posts, concerns: :toggleable
|
||||
# resources :photos, concerns: :toggleable
|
||||
|
||||
# Example resource route within a namespace:
|
||||
# namespace :admin do
|
||||
# # Directs /admin/products/* to Admin::ProductsController
|
||||
# # (app/controllers/admin/products_controller.rb)
|
||||
# resources :products
|
||||
# end
|
||||
|
||||
if Rails.env.development?
|
||||
mount LetterOpenerWeb::Engine, at: "/letter_opener"
|
||||
end
|
||||
@@ -285,7 +240,6 @@ Rails.application.routes.draw do
|
||||
mount Tolk::Engine => '/translate', :as => 'tolk'
|
||||
|
||||
# static pages
|
||||
|
||||
get '/blog' => redirect("http://diario.madrid.es/participa/")
|
||||
resources :pages, path: '/', only: [:show]
|
||||
end
|
||||
end
|
||||
@@ -71,11 +71,27 @@ end
|
||||
org_user_ids = User.organizations.pluck(:id)
|
||||
not_org_users = User.where(['users.id NOT IN(?)', org_user_ids])
|
||||
|
||||
puts "Creating Tags Categories"
|
||||
|
||||
ActsAsTaggableOn::Tag.create!(name: "Asociaciones", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Cultura", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Deportes", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Derechos Sociales", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Economía", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Empleo", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Equidad", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Sostenibilidad", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Participación", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Movilidad", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Medios", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Salud", featured: true , kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Transparencia", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Seguridad y Emergencias", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Medio Ambiente", featured: true, kind: "category")
|
||||
|
||||
puts "Creating Debates"
|
||||
|
||||
tags = Faker::Lorem.words(25)
|
||||
|
||||
(1..30).each do |i|
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
@@ -84,14 +100,30 @@ tags = Faker::Lorem.words(25)
|
||||
created_at: rand((Time.now - 1.week) .. Time.now),
|
||||
description: description,
|
||||
tag_list: tags.sample(3).join(','),
|
||||
geozone: Geozone.reorder("RANDOM()").first,
|
||||
terms_of_service: "1")
|
||||
puts " #{debate.title}"
|
||||
end
|
||||
|
||||
|
||||
tags = ActsAsTaggableOn::Tag.where(kind: 'category')
|
||||
(1..30).each do |i|
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
debate = Debate.create!(author: author,
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
created_at: rand((Time.now - 1.week) .. Time.now),
|
||||
description: description,
|
||||
tag_list: tags.sample(3).join(','),
|
||||
geozone: Geozone.reorder("RANDOM()").first,
|
||||
terms_of_service: "1")
|
||||
puts " #{debate.title}"
|
||||
end
|
||||
|
||||
|
||||
puts "Creating Proposals"
|
||||
|
||||
tags = Faker::Lorem.words(25)
|
||||
|
||||
(1..30).each do |i|
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
@@ -104,6 +136,26 @@ tags = Faker::Lorem.words(25)
|
||||
description: description,
|
||||
created_at: rand((Time.now - 1.week) .. Time.now),
|
||||
tag_list: tags.sample(3).join(','),
|
||||
geozone: Geozone.reorder("RANDOM()").first,
|
||||
terms_of_service: "1")
|
||||
puts " #{proposal.title}"
|
||||
end
|
||||
|
||||
|
||||
tags = ActsAsTaggableOn::Tag.where(kind: 'category')
|
||||
(1..30).each do |i|
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
proposal = Proposal.create!(author: author,
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
question: Faker::Lorem.sentence(3),
|
||||
summary: Faker::Lorem.sentence(3),
|
||||
responsible_name: Faker::Name.name,
|
||||
external_url: Faker::Internet.url,
|
||||
description: description,
|
||||
created_at: rand((Time.now - 1.week) .. Time.now),
|
||||
tag_list: tags.sample(3).join(','),
|
||||
geozone: Geozone.reorder("RANDOM()").first,
|
||||
terms_of_service: "1")
|
||||
puts " #{proposal.title}"
|
||||
end
|
||||
@@ -232,4 +284,4 @@ puts "Confirming hiding in debates, comments & proposals"
|
||||
|
||||
Comment.only_hidden.flagged.reorder("RANDOM()").limit(10).each(&:confirm_hide)
|
||||
Debate.only_hidden.flagged.reorder("RANDOM()").limit(5).each(&:confirm_hide)
|
||||
Proposal.only_hidden.flagged.reorder("RANDOM()").limit(5).each(&:confirm_hide)
|
||||
Proposal.only_hidden.flagged.reorder("RANDOM()").limit(5).each(&:confirm_hide)
|
||||
5
db/migrate/20160119132601_add_kind_to_tags.rb
Normal file
5
db/migrate/20160119132601_add_kind_to_tags.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddKindToTags < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :tags, :kind, :string
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddGeozoneToProposalsAndDebates < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :proposals, :geozone_id, :integer, default: nil
|
||||
add_index :proposals, :geozone_id
|
||||
|
||||
add_column :debates, :geozone_id, :integer, default: nil
|
||||
add_index :debates, :geozone_id
|
||||
end
|
||||
end
|
||||
@@ -118,6 +118,7 @@ ActiveRecord::Schema.define(version: 20160122153329) do
|
||||
t.integer "cached_votes_score", default: 0
|
||||
t.integer "hot_score", limit: 8, default: 0
|
||||
t.integer "confidence_score", default: 0
|
||||
t.integer "geozone_id"
|
||||
end
|
||||
|
||||
add_index "debates", ["author_id", "hidden_at"], name: "index_debates_on_author_id_and_hidden_at", using: :btree
|
||||
@@ -127,6 +128,7 @@ ActiveRecord::Schema.define(version: 20160122153329) do
|
||||
add_index "debates", ["cached_votes_total"], name: "index_debates_on_cached_votes_total", using: :btree
|
||||
add_index "debates", ["cached_votes_up"], name: "index_debates_on_cached_votes_up", using: :btree
|
||||
add_index "debates", ["confidence_score"], name: "index_debates_on_confidence_score", using: :btree
|
||||
add_index "debates", ["geozone_id"], name: "index_debates_on_geozone_id", using: :btree
|
||||
add_index "debates", ["hidden_at"], name: "index_debates_on_hidden_at", using: :btree
|
||||
add_index "debates", ["hot_score"], name: "index_debates_on_hot_score", using: :btree
|
||||
add_index "debates", ["title"], name: "index_debates_on_title", using: :btree
|
||||
@@ -199,7 +201,7 @@ ActiveRecord::Schema.define(version: 20160122153329) do
|
||||
create_table "locks", force: :cascade do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "tries", default: 0
|
||||
t.datetime "locked_until", default: '2000-01-01 00:01:01', null: false
|
||||
t.datetime "locked_until", default: '2000-01-01 07:01:01', null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
@@ -252,12 +254,14 @@ ActiveRecord::Schema.define(version: 20160122153329) do
|
||||
t.string "video_url"
|
||||
t.integer "physical_votes", default: 0
|
||||
t.tsvector "tsv"
|
||||
t.integer "geozone_id"
|
||||
end
|
||||
|
||||
add_index "proposals", ["author_id", "hidden_at"], name: "index_proposals_on_author_id_and_hidden_at", using: :btree
|
||||
add_index "proposals", ["author_id"], name: "index_proposals_on_author_id", using: :btree
|
||||
add_index "proposals", ["cached_votes_up"], name: "index_proposals_on_cached_votes_up", using: :btree
|
||||
add_index "proposals", ["confidence_score"], name: "index_proposals_on_confidence_score", using: :btree
|
||||
add_index "proposals", ["geozone_id"], name: "index_proposals_on_geozone_id", using: :btree
|
||||
add_index "proposals", ["hidden_at"], name: "index_proposals_on_hidden_at", using: :btree
|
||||
add_index "proposals", ["hot_score"], name: "index_proposals_on_hot_score", using: :btree
|
||||
add_index "proposals", ["question"], name: "index_proposals_on_question", using: :btree
|
||||
@@ -315,6 +319,7 @@ ActiveRecord::Schema.define(version: 20160122153329) do
|
||||
t.boolean "featured", default: false
|
||||
t.integer "debates_count", default: 0
|
||||
t.integer "proposals_count", default: 0
|
||||
t.string "kind"
|
||||
t.integer "spending_proposals_count", default: 0
|
||||
end
|
||||
|
||||
|
||||
@@ -106,27 +106,6 @@ feature 'Debates' do
|
||||
expect(page).to have_content "Debate created successfully."
|
||||
end
|
||||
|
||||
scenario 'Failed creation goes back to new showing featured tags' do
|
||||
featured_tag = create(:tag, :featured)
|
||||
tag = create(:tag)
|
||||
login_as(create(:user))
|
||||
|
||||
visit new_debate_path
|
||||
fill_in 'debate_title', with: ""
|
||||
fill_in 'debate_description', with: 'Very important issue...'
|
||||
fill_in 'debate_captcha', with: correct_captcha_text
|
||||
check 'debate_terms_of_service'
|
||||
|
||||
click_button "Start a debate"
|
||||
|
||||
expect(page).to_not have_content "Debate created successfully."
|
||||
expect(page).to have_content "error"
|
||||
within(".tags") do
|
||||
expect(page).to have_content featured_tag.name
|
||||
expect(page).to_not have_content tag.name
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Errors on create' do
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
@@ -204,27 +183,43 @@ feature 'Debates' do
|
||||
login_as(author)
|
||||
end
|
||||
|
||||
scenario 'using featured tags', :js do
|
||||
['Medio Ambiente', 'Ciencia'].each do |tag_name|
|
||||
create(:tag, :featured, name: tag_name)
|
||||
end
|
||||
pending 'Category tags', :js do
|
||||
education = create(:tag, name: 'Education', kind: 'category')
|
||||
health = create(:tag, name: 'Health', kind: 'category')
|
||||
|
||||
visit new_debate_path
|
||||
|
||||
fill_in 'debate_title', with: 'A test'
|
||||
fill_in_ckeditor 'debate_description', with: 'A test'
|
||||
fill_in 'debate_title', with: 'Testing auto link'
|
||||
fill_in 'debate_description', with: "<script>alert('hey')</script> <a href=\"javascript:alert('surprise!')\">click me<a/> http://example.org"
|
||||
fill_in 'debate_captcha', with: correct_captcha_text
|
||||
check 'debate_terms_of_service'
|
||||
|
||||
['Medio Ambiente', 'Ciencia'].each do |tag_name|
|
||||
find('.js-add-tag-link', text: tag_name).click
|
||||
end
|
||||
|
||||
find('.js-add-tag-link', text: 'Education').click
|
||||
click_button 'Start a debate'
|
||||
|
||||
expect(page).to have_content 'Debate created successfully.'
|
||||
['Medio Ambiente', 'Ciencia'].each do |tag_name|
|
||||
expect(page).to have_content tag_name
|
||||
|
||||
within "#tags" do
|
||||
expect(page).to have_content 'Education'
|
||||
expect(page).to_not have_content 'Health'
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Custom tags' do
|
||||
visit new_debate_path
|
||||
|
||||
fill_in 'debate_title', with: "Great title"
|
||||
fill_in 'debate_description', with: 'Very important issue...'
|
||||
fill_in 'debate_captcha', with: correct_captcha_text
|
||||
check 'debate_terms_of_service'
|
||||
|
||||
fill_in 'debate_tag_list', with: 'Refugees, Solidarity'
|
||||
click_button 'Start a debate'
|
||||
|
||||
expect(page).to have_content 'Debate created successfully.'
|
||||
within "#tags" do
|
||||
expect(page).to have_content 'Refugees'
|
||||
expect(page).to have_content 'Solidarity'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -323,27 +318,6 @@ feature 'Debates' do
|
||||
expect(page).to have_content "Debate updated successfully."
|
||||
end
|
||||
|
||||
scenario 'Failed update goes back to edit showing featured tags' do
|
||||
debate = create(:debate)
|
||||
featured_tag = create(:tag, :featured)
|
||||
tag = create(:tag)
|
||||
login_as(debate.author)
|
||||
|
||||
visit edit_debate_path(debate)
|
||||
expect(current_path).to eq(edit_debate_path(debate))
|
||||
|
||||
fill_in 'debate_title', with: ""
|
||||
fill_in 'debate_captcha', with: correct_captcha_text
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to_not have_content "Debate updated successfully."
|
||||
expect(page).to have_content "error"
|
||||
within(".tags") do
|
||||
expect(page).to have_content featured_tag.name
|
||||
expect(page).to_not have_content tag.name
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Limiting tags shown' do
|
||||
scenario 'Index page shows up to 5 tags per debate' do
|
||||
tag_list = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa"]
|
||||
@@ -890,4 +864,67 @@ feature 'Debates' do
|
||||
visit debate_path(debate)
|
||||
expect(page).to have_content('User deleted')
|
||||
end
|
||||
|
||||
context "Filter" do
|
||||
|
||||
pending "By category" do
|
||||
education = create(:tag, name: 'Education', kind: 'category')
|
||||
health = create(:tag, name: 'Health', kind: 'category')
|
||||
|
||||
debate1 = create(:debate, tag_list: education.name)
|
||||
debate2 = create(:debate, tag_list: health.name)
|
||||
|
||||
visit debates_path
|
||||
|
||||
within "#categories" do
|
||||
click_link "Education"
|
||||
end
|
||||
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 1)
|
||||
expect(page).to have_content(debate1.title)
|
||||
end
|
||||
end
|
||||
|
||||
context "By geozone" do
|
||||
|
||||
background do
|
||||
geozone1 = Geozone.create(name: "California")
|
||||
geozone2 = Geozone.create(name: "New York")
|
||||
|
||||
@debate1 = create(:debate, geozone: geozone1)
|
||||
@debate2 = create(:debate, geozone: geozone2)
|
||||
end
|
||||
|
||||
pending "From map" do
|
||||
visit debates_path
|
||||
|
||||
click_link "map"
|
||||
within("#html_map") do
|
||||
url = find("area[title='California']")[:href]
|
||||
visit url
|
||||
end
|
||||
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 1)
|
||||
expect(page).to have_content(@debate1.title)
|
||||
end
|
||||
end
|
||||
|
||||
pending "From geozone list" do
|
||||
visit debates_path
|
||||
|
||||
click_link "map"
|
||||
within("#geozones") do
|
||||
click_link "California"
|
||||
end
|
||||
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 1)
|
||||
expect(page).to have_content(@debate1.title)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -166,31 +166,6 @@ feature 'Proposals' do
|
||||
expect(page).to have_content "Proposal created successfully."
|
||||
end
|
||||
|
||||
scenario 'Failed creation goes back to new showing featured tags' do
|
||||
featured_tag = create(:tag, :featured)
|
||||
tag = create(:tag)
|
||||
login_as(create(:user))
|
||||
|
||||
visit new_proposal_path
|
||||
fill_in 'proposal_title', with: ""
|
||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
|
||||
fill_in 'proposal_summary', with: 'In summary, what we want is...'
|
||||
fill_in 'proposal_description', with: 'Very important issue...'
|
||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
click_button "Create proposal"
|
||||
|
||||
expect(page).to_not have_content "Proposal created successfully."
|
||||
expect(page).to have_content "error"
|
||||
within(".tags") do
|
||||
expect(page).to have_content featured_tag.name
|
||||
expect(page).to_not have_content tag.name
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Errors on create' do
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
@@ -271,42 +246,67 @@ feature 'Proposals' do
|
||||
expect(page.html).to_not include "<script>alert('hey')</script>"
|
||||
end
|
||||
|
||||
context 'Tagging proposals' do
|
||||
context 'Tagging' do
|
||||
let(:author) { create(:user) }
|
||||
|
||||
background do
|
||||
login_as(author)
|
||||
end
|
||||
|
||||
scenario 'using featured tags', :js do
|
||||
['Medio Ambiente', 'Ciencia'].each do |tag_name|
|
||||
create(:tag, :featured, name: tag_name)
|
||||
end
|
||||
scenario 'Category tags', :js do
|
||||
education = create(:tag, name: 'Education', kind: 'category')
|
||||
health = create(:tag, name: 'Health', kind: 'category')
|
||||
|
||||
visit new_proposal_path
|
||||
|
||||
fill_in 'proposal_title', with: 'A test with enough characters'
|
||||
fill_in 'proposal_title', with: 'Help refugees'
|
||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
|
||||
fill_in 'proposal_summary', with: 'In summary, what we want is...'
|
||||
fill_in_ckeditor 'proposal_description', with: 'A description with enough characters'
|
||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||
fill_in 'proposal_video_url', with: 'http://youtube.com'
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
['Medio Ambiente', 'Ciencia'].each do |tag_name|
|
||||
find('.js-add-tag-link', text: tag_name).click
|
||||
end
|
||||
|
||||
find('.js-add-tag-link', text: 'Education').click
|
||||
click_button 'Create proposal'
|
||||
|
||||
expect(page).to have_content 'Proposal created successfully.'
|
||||
['Medio Ambiente', 'Ciencia'].each do |tag_name|
|
||||
expect(page).to have_content tag_name
|
||||
|
||||
within "#tags" do
|
||||
expect(page).to have_content 'Education'
|
||||
expect(page).to_not have_content 'Health'
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Custom tags' do
|
||||
visit new_proposal_path
|
||||
|
||||
fill_in 'proposal_title', with: 'Help refugees'
|
||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
|
||||
fill_in 'proposal_summary', with: 'In summary, what we want is...'
|
||||
fill_in 'proposal_description', with: 'This is very important because...'
|
||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||
fill_in 'proposal_video_url', with: 'http://youtube.com'
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
fill_in 'proposal_tag_list', with: 'Refugees, Solidarity'
|
||||
click_button 'Create proposal'
|
||||
|
||||
expect(page).to have_content 'Proposal created successfully.'
|
||||
within "#tags" do
|
||||
expect(page).to have_content 'Refugees'
|
||||
expect(page).to have_content 'Solidarity'
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'using dangerous strings' do
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
|
||||
visit new_proposal_path
|
||||
|
||||
fill_in 'proposal_title', with: 'A test of dangerous strings'
|
||||
@@ -330,6 +330,61 @@ feature 'Proposals' do
|
||||
end
|
||||
end
|
||||
|
||||
context "Geozones" do
|
||||
|
||||
scenario "Default whole city" do
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
|
||||
visit new_proposal_path
|
||||
|
||||
fill_in 'proposal_title', with: 'Help refugees'
|
||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
|
||||
fill_in 'proposal_summary', with: 'In summary, what we want is...'
|
||||
fill_in 'proposal_description', with: 'This is very important because...'
|
||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||
fill_in 'proposal_video_url', with: 'http://youtube.com'
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
click_button 'Create proposal'
|
||||
|
||||
expect(page).to have_content 'Proposal created successfully.'
|
||||
within "#geozone" do
|
||||
expect(page).to have_content 'All city'
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Specific geozone" do
|
||||
geozone = create(:geozone, name: 'California')
|
||||
geozone = create(:geozone, name: 'New York')
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
|
||||
visit new_proposal_path
|
||||
|
||||
fill_in 'proposal_title', with: 'Help refugees'
|
||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
|
||||
fill_in 'proposal_summary', with: 'In summary, what we want is...'
|
||||
fill_in 'proposal_description', with: 'This is very important because...'
|
||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||
fill_in 'proposal_video_url', with: 'http://youtube.com'
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
select('California', from: 'proposal_geozone_id')
|
||||
click_button 'Create proposal'
|
||||
|
||||
expect(page).to have_content 'Proposal created successfully.'
|
||||
within "#geozone" do
|
||||
expect(page).to have_content 'California'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
scenario 'Update should not be posible if logged user is not the author' do
|
||||
proposal = create(:proposal)
|
||||
expect(proposal).to be_editable
|
||||
@@ -410,27 +465,6 @@ feature 'Proposals' do
|
||||
expect(page).to have_content "Proposal updated successfully."
|
||||
end
|
||||
|
||||
scenario 'Failed update goes back to edit showing featured tags' do
|
||||
proposal = create(:proposal)
|
||||
featured_tag = create(:tag, :featured)
|
||||
tag = create(:tag)
|
||||
login_as(proposal.author)
|
||||
|
||||
visit edit_proposal_path(proposal)
|
||||
expect(current_path).to eq(edit_proposal_path(proposal))
|
||||
|
||||
fill_in 'proposal_title', with: ""
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to_not have_content "Proposal updated successfully."
|
||||
expect(page).to have_content "error"
|
||||
within(".tags") do
|
||||
expect(page).to have_content featured_tag.name
|
||||
expect(page).to_not have_content tag.name
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Limiting tags shown' do
|
||||
scenario 'Index page shows up to 5 tags per proposal' do
|
||||
create_featured_proposals
|
||||
@@ -988,4 +1022,67 @@ feature 'Proposals' do
|
||||
visit proposals_path
|
||||
expect(page).to have_content('User deleted')
|
||||
end
|
||||
|
||||
context "Filter" do
|
||||
|
||||
scenario "By category" do
|
||||
education = create(:tag, name: 'Education', kind: 'category')
|
||||
health = create(:tag, name: 'Health', kind: 'category')
|
||||
|
||||
proposal1 = create(:proposal, tag_list: education.name)
|
||||
proposal2 = create(:proposal, tag_list: health.name)
|
||||
|
||||
visit proposals_path
|
||||
|
||||
within "#categories" do
|
||||
click_link "Education"
|
||||
end
|
||||
|
||||
within("#proposals") do
|
||||
expect(page).to have_css('.proposal', count: 1)
|
||||
expect(page).to have_content(proposal1.title)
|
||||
end
|
||||
end
|
||||
|
||||
context "By geozone" do
|
||||
|
||||
background do
|
||||
geozone1 = Geozone.create(name: "California")
|
||||
geozone2 = Geozone.create(name: "New York")
|
||||
|
||||
@proposal1 = create(:proposal, geozone: geozone1)
|
||||
@proposal2 = create(:proposal, geozone: geozone2)
|
||||
end
|
||||
|
||||
scenario "From map" do
|
||||
visit proposals_path
|
||||
|
||||
click_link "map"
|
||||
within("#html_map") do
|
||||
url = find("area[title='California']")[:href]
|
||||
visit url
|
||||
end
|
||||
|
||||
within("#proposals") do
|
||||
expect(page).to have_css('.proposal', count: 1)
|
||||
expect(page).to have_content(@proposal1.title)
|
||||
end
|
||||
end
|
||||
|
||||
scenario "From geozone list" do
|
||||
visit proposals_path
|
||||
|
||||
click_link "map"
|
||||
within("#geozones") do
|
||||
click_link "California"
|
||||
end
|
||||
|
||||
within("#proposals") do
|
||||
expect(page).to have_css('.proposal', count: 1)
|
||||
expect(page).to have_content(@proposal1.title)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -66,7 +66,4 @@ describe 'ActsAsTaggableOn' do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -455,6 +455,13 @@ describe Debate do
|
||||
expect(results).to eq([debate])
|
||||
end
|
||||
|
||||
xit "searches by geozone" do
|
||||
geozone = create(:geozone, name: 'California')
|
||||
debate = create(:debate, geozone: geozone)
|
||||
results = Debate.search('California')
|
||||
expect(results).to eq([debate])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "stemming" do
|
||||
|
||||
@@ -402,6 +402,13 @@ describe Proposal do
|
||||
expect(results).to eq([proposal])
|
||||
end
|
||||
|
||||
it "searches by geozone" do
|
||||
geozone = create(:geozone, name: 'California')
|
||||
proposal = create(:proposal, geozone: geozone)
|
||||
results = Proposal.search('California')
|
||||
expect(results).to eq([proposal])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "stemming" do
|
||||
|
||||
Reference in New Issue
Block a user