decidim-core 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/config/decidim_core_manifest.js +2 -0
- data/app/assets/javascripts/decidim/map.js.es6.erb +95 -0
- data/app/assets/stylesheets/decidim/map.css +3 -0
- data/app/assets/stylesheets/decidim/modules/_layout.scss +2 -4
- data/app/assets/stylesheets/decidim/modules/_margins.scss +3 -2
- data/app/assets/stylesheets/decidim/modules/_process-header.scss +15 -2
- data/app/assets/stylesheets/decidim/modules/_process-phase.scss +4 -1
- data/app/assets/stylesheets/decidim/utils/_settings.scss +3 -3
- data/app/commands/decidim/create_report.rb +90 -0
- data/app/controllers/concerns/decidim/devise_controllers.rb +26 -0
- data/app/controllers/concerns/decidim/payload_info.rb +23 -0
- data/app/controllers/concerns/decidim/user_profile.rb +2 -1
- data/app/controllers/decidim/application_controller.rb +25 -1
- data/app/controllers/decidim/authorizations_controller.rb +10 -2
- data/app/controllers/decidim/cookie_policy_controller.rb +5 -0
- data/app/controllers/decidim/devise/confirmations_controller.rb +1 -9
- data/app/controllers/decidim/devise/invitations_controller.rb +1 -9
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +1 -10
- data/app/controllers/decidim/devise/passwords_controller.rb +1 -9
- data/app/controllers/decidim/devise/registrations_controller.rb +2 -15
- data/app/controllers/decidim/devise/sessions_controller.rb +9 -15
- data/{lib → app/controllers}/decidim/features/base_controller.rb +5 -1
- data/app/controllers/decidim/participatory_process_groups_controller.rb +22 -0
- data/app/controllers/decidim/participatory_process_steps_controller.rb +2 -0
- data/app/controllers/decidim/participatory_processes_controller.rb +14 -3
- data/app/controllers/decidim/reports_controller.rb +33 -0
- data/app/controllers/decidim/static_map_controller.rb +18 -0
- data/app/forms/decidim/report_form.rb +12 -0
- data/app/helpers/decidim/application_helper.rb +0 -2
- data/app/helpers/decidim/feature_reference_helper.rb +22 -0
- data/app/helpers/decidim/map_helper.rb +41 -0
- data/app/helpers/decidim/organization_scopes_helper.rb +41 -0
- data/app/helpers/decidim/replace_buttons_helper.rb +42 -0
- data/app/helpers/decidim/resource_helper.rb +2 -1
- data/app/helpers/decidim/translations_helper.rb +1 -1
- data/app/mailers/decidim/reported_mailer.rb +35 -0
- data/app/middleware/decidim/current_organization.rb +29 -3
- data/app/models/decidim/abilities/everyone.rb +1 -0
- data/app/models/decidim/moderation.rb +13 -0
- data/app/models/decidim/newsletter.rb +1 -0
- data/app/models/decidim/organization.rb +2 -0
- data/app/models/decidim/participatory_process.rb +11 -0
- data/app/models/decidim/participatory_process_group.rb +15 -0
- data/app/models/decidim/participatory_process_step.rb +1 -1
- data/app/models/decidim/report.rb +23 -0
- data/app/services/decidim/public_processes.rb +42 -0
- data/app/services/decidim/resource_search.rb +17 -1
- data/app/services/decidim/static_map_generator.rb +49 -0
- data/app/uploaders/decidim/application_uploader.rb +4 -1
- data/app/uploaders/decidim/official_image_footer_uploader.rb +2 -2
- data/app/uploaders/decidim/official_image_header_uploader.rb +1 -1
- data/app/validators/geocoding_validator.rb +22 -0
- data/app/views/decidim/authorizations/new.html.erb +1 -1
- data/app/views/decidim/participatory_process_groups/_participatory_process_group.html.erb +22 -0
- data/app/views/decidim/participatory_process_groups/show.html.erb +11 -0
- data/app/views/decidim/participatory_processes/index.html.erb +1 -1
- data/app/views/decidim/participatory_processes/show.html.erb +18 -5
- data/app/views/decidim/reported_mailer/hide.html.erb +5 -0
- data/app/views/decidim/reported_mailer/report.html.erb +5 -0
- data/app/views/decidim/shared/_address_details.html.erb +9 -0
- data/app/views/decidim/shared/_flag_modal.html.erb +20 -0
- data/app/views/decidim/shared/_share_modal.html.erb +5 -5
- data/app/views/decidim/shared/_static_map.html.erb +17 -0
- data/app/views/devise/mailer/invite_collaborator.html.erb +17 -0
- data/app/views/devise/mailer/invite_collaborator.text.erb +15 -0
- data/app/views/layouts/decidim/_application.html.erb +5 -12
- data/app/views/layouts/decidim/{_social_meta.html.erb → _head.html.erb} +13 -0
- data/app/views/layouts/decidim/_head_extra.html.erb +7 -0
- data/app/views/layouts/decidim/_process_header.html.erb +15 -9
- data/app/views/layouts/decidim/_process_header_steps.html.erb +3 -3
- data/app/views/layouts/decidim/{_header.html.erb → _wrapper.html.erb} +47 -10
- data/app/views/pages/home/_highlighted_processes.html.erb +2 -2
- data/config/i18n-tasks.yml +3 -0
- data/config/locales/ca.yml +40 -1
- data/config/locales/en.yml +40 -1
- data/config/locales/es.yml +40 -1
- data/config/locales/eu.yml +235 -1
- data/config/locales/fi.yml +375 -0
- data/config/routes.rb +4 -0
- data/db/migrate/20170215115407_add_organization_custom_reference.rb +11 -0
- data/db/migrate/20170220110740_remove_steps_short_description.rb +21 -0
- data/db/migrate/20170221094835_add_scopes_to_processes.rb +6 -0
- data/db/migrate/20170228142440_add_participatory_process_groups.rb +15 -0
- data/db/migrate/20170306144354_add_secondary_hosts_to_organizations.rb +5 -0
- data/db/migrate/20170307084957_create_reports.rb +15 -0
- data/db/migrate/20170308091316_create_moderations.rb +12 -0
- data/db/migrate/20170313095436_add_available_authorizations_to_organization.rb +10 -0
- data/db/seeds.rb +20 -10
- data/lib/decidim/core.rb +12 -1
- data/lib/decidim/core/api.rb +1 -0
- data/lib/decidim/core/api/decidim_type.rb +12 -0
- data/lib/decidim/core/api/process_step_type.rb +0 -6
- data/lib/decidim/core/api/user_type.rb +4 -0
- data/lib/decidim/core/engine.rb +27 -0
- data/lib/decidim/core/test.rb +5 -0
- data/lib/decidim/core/test/factories.rb +52 -3
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +215 -0
- data/lib/decidim/core/test/shared_examples/has_reference.rb +30 -0
- data/lib/decidim/core/test/shared_examples/manage_moderations_examples.rb +75 -0
- data/lib/decidim/core/test/shared_examples/reportable.rb +44 -0
- data/lib/decidim/core/test/shared_examples/reports_examples.rb +64 -0
- data/lib/decidim/core/version.rb +2 -2
- data/lib/decidim/has_reference.rb +50 -0
- data/lib/decidim/query_extensions.rb +4 -0
- data/lib/decidim/reportable.rb +46 -0
- data/vendor/assets/javascripts/leaflet-svg-icon.js +179 -0
- data/vendor/assets/javascripts/leaflet-tilelayer-here.js +166 -0
- data/vendor/assets/javascripts/leaflet.js +9 -0
- data/vendor/assets/javascripts/leaflet.markercluster.js +7 -0
- data/vendor/assets/javascripts/quill.min.js +8 -8
- data/vendor/assets/javascripts/quill.min.js.map +1 -1
- data/vendor/assets/stylesheets/MarkerCluster.Default.css +60 -0
- data/vendor/assets/stylesheets/MarkerCluster.css +14 -0
- data/vendor/assets/stylesheets/leaflet.css +624 -0
- data/vendor/assets/stylesheets/quill.bubble.css +75 -4
- data/vendor/assets/stylesheets/quill.core.css +21 -2
- data/vendor/assets/stylesheets/quill.snow.css +29 -3
- metadata +107 -27
- data/app/views/layouts/decidim/_footer.html.erb +0 -36
- data/app/views/layouts/decidim/_meta.html.erb +0 -4
data/config/routes.rb
CHANGED
@@ -21,6 +21,7 @@ Decidim::Core::Engine.routes.draw do
|
|
21
21
|
|
22
22
|
resource :locale, only: [:create]
|
23
23
|
|
24
|
+
resources :participatory_process_groups, only: :show, path: "processes_groups"
|
24
25
|
resources :participatory_processes, only: [:index, :show], path: "processes" do
|
25
26
|
resources :participatory_process_steps, only: [:index], path: "steps"
|
26
27
|
end
|
@@ -50,6 +51,7 @@ Decidim::Core::Engine.routes.draw do
|
|
50
51
|
|
51
52
|
resources :pages, only: [:index, :show], format: false
|
52
53
|
|
54
|
+
get "/static_map", to: "static_map#show", as: :static_map
|
53
55
|
get "/cookies/accept", to: "cookie_policy#accept", as: :accept_cookies
|
54
56
|
|
55
57
|
match "/404", to: "pages#show", id: "404", via: :all
|
@@ -59,5 +61,7 @@ Decidim::Core::Engine.routes.draw do
|
|
59
61
|
mount LetterOpenerWeb::Engine, at: "/letter_opener"
|
60
62
|
end
|
61
63
|
|
64
|
+
resource :report, only: [:create]
|
65
|
+
|
62
66
|
root to: "pages#show", id: "home"
|
63
67
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class AddOrganizationCustomReference < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
add_column :decidim_organizations, :reference_prefix, :string
|
4
|
+
|
5
|
+
Decidim::Organization.find_each do |organization|
|
6
|
+
organization.update_attribute(:reference_prefix, organization.name[0])
|
7
|
+
end
|
8
|
+
|
9
|
+
change_column_null :decidim_organizations, :reference_prefix, false
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class RemoveStepsShortDescription < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
Decidim::ParticipatoryProcessStep.transaction do
|
4
|
+
Decidim::ParticipatoryProcessStep.find_each do |step|
|
5
|
+
step.update_attributes!(
|
6
|
+
description: new_description_for(step)
|
7
|
+
)
|
8
|
+
end
|
9
|
+
|
10
|
+
remove_column :decidim_participatory_process_steps, :short_description
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def new_description_for(step)
|
15
|
+
desc = {}
|
16
|
+
step.description.keys.each do |locale|
|
17
|
+
desc[locale] = step.short_description[locale] + step.description[locale]
|
18
|
+
end
|
19
|
+
desc
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class AddParticipatoryProcessGroups < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :decidim_participatory_process_groups do |t|
|
4
|
+
t.jsonb :name, null: false
|
5
|
+
t.jsonb :description, null: false
|
6
|
+
t.string :hero_image
|
7
|
+
|
8
|
+
t.references :decidim_organization, index: { name: "decidim_participatory_process_group_organization" }
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
|
13
|
+
add_column :decidim_participatory_processes, :decidim_participatory_process_group_id, :integer
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateReports < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :decidim_reports do |t|
|
4
|
+
t.references :decidim_moderation, null: false, index: { name: "decidim_reports_moderation" }
|
5
|
+
t.references :decidim_user, null: false, index: { name: "decidim_reports_user" }
|
6
|
+
|
7
|
+
t.string :reason, null: false
|
8
|
+
t.text :details
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index :decidim_reports, [:decidim_moderation_id, :decidim_user_id], unique: true, name: "decidim_reports_moderation_user_unique"
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateModerations < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :decidim_moderations do |t|
|
4
|
+
t.references :decidim_participatory_process, null: false, index: { name: "decidim_moderations_participatory_process" }
|
5
|
+
t.references :decidim_reportable, null: false, polymorphic: true, index: { unique: true, name: "decidim_moderations_reportable" }
|
6
|
+
t.integer :report_count, null: false, default: 0, index: { name: "decidim_moderations_report_count" }
|
7
|
+
t.datetime :hidden_at, index: { name: "decidim_moderations_hidden_at" }
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class AddAvailableAuthorizationsToOrganization < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
add_column :decidim_organizations, :available_authorizations, :string, array: true, default: []
|
4
|
+
|
5
|
+
handlers = Decidim.authorization_handlers.map(&:name)
|
6
|
+
Decidim::Organization.find_each do |org|
|
7
|
+
org.update_attributes(available_authorizations: handlers)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/db/seeds.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
if !Rails.env.production? || ENV["SEED"]
|
3
3
|
require "decidim/faker/localized"
|
4
4
|
|
5
|
-
organization = Decidim::Organization.create!(
|
5
|
+
organization = Decidim::Organization.first || Decidim::Organization.create!(
|
6
6
|
name: Faker::Company.name,
|
7
7
|
twitter_handler: Faker::Hipster.word,
|
8
8
|
facebook_handler: Faker::Hipster.word,
|
@@ -16,7 +16,8 @@ if !Rails.env.production? || ENV["SEED"]
|
|
16
16
|
end,
|
17
17
|
homepage_image: File.new(File.join(File.dirname(__FILE__), "seeds", "homepage_image.jpg")),
|
18
18
|
default_locale: I18n.default_locale,
|
19
|
-
available_locales: Decidim.available_locales
|
19
|
+
available_locales: Decidim.available_locales,
|
20
|
+
reference_prefix: Faker::Name.suffix
|
20
21
|
)
|
21
22
|
|
22
23
|
3.times.each do |index|
|
@@ -28,7 +29,7 @@ if !Rails.env.production? || ENV["SEED"]
|
|
28
29
|
|
29
30
|
Decidim::User.create!(
|
30
31
|
name: Faker::Name.name,
|
31
|
-
email: "admin@
|
32
|
+
email: "admin@example.org",
|
32
33
|
password: "decidim123456",
|
33
34
|
password_confirmation: "decidim123456",
|
34
35
|
organization: organization,
|
@@ -42,7 +43,7 @@ if !Rails.env.production? || ENV["SEED"]
|
|
42
43
|
|
43
44
|
Decidim::User.create!(
|
44
45
|
name: Faker::Name.name,
|
45
|
-
email: "collaborator@
|
46
|
+
email: "collaborator@example.org",
|
46
47
|
password: "decidim123456",
|
47
48
|
password_confirmation: "decidim123456",
|
48
49
|
organization: organization,
|
@@ -56,7 +57,7 @@ if !Rails.env.production? || ENV["SEED"]
|
|
56
57
|
|
57
58
|
Decidim::User.create!(
|
58
59
|
name: Faker::Name.name,
|
59
|
-
email: "user@
|
60
|
+
email: "user@example.org",
|
60
61
|
password: "decidim123456",
|
61
62
|
password_confirmation: "decidim123456",
|
62
63
|
confirmed_at: Time.current,
|
@@ -94,6 +95,17 @@ if !Rails.env.production? || ENV["SEED"]
|
|
94
95
|
end
|
95
96
|
end
|
96
97
|
|
98
|
+
process_groups = []
|
99
|
+
3.times do
|
100
|
+
process_groups << Decidim::ParticipatoryProcessGroup.create!(
|
101
|
+
name: Decidim::Faker::Localized.sentence(3),
|
102
|
+
description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
103
|
+
Decidim::Faker::Localized.paragraph(3)
|
104
|
+
end,
|
105
|
+
hero_image: File.new(File.join(File.dirname(__FILE__), "seeds", "city.jpeg")),
|
106
|
+
organization: organization
|
107
|
+
)
|
108
|
+
end
|
97
109
|
|
98
110
|
3.times do
|
99
111
|
Decidim::ParticipatoryProcess.create!(
|
@@ -112,22 +124,20 @@ if !Rails.env.production? || ENV["SEED"]
|
|
112
124
|
promoted: true,
|
113
125
|
published_at: 2.weeks.ago,
|
114
126
|
organization: organization,
|
115
|
-
|
127
|
+
meta_scope: Decidim::Faker::Localized.word,
|
116
128
|
developer_group: Decidim::Faker::Localized.sentence(1),
|
117
129
|
local_area: Decidim::Faker::Localized.sentence(2),
|
118
130
|
target: Decidim::Faker::Localized.sentence(3),
|
119
131
|
participatory_scope: Decidim::Faker::Localized.sentence(1),
|
120
132
|
participatory_structure: Decidim::Faker::Localized.sentence(2),
|
121
|
-
end_date: 2.month.from_now.at_midnight
|
133
|
+
end_date: 2.month.from_now.at_midnight,
|
134
|
+
participatory_process_group: process_groups.sample
|
122
135
|
)
|
123
136
|
end
|
124
137
|
|
125
138
|
Decidim::ParticipatoryProcess.find_each do |process|
|
126
139
|
Decidim::ParticipatoryProcessStep.create!(
|
127
140
|
title: Decidim::Faker::Localized.sentence(1, false, 2),
|
128
|
-
short_description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
129
|
-
Decidim::Faker::Localized.sentence(3)
|
130
|
-
end,
|
131
141
|
description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
132
142
|
Decidim::Faker::Localized.paragraph(3)
|
133
143
|
end,
|
data/lib/decidim/core.rb
CHANGED
@@ -14,6 +14,7 @@ module Decidim
|
|
14
14
|
autoload :FeatureManifest, "decidim/feature_manifest"
|
15
15
|
autoload :ResourceManifest, "decidim/resource_manifest"
|
16
16
|
autoload :Resourceable, "decidim/resourceable"
|
17
|
+
autoload :Reportable, "decidim/reportable"
|
17
18
|
autoload :Authorable, "decidim/authorable"
|
18
19
|
autoload :Features, "decidim/features"
|
19
20
|
autoload :HasAttachments, "decidim/has_attachments"
|
@@ -21,6 +22,7 @@ module Decidim
|
|
21
22
|
autoload :HasFeature, "decidim/has_feature"
|
22
23
|
autoload :HasScope, "decidim/has_scope"
|
23
24
|
autoload :HasCategory, "decidim/has_category"
|
25
|
+
autoload :HasReference, "decidim/has_reference"
|
24
26
|
autoload :Attributes, "decidim/attributes"
|
25
27
|
|
26
28
|
include ActiveSupport::Configurable
|
@@ -77,7 +79,7 @@ module Decidim
|
|
77
79
|
|
78
80
|
# Exposes a configuration option: The application name String.
|
79
81
|
config_accessor :available_locales do
|
80
|
-
%w(en ca es)
|
82
|
+
%w(en ca es eu fi)
|
81
83
|
end
|
82
84
|
|
83
85
|
# Exposes a configuration option: an object to configure geocoder
|
@@ -91,6 +93,15 @@ module Decidim
|
|
91
93
|
10.megabytes
|
92
94
|
end
|
93
95
|
|
96
|
+
# The number of reports which an object can receive before hiding it
|
97
|
+
config_accessor :max_reports_before_hiding { 3 }
|
98
|
+
|
99
|
+
# A base path for the uploads. If set, make sure it ends in a slash.
|
100
|
+
# Uploads will be set to `<base_path>/uploads/`. This can be useful if you
|
101
|
+
# want to use the same uploads place for both staging and production
|
102
|
+
# environments, but in different folders.
|
103
|
+
config_accessor :base_uploads_path { nil }
|
104
|
+
|
94
105
|
# Public: Registers a feature, usually held in an external library or in a
|
95
106
|
# separate folder in the main repository. Exposes a DSL defined by
|
96
107
|
# `Decidim::FeatureManifest`.
|
data/lib/decidim/core/api.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
# This type represents a ParticipatoryProcess.
|
4
|
+
DecidimType = GraphQL::ObjectType.define do
|
5
|
+
name "Decidim"
|
6
|
+
description "Decidim's framework-related properties."
|
7
|
+
|
8
|
+
field :version, !types.String, "The current decidim's version of this deployment." do
|
9
|
+
resolve ->(obj, _args, _ctx) { obj.version }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -14,5 +14,9 @@ module Decidim
|
|
14
14
|
field :avatarUrl, !types.String, "The user's avatar url" do
|
15
15
|
resolve ->(obj, _args, _ctx) { obj.avatar.url }
|
16
16
|
end
|
17
|
+
|
18
|
+
field :organizationName, !types.String, "The user's organization name" do
|
19
|
+
resolve ->(obj, _args, _ctx) { obj.organization.name }
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
data/lib/decidim/core/engine.rb
CHANGED
@@ -12,6 +12,7 @@ require "jquery-rails"
|
|
12
12
|
require "sassc-rails"
|
13
13
|
require "foundation-rails"
|
14
14
|
require "foundation_rails_helper"
|
15
|
+
require "autoprefixer-rails"
|
15
16
|
require "active_link_to"
|
16
17
|
require "rectify"
|
17
18
|
require "carrierwave"
|
@@ -29,6 +30,7 @@ require "omniauth-google-oauth2"
|
|
29
30
|
require "invisible_captcha"
|
30
31
|
require "premailer/rails"
|
31
32
|
require "nokogiri"
|
33
|
+
require "geocoder"
|
32
34
|
|
33
35
|
require "decidim/api"
|
34
36
|
|
@@ -91,6 +93,31 @@ module Decidim
|
|
91
93
|
initializer "decidim.i18n_exceptions" do
|
92
94
|
ActionView::Base.raise_on_missing_translations = true unless Rails.env.production?
|
93
95
|
end
|
96
|
+
|
97
|
+
initializer "decidim.geocoding" do
|
98
|
+
if Decidim.geocoder.present?
|
99
|
+
Geocoder.configure(
|
100
|
+
# geocoding service (see below for supported options):
|
101
|
+
lookup: :here,
|
102
|
+
|
103
|
+
# IP address geocoding service (see below for supported options):
|
104
|
+
# :ip_lookup => :maxmind,
|
105
|
+
|
106
|
+
# to use an API key:
|
107
|
+
api_key: [Decidim.geocoder&.fetch(:here_app_id), Decidim.geocoder&.fetch(:here_app_code)]
|
108
|
+
|
109
|
+
# geocoding service request timeout, in seconds (default 3):
|
110
|
+
# :timeout => 5,
|
111
|
+
|
112
|
+
# set default units to kilometers:
|
113
|
+
# :units => :km,
|
114
|
+
|
115
|
+
# caching (see below for details):
|
116
|
+
# :cache => Redis.new,
|
117
|
+
# :cache_prefix => "..."
|
118
|
+
)
|
119
|
+
end
|
120
|
+
end
|
94
121
|
end
|
95
122
|
end
|
96
123
|
end
|
data/lib/decidim/core/test.rb
CHANGED
@@ -5,3 +5,8 @@ require "decidim/core/test/shared_examples/has_attachments"
|
|
5
5
|
require "decidim/core/test/shared_examples/has_feature"
|
6
6
|
require "decidim/core/test/shared_examples/has_scope"
|
7
7
|
require "decidim/core/test/shared_examples/has_category"
|
8
|
+
require "decidim/core/test/shared_examples/has_reference"
|
9
|
+
require "decidim/core/test/shared_examples/comments_examples"
|
10
|
+
require "decidim/core/test/shared_examples/reportable"
|
11
|
+
require "decidim/core/test/shared_examples/reports_examples"
|
12
|
+
require "decidim/core/test/shared_examples/manage_moderations_examples"
|
@@ -8,7 +8,7 @@ FactoryGirl.define do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
sequence(:email) do |n|
|
11
|
-
"user#{n}@
|
11
|
+
"user#{n}@example.org"
|
12
12
|
end
|
13
13
|
|
14
14
|
sequence(:slug) do |n|
|
@@ -31,6 +31,7 @@ FactoryGirl.define do
|
|
31
31
|
|
32
32
|
factory :organization, class: Decidim::Organization do
|
33
33
|
name { Faker::Company.unique.name }
|
34
|
+
reference_prefix { Faker::Name.suffix }
|
34
35
|
twitter_handler { Faker::Hipster.word }
|
35
36
|
facebook_handler { Faker::Hipster.word }
|
36
37
|
instagram_handler { Faker::Hipster.word }
|
@@ -58,7 +59,7 @@ FactoryGirl.define do
|
|
58
59
|
banner_image { test_file("city2.jpeg", "image/jpeg") }
|
59
60
|
published_at { Time.current }
|
60
61
|
organization
|
61
|
-
|
62
|
+
meta_scope { Decidim::Faker::Localized.word }
|
62
63
|
developer_group { Decidim::Faker::Localized.sentence(1) }
|
63
64
|
local_area { Decidim::Faker::Localized.sentence(2) }
|
64
65
|
target { Decidim::Faker::Localized.sentence(3) }
|
@@ -77,24 +78,44 @@ FactoryGirl.define do
|
|
77
78
|
published_at { Time.current }
|
78
79
|
end
|
79
80
|
|
81
|
+
trait :with_scope do
|
82
|
+
after(:create) do |participatory_process, _evaluator|
|
83
|
+
create(:scope,
|
84
|
+
organization: participatory_process.organization)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
80
88
|
trait :with_steps do
|
81
89
|
after(:create) do |participatory_process, _evaluator|
|
82
90
|
create(:participatory_process_step,
|
83
91
|
active: true,
|
84
92
|
participatory_process: participatory_process)
|
93
|
+
participatory_process.reload
|
94
|
+
participatory_process.steps.reload
|
85
95
|
end
|
86
96
|
end
|
87
97
|
end
|
88
98
|
|
99
|
+
factory :participatory_process_group, class: Decidim::ParticipatoryProcessGroup do
|
100
|
+
name { Decidim::Faker::Localized.sentence(3) }
|
101
|
+
description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { Decidim::Faker::Localized.sentence(4) } }
|
102
|
+
hero_image { test_file("city.jpeg", "image/jpeg") }
|
103
|
+
organization
|
104
|
+
end
|
105
|
+
|
89
106
|
factory :participatory_process_step, class: Decidim::ParticipatoryProcessStep do
|
90
107
|
title { Decidim::Faker::Localized.sentence(3) }
|
91
|
-
short_description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { Decidim::Faker::Localized.sentence(2) } }
|
92
108
|
description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { Decidim::Faker::Localized.sentence(4) } }
|
93
109
|
start_date 1.month.ago.at_midnight
|
94
110
|
end_date 2.month.from_now.at_midnight
|
95
111
|
position nil
|
96
112
|
participatory_process
|
97
113
|
|
114
|
+
after(:create) do |step, _evaluator|
|
115
|
+
step.participatory_process.reload
|
116
|
+
step.participatory_process.steps.reload
|
117
|
+
end
|
118
|
+
|
98
119
|
trait :active do
|
99
120
|
active true
|
100
121
|
end
|
@@ -139,9 +160,22 @@ FactoryGirl.define do
|
|
139
160
|
phone { Faker::PhoneNumber.phone_number }
|
140
161
|
avatar { test_file("avatar.jpg", "image/jpeg") }
|
141
162
|
|
163
|
+
transient do
|
164
|
+
users []
|
165
|
+
end
|
166
|
+
|
142
167
|
trait :verified do
|
143
168
|
verified_at { Time.current }
|
144
169
|
end
|
170
|
+
|
171
|
+
after(:create) do |user_group, evaluator|
|
172
|
+
users = evaluator.users
|
173
|
+
next if users.empty?
|
174
|
+
|
175
|
+
users.each do |user|
|
176
|
+
create(:user_group_membership, user: user, user_group: user_group)
|
177
|
+
end
|
178
|
+
end
|
145
179
|
end
|
146
180
|
|
147
181
|
factory :user_group_membership, class: Decidim::UserGroupMembership do
|
@@ -201,6 +235,10 @@ FactoryGirl.define do
|
|
201
235
|
manifest_name "dummy"
|
202
236
|
published_at { Time.now }
|
203
237
|
|
238
|
+
after(:create) do |feature, _evaluator|
|
239
|
+
feature.participatory_process.steps.reload
|
240
|
+
end
|
241
|
+
|
204
242
|
trait :unpublished do
|
205
243
|
published_at { nil }
|
206
244
|
end
|
@@ -234,6 +272,17 @@ FactoryGirl.define do
|
|
234
272
|
subject { Decidim::Faker::Localized.sentence(3) }
|
235
273
|
body { Decidim::Faker::Localized.wrapped("<p>", "</p>") { Decidim::Faker::Localized.sentence(4) } }
|
236
274
|
end
|
275
|
+
|
276
|
+
factory :moderation, class: Decidim::Moderation do
|
277
|
+
reportable { build(:dummy_resource) }
|
278
|
+
participatory_process { reportable.feature.participatory_process }
|
279
|
+
end
|
280
|
+
|
281
|
+
factory :report, class: Decidim::Report do
|
282
|
+
moderation
|
283
|
+
user { build(:user, organization: moderation.reportable.organization) }
|
284
|
+
reason "spam"
|
285
|
+
end
|
237
286
|
end
|
238
287
|
|
239
288
|
def test_file(filename, content_type)
|