decidim-core 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/decidim/extras/_add_comments.scss +9 -0
- data/app/assets/stylesheets/decidim/extras/_label-required.scss +3 -0
- data/app/assets/stylesheets/decidim/extras/_reference.scss +3 -0
- data/app/assets/stylesheets/decidim/extras/_social_icons_mini.scss +10 -0
- data/app/commands/decidim/invite_user.rb +1 -1
- data/app/commands/decidim/update_account.rb +2 -6
- data/app/constraints/decidim/current_feature.rb +11 -18
- data/app/constraints/decidim/current_participatory_process.rb +35 -0
- data/app/controllers/concerns/decidim/devise_controllers.rb +1 -0
- data/app/controllers/concerns/decidim/locale_switcher.rb +2 -2
- data/app/controllers/concerns/decidim/needs_authorization.rb +1 -2
- data/app/controllers/concerns/decidim/needs_organization.rb +1 -2
- data/app/controllers/concerns/decidim/needs_participatory_process.rb +19 -10
- data/app/controllers/decidim/account_controller.rb +13 -9
- data/app/controllers/decidim/application_controller.rb +3 -8
- data/app/controllers/decidim/devise/registrations_controller.rb +0 -1
- data/app/controllers/decidim/devise/sessions_controller.rb +0 -1
- data/app/controllers/decidim/errors_controller.rb +15 -0
- data/app/controllers/decidim/features/base_controller.rb +1 -0
- data/app/controllers/decidim/participatory_process_groups_controller.rb +6 -2
- data/app/controllers/decidim/participatory_process_steps_controller.rb +1 -0
- data/app/controllers/decidim/participatory_processes_controller.rb +3 -3
- data/app/helpers/decidim/application_helper.rb +3 -0
- data/app/helpers/decidim/feature_path_helper.rb +35 -0
- data/app/helpers/decidim/feature_reference_helper.rb +4 -2
- data/app/helpers/decidim/icon_helper.rb +20 -0
- data/app/helpers/decidim/menu_helper.rb +1 -1
- data/app/helpers/decidim/participatory_process_helper.rb +0 -14
- data/app/models/decidim/feature.rb +9 -1
- data/app/models/decidim/static_page.rb +1 -0
- data/app/models/decidim/user.rb +2 -0
- data/app/queries/decidim/highlighted_participatory_processes.rb +1 -1
- data/app/views/decidim/account/show.html.erb +1 -3
- data/app/views/decidim/devise/shared/_omniauth_buttons.html.erb +1 -1
- data/app/views/decidim/devise/shared/_omniauth_buttons_mini.html.erb +20 -0
- data/app/views/{pages/500.html.erb → decidim/errors/internal_server_error.html.erb} +0 -0
- data/app/views/{pages/404.html.erb → decidim/errors/not_found.html.erb} +1 -1
- data/app/views/decidim/shared/_login_modal.html.erb +4 -0
- data/app/views/decidim/shared/_share_modal.html.erb +1 -1
- data/app/views/layouts/decidim/_process_header.html.erb +2 -2
- data/config/i18n-tasks.yml +2 -0
- data/config/initializers/invisible_captcha.rb +2 -2
- data/config/locales/ca.yml +14 -8
- data/config/locales/en.yml +13 -7
- data/config/locales/es.yml +13 -7
- data/config/locales/eu.yml +0 -7
- data/config/locales/fi.yml +0 -7
- data/config/locales/fr.yml +4 -11
- data/config/locales/it.yml +0 -7
- data/config/locales/nl.yml +0 -7
- data/config/routes.rb +2 -8
- data/db/migrate/20160817115213_devise_create_decidim_users.rb +6 -6
- data/db/migrate/20160920140207_devise_invitable_add_to_decidim_users.rb +9 -9
- data/db/seeds.rb +2 -2
- data/lib/decidim/core.rb +25 -1
- data/lib/decidim/core/engine.rb +0 -1
- data/lib/decidim/core/test.rb +1 -0
- data/lib/decidim/core/test/factories.rb +11 -6
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +69 -66
- data/lib/decidim/core/test/shared_examples/errors.rb +21 -0
- data/lib/decidim/core/test/shared_examples/has_reference.rb +18 -2
- data/lib/decidim/core/test/shared_examples/manage_moderations_examples.rb +2 -2
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/devise_failure_app.rb +1 -1
- data/lib/decidim/form_builder.rb +89 -5
- data/lib/decidim/has_reference.rb +3 -15
- data/lib/decidim/notifiable.rb +22 -0
- data/lib/devise/models/decidim_validatable.rb +4 -4
- metadata +41 -16
data/config/locales/fi.yml
CHANGED
@@ -307,13 +307,6 @@ fi:
|
|
307
307
|
locale:
|
308
308
|
name: Suomi
|
309
309
|
pages:
|
310
|
-
'404':
|
311
|
-
back_home: Takaisin kotisivulle
|
312
|
-
content_doesnt_exist: Tämä osoite on virheellinen tai sivun osoite on muuttunut.
|
313
|
-
title: Etsimääsi sivua ei löydy
|
314
|
-
'500':
|
315
|
-
title: Palvelimellamme tapahtui virhe
|
316
|
-
try_later: Yritä myöhemmin uudestaan.
|
317
310
|
home:
|
318
311
|
extended:
|
319
312
|
debates: Väittelyt
|
data/config/locales/fr.yml
CHANGED
@@ -176,8 +176,8 @@ fr:
|
|
176
176
|
local_area: Localisation
|
177
177
|
participatory_scope: Objectif du processus participatif
|
178
178
|
participatory_structure: Organisations concernées
|
179
|
-
scope:
|
180
|
-
target: Public
|
179
|
+
scope: Zone d'application
|
180
|
+
target: Public visé
|
181
181
|
reported_mailer:
|
182
182
|
hide:
|
183
183
|
hello: Bonjour %{name},
|
@@ -188,7 +188,7 @@ fr:
|
|
188
188
|
reports:
|
189
189
|
create:
|
190
190
|
error: Une erreur s'est produite lors de la création du rapport. Veuillez essayer à nouveau.
|
191
|
-
success: Le
|
191
|
+
success: Le contenu a été signalé, il sera examiné par un administrateur.
|
192
192
|
shared:
|
193
193
|
action_authorization_modal:
|
194
194
|
incomplete:
|
@@ -214,7 +214,7 @@ fr:
|
|
214
214
|
close: Fermer
|
215
215
|
description: Ce contenu est-il inapproprié?
|
216
216
|
does_not_belong: Contient des activités illégales, des menaces suicidaires, des informations personnelles, ou autre chose que vous pensez ne pas être approprié à %{organization_name}.
|
217
|
-
offensive: Contient des propos
|
217
|
+
offensive: Contient des propos racistes, sexistes, des insultes, des attaques personnelles, des menaces de mort, des incitations au suicide ou toute forme de discours de haine.
|
218
218
|
report: Signaler
|
219
219
|
spam: Contient des piège-à-clic (clickbait), des publicités, des escroqueries ou des robots fonctionnant au script (script bots).
|
220
220
|
title: Signaler un problème
|
@@ -323,13 +323,6 @@ fr:
|
|
323
323
|
locale:
|
324
324
|
name: Français
|
325
325
|
pages:
|
326
|
-
'404':
|
327
|
-
back_home: Retour à l'accueil
|
328
|
-
content_doesnt_exist: Cette adresse web est incorrecte ou n'existe plus.
|
329
|
-
title: La page que vous recherchez ne peut être trouvée
|
330
|
-
'500':
|
331
|
-
title: Il y a eu un problème avec notre serveur
|
332
|
-
try_later: Veuillez réessayer plus tard.
|
333
326
|
home:
|
334
327
|
extended:
|
335
328
|
debates: Débats
|
data/config/locales/it.yml
CHANGED
@@ -303,13 +303,6 @@ it:
|
|
303
303
|
locale:
|
304
304
|
name: Italiano
|
305
305
|
pages:
|
306
|
-
'404':
|
307
|
-
back_home: Torna alla home page
|
308
|
-
content_doesnt_exist: Questo indirizzo non è corretto oppure è stato rimosso.
|
309
|
-
title: La pagina che stai cercando non esiste oppure non è disponibile
|
310
|
-
'500':
|
311
|
-
title: Si è verificato un problema da parte del server
|
312
|
-
try_later: Per cortesia riprova più tardi.
|
313
306
|
home:
|
314
307
|
extended:
|
315
308
|
debates: Dibattiti
|
data/config/locales/nl.yml
CHANGED
@@ -307,13 +307,6 @@ nl:
|
|
307
307
|
locale:
|
308
308
|
name: Nederlands
|
309
309
|
pages:
|
310
|
-
'404':
|
311
|
-
back_home: Terug naar huis
|
312
|
-
content_doesnt_exist: Dit adres is onjuist of is verwijderd.
|
313
|
-
title: De pagina die u zoekt is niet gevonden
|
314
|
-
'500':
|
315
|
-
title: Er was een probleem met de server
|
316
|
-
try_later: Probeer het later opnieuw.
|
317
310
|
home:
|
318
311
|
extended:
|
319
312
|
debates: Debatten
|
data/config/routes.rb
CHANGED
@@ -36,8 +36,6 @@ Decidim::Core::Engine.routes.draw do
|
|
36
36
|
mount manifest.engine, at: "/", as: "decidim_#{manifest.name}"
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
40
|
-
get "/", to: redirect("/404"), as: :feature
|
41
39
|
end
|
42
40
|
|
43
41
|
authenticate(:user) do
|
@@ -60,12 +58,8 @@ Decidim::Core::Engine.routes.draw do
|
|
60
58
|
get "/static_map", to: "static_map#show", as: :static_map
|
61
59
|
get "/cookies/accept", to: "cookie_policy#accept", as: :accept_cookies
|
62
60
|
|
63
|
-
match "/404", to: "
|
64
|
-
match "/500", to: "
|
65
|
-
|
66
|
-
if Rails.env.development? && defined?(LetterOpenerWeb::Engine)
|
67
|
-
mount LetterOpenerWeb::Engine, at: "/letter_opener"
|
68
|
-
end
|
61
|
+
match "/404", to: "errors#not_found", via: :all
|
62
|
+
match "/500", to: "errors#internal_server_error", via: :all
|
69
63
|
|
70
64
|
resource :report, only: [:create]
|
71
65
|
|
@@ -4,22 +4,22 @@ class DeviseCreateDecidimUsers < ActiveRecord::Migration[5.0]
|
|
4
4
|
def change
|
5
5
|
create_table :decidim_users do |t|
|
6
6
|
## Database authenticatable
|
7
|
-
t.string :email,
|
7
|
+
t.string :email, null: false, default: ""
|
8
8
|
t.string :encrypted_password, null: false, default: ""
|
9
9
|
|
10
10
|
## Recoverable
|
11
|
-
t.string
|
11
|
+
t.string :reset_password_token
|
12
12
|
t.datetime :reset_password_sent_at
|
13
13
|
|
14
14
|
## Rememberable
|
15
15
|
t.datetime :remember_created_at
|
16
16
|
|
17
17
|
## Trackable
|
18
|
-
t.integer
|
18
|
+
t.integer :sign_in_count, default: 0, null: false
|
19
19
|
t.datetime :current_sign_in_at
|
20
20
|
t.datetime :last_sign_in_at
|
21
|
-
t.string
|
22
|
-
t.string
|
21
|
+
t.string :current_sign_in_ip
|
22
|
+
t.string :last_sign_in_ip
|
23
23
|
|
24
24
|
## Confirmable
|
25
25
|
# t.string :confirmation_token
|
@@ -35,7 +35,7 @@ class DeviseCreateDecidimUsers < ActiveRecord::Migration[5.0]
|
|
35
35
|
t.timestamps null: false
|
36
36
|
end
|
37
37
|
|
38
|
-
add_index :decidim_users, :email,
|
38
|
+
add_index :decidim_users, :email, unique: true
|
39
39
|
add_index :decidim_users, :reset_password_token, unique: true
|
40
40
|
# add_index :decidim_users, :confirmation_token, unique: true
|
41
41
|
# add_index :decidim_users, :unlock_token, unique: true
|
@@ -3,16 +3,16 @@
|
|
3
3
|
class DeviseInvitableAddToDecidimUsers < ActiveRecord::Migration[4.2]
|
4
4
|
def up
|
5
5
|
change_table :decidim_users do |t|
|
6
|
-
t.string
|
7
|
-
t.datetime
|
8
|
-
t.datetime
|
9
|
-
t.datetime
|
10
|
-
t.integer
|
6
|
+
t.string :invitation_token
|
7
|
+
t.datetime :invitation_created_at
|
8
|
+
t.datetime :invitation_sent_at
|
9
|
+
t.datetime :invitation_accepted_at
|
10
|
+
t.integer :invitation_limit
|
11
11
|
t.references :invited_by, polymorphic: true
|
12
|
-
t.integer
|
13
|
-
t.index
|
14
|
-
t.index
|
15
|
-
t.index
|
12
|
+
t.integer :invitations_count, default: 0
|
13
|
+
t.index :invitations_count
|
14
|
+
t.index :invitation_token, unique: true # for invitable
|
15
|
+
t.index :invited_by_id
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
data/db/seeds.rb
CHANGED
@@ -70,7 +70,7 @@ if !Rails.env.production? || ENV["SEED"]
|
|
70
70
|
)
|
71
71
|
|
72
72
|
3.times do
|
73
|
-
Decidim::User.
|
73
|
+
Decidim::User.find_each do |user|
|
74
74
|
user_group = Decidim::UserGroup.create!(
|
75
75
|
name: Faker::Company.name,
|
76
76
|
document_number: Faker::Number.number(10),
|
@@ -85,7 +85,7 @@ if !Rails.env.production? || ENV["SEED"]
|
|
85
85
|
)
|
86
86
|
|
87
87
|
user_group = Decidim::UserGroup.create!(
|
88
|
-
name: Faker::Company.name,
|
88
|
+
name: Faker::Company.unique.name,
|
89
89
|
document_number: Faker::Number.number(10),
|
90
90
|
phone: Faker::PhoneNumber.phone_number,
|
91
91
|
decidim_organization_id: user.organization.id
|
data/lib/decidim/core.rb
CHANGED
@@ -17,6 +17,7 @@ module Decidim
|
|
17
17
|
autoload :Resourceable, "decidim/resourceable"
|
18
18
|
autoload :Reportable, "decidim/reportable"
|
19
19
|
autoload :Authorable, "decidim/authorable"
|
20
|
+
autoload :Notifiable, "decidim/notifiable"
|
20
21
|
autoload :Features, "decidim/features"
|
21
22
|
autoload :HasAttachments, "decidim/has_attachments"
|
22
23
|
autoload :FeatureValidator, "decidim/feature_validator"
|
@@ -84,14 +85,37 @@ module Decidim
|
|
84
85
|
[]
|
85
86
|
end
|
86
87
|
|
87
|
-
# Exposes a configuration option: The application
|
88
|
+
# Exposes a configuration option: The application available locales.
|
88
89
|
config_accessor :available_locales do
|
89
90
|
%w(en ca es eu it fi fr nl)
|
90
91
|
end
|
91
92
|
|
93
|
+
# Exposes a configuration option: The application default locale.
|
94
|
+
config_accessor :default_locale { :en }
|
95
|
+
|
92
96
|
# Exposes a configuration option: an object to configure geocoder
|
93
97
|
config_accessor :geocoder
|
94
98
|
|
99
|
+
# Exposes a configuration option: a custom method to generate references
|
100
|
+
# Default: Calculates a unique reference for the model in
|
101
|
+
# the following format:
|
102
|
+
#
|
103
|
+
# "BCN-DPP-2017-02-6589" which in this example translates to:
|
104
|
+
#
|
105
|
+
# BCN: A setting configured at the organization to be prepended to each reference.
|
106
|
+
# PROP: Unique name identifier for a resource: Decidim::Proposals::Proposal (MEET for meetings or PROJ for projects).
|
107
|
+
# 2017-02: Year-Month of the resource creation date
|
108
|
+
# 6589: ID of the resource
|
109
|
+
config_accessor :resource_reference_generator do
|
110
|
+
lambda do |resource, feature|
|
111
|
+
ref = feature.participatory_process.organization.reference_prefix
|
112
|
+
class_identifier = resource.class.name.demodulize[0..3].upcase
|
113
|
+
year_month = (resource.created_at || Time.current).strftime("%Y-%m")
|
114
|
+
|
115
|
+
[ref, class_identifier, year_month, resource.id].join("-")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
95
119
|
# Exposes a configuration option: the currency unit
|
96
120
|
config_accessor :currency_unit { "€" }
|
97
121
|
|
data/lib/decidim/core/engine.rb
CHANGED
data/lib/decidim/core/test.rb
CHANGED
@@ -11,3 +11,4 @@ require "decidim/core/test/shared_examples/comments_examples"
|
|
11
11
|
require "decidim/core/test/shared_examples/reportable"
|
12
12
|
require "decidim/core/test/shared_examples/reports_examples"
|
13
13
|
require "decidim/core/test/shared_examples/manage_moderations_examples"
|
14
|
+
require "decidim/core/test/shared_examples/errors"
|
@@ -126,14 +126,14 @@ FactoryGirl.define do
|
|
126
126
|
end
|
127
127
|
|
128
128
|
factory :user, class: Decidim::User do
|
129
|
-
email
|
130
|
-
password
|
129
|
+
email { generate(:email) }
|
130
|
+
password "password1234"
|
131
131
|
password_confirmation "password1234"
|
132
|
-
name
|
132
|
+
name { generate(:name) }
|
133
133
|
organization
|
134
|
-
locale
|
135
|
-
tos_agreement
|
136
|
-
avatar
|
134
|
+
locale { organization.default_locale }
|
135
|
+
tos_agreement "1"
|
136
|
+
avatar { test_file("avatar.jpg", "image/jpeg") }
|
137
137
|
comments_notifications true
|
138
138
|
replies_notifications true
|
139
139
|
|
@@ -141,6 +141,11 @@ FactoryGirl.define do
|
|
141
141
|
confirmed_at { Time.current }
|
142
142
|
end
|
143
143
|
|
144
|
+
trait :deleted do
|
145
|
+
email ""
|
146
|
+
deleted_at { Time.current }
|
147
|
+
end
|
148
|
+
|
144
149
|
trait :admin do
|
145
150
|
roles ["admin"]
|
146
151
|
end
|
@@ -4,24 +4,14 @@
|
|
4
4
|
RSpec.shared_examples "comments" do
|
5
5
|
let!(:organization) { create(:organization) }
|
6
6
|
let!(:user) { create(:user, :confirmed, organization: organization) }
|
7
|
-
let!(:comments)
|
8
|
-
Array.new(3) do
|
9
|
-
create(:comment, commentable: commentable)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
let(:authenticated) { false }
|
13
|
-
|
14
|
-
def visit_commentable_path
|
15
|
-
login_as user, scope: :user if authenticated
|
16
|
-
visit resource_path
|
17
|
-
end
|
7
|
+
let!(:comments) { create_list(:comment, 3, commentable: commentable) }
|
18
8
|
|
19
9
|
before do
|
20
10
|
switch_to_host(organization.host)
|
21
11
|
end
|
22
12
|
|
23
|
-
it "
|
24
|
-
|
13
|
+
it "shows the list of comments for the resorce" do
|
14
|
+
visit resource_path
|
25
15
|
|
26
16
|
expect(page).to have_selector("#comments")
|
27
17
|
expect(page).to have_selector("article.comment", count: comments.length)
|
@@ -34,11 +24,11 @@ RSpec.shared_examples "comments" do
|
|
34
24
|
end
|
35
25
|
end
|
36
26
|
|
37
|
-
it "user
|
27
|
+
it "allows user to sort the comments" do
|
38
28
|
comment = create(:comment, commentable: commentable, body: "Most Rated Comment")
|
39
29
|
create(:comment_vote, comment: comment, author: user, weight: 1)
|
40
30
|
|
41
|
-
|
31
|
+
visit resource_path
|
42
32
|
|
43
33
|
within ".order-by" do
|
44
34
|
page.find(".dropdown.menu .is-dropdown-submenu-parent").hover
|
@@ -52,44 +42,41 @@ RSpec.shared_examples "comments" do
|
|
52
42
|
end
|
53
43
|
|
54
44
|
context "when not authenticated" do
|
55
|
-
it "
|
56
|
-
|
45
|
+
it "does not show form to add comments to user" do
|
46
|
+
visit resource_path
|
57
47
|
expect(page).not_to have_selector(".add-comment form")
|
58
48
|
end
|
59
49
|
end
|
60
50
|
|
61
51
|
context "when authenticated" do
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
52
|
+
before do
|
53
|
+
login_as user, scope: :user
|
54
|
+
visit resource_path
|
55
|
+
end
|
66
56
|
|
57
|
+
it "shows form to add comments to user" do
|
67
58
|
expect(page).to have_selector(".add-comment form")
|
68
59
|
end
|
69
60
|
|
70
61
|
context "when user adds a new comment" do
|
71
62
|
before do
|
72
|
-
visit_commentable_path
|
73
|
-
|
74
|
-
expect(page).to have_selector(".add-comment form")
|
75
|
-
|
76
63
|
within ".add-comment form" do
|
77
64
|
fill_in "add-comment-#{commentable.commentable_type}-#{commentable.id}", with: "This is a new comment"
|
78
65
|
click_button "Send"
|
79
66
|
end
|
80
67
|
end
|
81
68
|
|
82
|
-
it "
|
69
|
+
it "shows comment to the user" do
|
83
70
|
within "#comments" do
|
84
71
|
expect(page).to have_content user.name
|
85
72
|
expect(page).to have_content "This is a new comment"
|
86
73
|
end
|
87
74
|
end
|
88
75
|
|
89
|
-
it "
|
90
|
-
if commentable.
|
76
|
+
it "send notifications" do
|
77
|
+
if commentable.notifiable?(author: user)
|
91
78
|
wait_for_email subject: "new comment"
|
92
|
-
|
79
|
+
relogin_as commentable.users_to_notify.first, scope: :user
|
93
80
|
visit last_email_first_link
|
94
81
|
|
95
82
|
within "#comments" do
|
@@ -111,8 +98,8 @@ RSpec.shared_examples "comments" do
|
|
111
98
|
create(:user_group_membership, user: user, user_group: user_group)
|
112
99
|
end
|
113
100
|
|
114
|
-
it "
|
115
|
-
|
101
|
+
it "adds new comment as a user group" do
|
102
|
+
visit resource_path
|
116
103
|
|
117
104
|
expect(page).to have_selector(".add-comment form")
|
118
105
|
|
@@ -129,12 +116,12 @@ RSpec.shared_examples "comments" do
|
|
129
116
|
end
|
130
117
|
end
|
131
118
|
|
132
|
-
context "when a user replies a
|
119
|
+
context "when a user replies to a comment" do
|
133
120
|
let!(:comment_author) { create(:user, :confirmed, organization: organization) }
|
134
121
|
let!(:comment) { create(:comment, commentable: commentable, author: comment_author) }
|
135
122
|
|
136
123
|
before do
|
137
|
-
|
124
|
+
visit resource_path
|
138
125
|
|
139
126
|
expect(page).to have_selector(".comment__reply")
|
140
127
|
|
@@ -145,15 +132,15 @@ RSpec.shared_examples "comments" do
|
|
145
132
|
end
|
146
133
|
end
|
147
134
|
|
148
|
-
it "
|
135
|
+
it "shows reply to the user" do
|
149
136
|
within "#comments #comment_#{comment.id}" do
|
150
137
|
expect(page).to have_content "This is a reply"
|
151
138
|
end
|
152
139
|
end
|
153
140
|
|
154
|
-
it "
|
141
|
+
it "sends notifications received by commentable's author" do
|
155
142
|
wait_for_email subject: "new reply"
|
156
|
-
|
143
|
+
relogin_as comment.author, scope: :user
|
157
144
|
visit last_email_first_link
|
158
145
|
|
159
146
|
within "#comments #comment_#{comment.id}" do
|
@@ -162,51 +149,67 @@ RSpec.shared_examples "comments" do
|
|
162
149
|
end
|
163
150
|
end
|
164
151
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
it "user can comment in favor" do
|
171
|
-
visit_commentable_path
|
152
|
+
describe "arguable option" do
|
153
|
+
context "commenting with alignment" do
|
154
|
+
before do
|
155
|
+
visit resource_path
|
172
156
|
|
173
|
-
|
157
|
+
expect(page).to have_selector(".add-comment form")
|
158
|
+
end
|
174
159
|
|
175
|
-
|
160
|
+
it "works according to the setting in the commentable" do
|
161
|
+
if commentable.comments_have_alignment?
|
162
|
+
page.find(".opinion-toggle--ok").click
|
176
163
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
164
|
+
within ".add-comment form" do
|
165
|
+
fill_in "add-comment-#{commentable.commentable_type}-#{commentable.id}", with: "I am in favor about this!"
|
166
|
+
click_button "Send"
|
167
|
+
end
|
181
168
|
|
182
|
-
|
183
|
-
|
169
|
+
within "#comments" do
|
170
|
+
expect(page).to have_selector "span.success.label", text: "In favor"
|
171
|
+
end
|
172
|
+
else
|
173
|
+
expect(page).not_to have_selector(".opinion-toggle--ok")
|
174
|
+
end
|
184
175
|
end
|
185
176
|
end
|
186
177
|
end
|
187
178
|
|
188
|
-
|
179
|
+
describe "votable option" do
|
189
180
|
before do
|
190
|
-
|
181
|
+
visit resource_path
|
191
182
|
end
|
192
183
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
184
|
+
context "upvoting a comment" do
|
185
|
+
it "works according to the setting in the commentable" do
|
186
|
+
within "#comment_#{comments[0].id}" do
|
187
|
+
if commentable.comments_have_votes?
|
188
|
+
expect(page).to have_selector(".comment__votes--up", text: /0/)
|
189
|
+
page.find(".comment__votes--up").click
|
190
|
+
expect(page).to have_selector(".comment__votes--up", text: /1/)
|
191
|
+
else
|
192
|
+
expect(page).to_not have_selector(".comment__votes--up", text: /0/)
|
193
|
+
end
|
194
|
+
end
|
200
195
|
end
|
201
196
|
end
|
202
197
|
|
203
|
-
|
204
|
-
|
198
|
+
context "downvoting a comment" do
|
199
|
+
before do
|
200
|
+
visit resource_path
|
201
|
+
end
|
205
202
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
203
|
+
it "works according to the setting in the commentable" do
|
204
|
+
within "#comment_#{comments[0].id}" do
|
205
|
+
if commentable.comments_have_votes?
|
206
|
+
expect(page).to have_selector(".comment__votes--down", text: /0/)
|
207
|
+
page.find(".comment__votes--down").click
|
208
|
+
expect(page).to have_selector(".comment__votes--down", text: /1/)
|
209
|
+
else
|
210
|
+
expect(page).to_not have_selector(".comment__votes--down", text: /0/)
|
211
|
+
end
|
212
|
+
end
|
210
213
|
end
|
211
214
|
end
|
212
215
|
end
|