decidim-department_admin 0.7.2
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 +7 -0
- data/LICENSE-AGPLv3.txt +661 -0
- data/README.md +132 -0
- data/Rakefile +9 -0
- data/app/controllers/decidim/department_admin/admin/application_controller.rb +15 -0
- data/app/controllers/decidim/department_admin/application_controller.rb +13 -0
- data/app/decorators/decidim/admin/newsletters_controller_decorator.rb +30 -0
- data/app/decorators/decidim/admin/users_controller_decorator.rb +128 -0
- data/app/decorators/decidim/area_decorator.rb +44 -0
- data/app/decorators/decidim/assemblies/admin/assemblies_controller_decorator.rb +25 -0
- data/app/decorators/decidim/assemblies/admin/assemblies_helper_decorator.rb +24 -0
- data/app/decorators/decidim/assemblies/create_assembly_decorator.rb +19 -0
- data/app/decorators/decidim/assemblies/parent_assemblies_for_select_decorator.rb +38 -0
- data/app/decorators/decidim/assemblies/permissions_decorator.rb +22 -0
- data/app/decorators/decidim/assemblies/update_assembly_decorator.rb +19 -0
- data/app/decorators/decidim/assemblies_decorator.rb +21 -0
- data/app/decorators/decidim/assemblies_with_user_role_decorator.rb +27 -0
- data/app/decorators/decidim/conference_form_decorator.rb +23 -0
- data/app/decorators/decidim/conferences/admin/conferences_controller_decorator.rb +27 -0
- data/app/decorators/decidim/conferences/create_conference_decorator.rb +51 -0
- data/app/decorators/decidim/conferences/permissions_decorator.rb +24 -0
- data/app/decorators/decidim/conferences/update_conference_decorator.rb +21 -0
- data/app/decorators/decidim/conferences_decorator.rb +27 -0
- data/app/decorators/decidim/conferences_with_user_role_decorator.rb +29 -0
- data/app/decorators/decidim/decidim_form_helper_decorator.rb +23 -0
- data/app/decorators/decidim/invite_user_decorator.rb +56 -0
- data/app/decorators/decidim/invite_user_form_decorator.rb +45 -0
- data/app/decorators/decidim/newsletter_decorator.rb +20 -0
- data/app/decorators/decidim/newsletters_helper_decorator.rb +44 -0
- data/app/decorators/decidim/participatory_process_decorator.rb +21 -0
- data/app/decorators/decidim/participatory_process_group_decorator.rb +17 -0
- data/app/decorators/decidim/participatory_processes/admin/participatory_processes_controller_decorator.rb +25 -0
- data/app/decorators/decidim/participatory_processes/create_participatory_process_decorator.rb +19 -0
- data/app/decorators/decidim/participatory_processes/permissions_decorator.rb +22 -0
- data/app/decorators/decidim/participatory_processes/update_participatory_process_decorator.rb +19 -0
- data/app/decorators/decidim/participatory_processes_with_user_role_decorator.rb +27 -0
- data/app/decorators/decidim/user_decorator.rb +59 -0
- data/app/decorators/lib/decidim/participatory_space_resourceable_decorator.rb +36 -0
- data/app/helpers/decidim/admin/user_roles_helper.rb +25 -0
- data/app/helpers/decidim/department_admin/application_helper.rb +54 -0
- data/app/models/decidim/participatory_space_role_config/department_admin.rb +8 -0
- data/app/overrides/decidim/admin/shared/add_radio_buttons_to_filters.rb +6 -0
- data/app/packs/entrypoints/decidim_department_admin.js +4 -0
- data/app/packs/entrypoints/decidim_department_admin.scss +1 -0
- data/app/packs/images/decidim/department_admin/icon.svg +1 -0
- data/app/packs/stylesheets/decidim/admin/department_admin.scss +5 -0
- data/app/permissions/decidim/assemblies/participatory_space_permissions.rb +14 -0
- data/app/permissions/decidim/conferences/participatory_space_permissions.rb +17 -0
- data/app/permissions/decidim/department_admin/permissions.rb +240 -0
- data/app/permissions/decidim/participatory_processes/participatory_space_permissions.rb +14 -0
- data/app/queries/decidim/admin/user_admin_by_space_name_filter.rb +67 -0
- data/app/queries/decidim/admin/user_admin_filter.rb +50 -0
- data/app/views/decidim/admin/users/_filters.html.erb +28 -0
- data/app/views/decidim/admin/users/_form.html.erb +30 -0
- data/app/views/decidim/admin/users/index.html.erb +93 -0
- data/app/views/decidim/admin/users/show.html.erb +99 -0
- data/app/views/decidim/assemblies/admin/assemblies/index.html.erb +147 -0
- data/app/views/decidim/conferences/admin/conferences/_form.html.erb +127 -0
- data/app/views/decidim/conferences/admin/conferences/index.html.erb +85 -0
- data/app/views/decidim/participatory_processes/admin/participatory_processes/index.html.erb +160 -0
- data/config/assets.rb +27 -0
- data/config/i18n-tasks.yml +148 -0
- data/config/initializers/user_roles.rb +4 -0
- data/config/locales/ca.yml +61 -0
- data/config/locales/cs.yml +46 -0
- data/config/locales/en.yml +61 -0
- data/config/locales/es.yml +61 -0
- data/db/migrate/20190328130102_create_department_admin_areas.rb +10 -0
- data/db/migrate/20210420143021_add_area_to_conferences.rb +7 -0
- data/lib/decidim/department_admin/admin.rb +10 -0
- data/lib/decidim/department_admin/admin_engine.rb +27 -0
- data/lib/decidim/department_admin/engine.rb +137 -0
- data/lib/decidim/department_admin/test/factories.rb +17 -0
- data/lib/decidim/department_admin/version.rb +11 -0
- data/lib/decidim/department_admin.rb +15 -0
- data/spec/commands/decidim/admin/deliver_newsletter_spec.rb +175 -0
- data/spec/commands/decidim/invite_user_spec.rb +42 -0
- data/spec/controllers/decidim/admin/users_controller_spec.rb +119 -0
- data/spec/factories.rb +4 -0
- data/spec/features/check_overrides_spec.rb +11 -0
- data/spec/i18n_spec.rb +29 -0
- data/spec/models/decidim/area_spec.rb +23 -0
- data/spec/permissions/decidim/department_admin/department_admin_permissions_spec.rb +120 -0
- data/spec/queries/parent_assemblies_for_select_spec.rb +52 -0
- data/spec/spec_helper.rb +47 -0
- data/spec/system/admin_explores_processes_spec.rb +53 -0
- data/spec/system/admin_invite_department_admin_spec.rb +118 -0
- data/spec/system/department_admin_manages_newsletters_spec.rb +237 -0
- data/spec/system/department_admin_should_be_able_to_access_admin_dashboard_spec.rb +75 -0
- data/spec/system/department_admin_should_be_able_to_manage_assemblies_spec.rb +99 -0
- data/spec/system/department_admin_should_be_able_to_manage_conferences_spec.rb +74 -0
- data/spec/system/department_admin_should_be_able_to_manage_processes_spec.rb +117 -0
- data/spec/system/department_admin_should_be_able_to_see_only_assemblies_from_her_area_spec.rb +46 -0
- data/spec/system/department_admin_should_be_able_to_see_only_newsletters_from_her_area_spec.rb +53 -0
- data/spec/system/department_admin_should_be_able_to_see_only_processes_from_her_area_spec.rb +50 -0
- metadata +229 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
# To "downgrade" an admin to department_admin, it must first be removed from admins
|
|
7
|
+
# create a new admin as department_admin.
|
|
8
|
+
#
|
|
9
|
+
describe "Admin invite user", type: :system do
|
|
10
|
+
let!(:area) { create(:area) }
|
|
11
|
+
|
|
12
|
+
let(:organization) { create(:organization) }
|
|
13
|
+
|
|
14
|
+
let!(:admin) { create(:user, :admin, :confirmed, organization: organization) }
|
|
15
|
+
let(:user_manager) { create(:user, :user_manager, :confirmed, organization: organization) }
|
|
16
|
+
|
|
17
|
+
let(:department_admin) do
|
|
18
|
+
user = create(:user, :confirmed, organization: organization)
|
|
19
|
+
user.roles << "department_admin"
|
|
20
|
+
user.areas << area
|
|
21
|
+
user.save!
|
|
22
|
+
user
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
before do
|
|
26
|
+
switch_to_host(organization.host)
|
|
27
|
+
login_as admin, scope: :user
|
|
28
|
+
visit decidim_admin.new_user_path
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "admin is able to create department admins" do
|
|
32
|
+
fill_the_form_for_department_admin("Cabello Loco", "my@email.net")
|
|
33
|
+
submit_form
|
|
34
|
+
check_succeess
|
|
35
|
+
user = check_is_department_admin("my@email.net")
|
|
36
|
+
check_assigned_area(user, area)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "admin is able to add department_admin role to existing user" do
|
|
40
|
+
fill_the_form_for_department_admin(user_manager.name, user_manager.email)
|
|
41
|
+
submit_form
|
|
42
|
+
check_succeess
|
|
43
|
+
check_is_department_admin(user_manager.email)
|
|
44
|
+
check_assigned_area(user_manager, area)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context "when departments are reorganized" do
|
|
48
|
+
let!(:new_area) { create(:area) }
|
|
49
|
+
|
|
50
|
+
before do
|
|
51
|
+
department_admin
|
|
52
|
+
visit decidim_admin.new_user_path
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "admin is able to change department_admin's area/department" do
|
|
56
|
+
fill_the_form_for_department_admin(department_admin.name, department_admin.email, new_area)
|
|
57
|
+
submit_form
|
|
58
|
+
check_succeess
|
|
59
|
+
check_is_department_admin(department_admin.email)
|
|
60
|
+
check_assigned_area(department_admin, new_area)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
context "when a department_admin is promoted to Admin" do
|
|
65
|
+
it "no longer has the `department_admin` role" do
|
|
66
|
+
department_admin
|
|
67
|
+
fill_the_form_for_admin(department_admin.name, department_admin.email)
|
|
68
|
+
submit_form
|
|
69
|
+
check_succeess
|
|
70
|
+
check_is_admin(department_admin.email)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def fill_the_form_for_department_admin(name, email, selected_area = area)
|
|
75
|
+
within "form.new_user" do
|
|
76
|
+
fill_in :user_name, with: name
|
|
77
|
+
fill_in :user_email, with: email
|
|
78
|
+
find("#user_role").find("option[value='department_admin']").select_option
|
|
79
|
+
expect(page).to have_css("#user_area_id")
|
|
80
|
+
find("#user_area_id").find("option[value='#{selected_area.id}']").select_option
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def fill_the_form_for_admin(name, email, _selected_area = area)
|
|
85
|
+
within "form.new_user" do
|
|
86
|
+
fill_in :user_name, with: name
|
|
87
|
+
fill_in :user_email, with: email
|
|
88
|
+
find("#user_role").find("option[value='admin']").select_option
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def submit_form
|
|
93
|
+
find("*[name=commit][type=submit]").click
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def check_succeess
|
|
97
|
+
expect(page).to have_content("Participant successfully invited.")
|
|
98
|
+
expect(page).to have_current_path "/admin/users"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def check_is_admin(email)
|
|
102
|
+
user = Decidim::User.find_by(email: email).reload
|
|
103
|
+
expect(user).to be_admin
|
|
104
|
+
expect(user.roles).not_to include("department_admin")
|
|
105
|
+
expect(user.areas).to be_empty
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def check_is_department_admin(email)
|
|
109
|
+
user = Decidim::User.find_by(email: email)
|
|
110
|
+
expect(user.roles).to include("department_admin")
|
|
111
|
+
user
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def check_assigned_area(user, area)
|
|
115
|
+
expect(user.areas.last).to eq(area)
|
|
116
|
+
expect(user.areas.size).to eq(1)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Admin manages newsletters", type: :system do
|
|
6
|
+
let(:organization) { create(:organization) }
|
|
7
|
+
let(:area) { create(:area, organization: organization) }
|
|
8
|
+
let(:department_admin) { create(:department_admin, :confirmed, name: "Sarah Kerrigan", organization: organization, area: area) }
|
|
9
|
+
let!(:deliverable_users) { create_list(:user, 5, :confirmed, newsletter_notifications_at: Time.current, organization: organization) }
|
|
10
|
+
|
|
11
|
+
before do
|
|
12
|
+
switch_to_host(organization.host)
|
|
13
|
+
login_as department_admin, scope: :user
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def wait_redirect
|
|
17
|
+
sleep(0.5)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def fill_newsletter_form
|
|
21
|
+
fill_in_i18n(
|
|
22
|
+
:newsletter_subject,
|
|
23
|
+
"#newsletter-subject-tabs",
|
|
24
|
+
en: "A fancy newsletter for %{name}",
|
|
25
|
+
es: "Un correo electrónico muy chulo para %{name}",
|
|
26
|
+
ca: "Un correu electrònic flipant per a %{name}"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
fill_in_i18n_editor(
|
|
30
|
+
:newsletter_settings_body,
|
|
31
|
+
"#newsletter-settings--body-tabs",
|
|
32
|
+
en: "Hello %{name}! Relevant content.",
|
|
33
|
+
es: "Hola, %{name}! Contenido relevante.",
|
|
34
|
+
ca: "Hola, %{name}! Contingut rellevant."
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
find("*[type=submit]").click
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context "when creating and previewing a newsletter" do
|
|
41
|
+
it "allows a newsletter to be created" do
|
|
42
|
+
visit decidim_admin.newsletters_path
|
|
43
|
+
|
|
44
|
+
within ".secondary-nav" do
|
|
45
|
+
find(".button.new").click
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
within "#basic_only_text .card-footer" do
|
|
49
|
+
click_link("Use this template")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
within "#new_newsletter_" do
|
|
53
|
+
fill_newsletter_form
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
expect(page).to have_content("Preview")
|
|
57
|
+
expect(page).to have_content("A fancy newsletter for #{department_admin.name}")
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
context "with existing newsletter" do
|
|
62
|
+
let!(:newsletter) do
|
|
63
|
+
create(:newsletter,
|
|
64
|
+
organization: organization,
|
|
65
|
+
subject: {
|
|
66
|
+
en: "A fancy newsletter for %{name}",
|
|
67
|
+
es: "Un correo electrónico muy chulo para %{name}",
|
|
68
|
+
ca: "Un correu electrònic flipant per a %{name}",
|
|
69
|
+
},
|
|
70
|
+
body: {
|
|
71
|
+
en: "Hello %{name}! Relevant content.",
|
|
72
|
+
es: "Hola, %{name}! Contenido relevante.",
|
|
73
|
+
ca: "Hola, %{name}! Contingut rellevant.",
|
|
74
|
+
},
|
|
75
|
+
author: department_admin)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "previews a newsletter" do
|
|
79
|
+
visit decidim_admin.newsletter_path(newsletter)
|
|
80
|
+
|
|
81
|
+
expect(page).to have_content("A fancy newsletter for Sarah Kerrigan")
|
|
82
|
+
expect(page).to have_css("iframe.email-preview[src=\"#{decidim_admin.preview_newsletter_path(newsletter)}\"]")
|
|
83
|
+
|
|
84
|
+
visit decidim_admin.preview_newsletter_path(newsletter)
|
|
85
|
+
expect(page).to have_content("Hello Sarah Kerrigan! Relevant content.")
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
context "when updating the newsletter" do
|
|
90
|
+
let!(:newsletter) { create(:newsletter, organization: organization, author: department_admin) }
|
|
91
|
+
|
|
92
|
+
it "allows a newsletter to be updated" do
|
|
93
|
+
visit decidim_admin.newsletters_path
|
|
94
|
+
within("tr[data-newsletter-id=\"#{newsletter.id}\"]") do
|
|
95
|
+
click_link "Edit"
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
within ".edit_newsletter" do
|
|
99
|
+
fill_newsletter_form
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
expect(page).to have_content("Preview")
|
|
103
|
+
expect(page).to have_content("A fancy newsletter")
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
context "when selecting newsletter recipients" do
|
|
108
|
+
let!(:newsletter) { create(:newsletter, organization: organization, author: department_admin) }
|
|
109
|
+
|
|
110
|
+
context "when followers are selected" do
|
|
111
|
+
let!(:participatory_processes) { create_list(:participatory_process, 2, organization: organization, area: area) }
|
|
112
|
+
let!(:followers) do
|
|
113
|
+
deliverable_users.each do |follower|
|
|
114
|
+
create(:follow, followable: participatory_processes.first, user: follower)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "sends to followers" do
|
|
119
|
+
visit decidim_admin.select_recipients_to_deliver_newsletter_path(newsletter)
|
|
120
|
+
perform_enqueued_jobs do
|
|
121
|
+
within(".newsletter_deliver") do
|
|
122
|
+
check("Send to followers")
|
|
123
|
+
uncheck("Send to participants")
|
|
124
|
+
within ".participatory_processes-block" do
|
|
125
|
+
select translated(participatory_processes.first.title), from: :newsletter_participatory_space_types_participatory_processes__ids
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
within ".button--double" do
|
|
130
|
+
accept_confirm { find("*", text: "Deliver").click }
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
wait_redirect
|
|
134
|
+
expect(page).to have_content("Newsletters")
|
|
135
|
+
expect(page).to have_admin_callout("successfully")
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
within "tbody" do
|
|
139
|
+
expect(page).to have_content("5 / 5")
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
context "when participants are selected" do
|
|
145
|
+
let!(:participatory_process) { create(:participatory_process, organization: organization, area: area) }
|
|
146
|
+
let!(:component) { create(:dummy_component, organization: newsletter.organization, participatory_space: participatory_process) }
|
|
147
|
+
|
|
148
|
+
before do
|
|
149
|
+
deliverable_users.each do |participant|
|
|
150
|
+
create(:dummy_resource, component: component, author: participant, published_at: Time.current)
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it "sends to participants" do
|
|
155
|
+
visit decidim_admin.select_recipients_to_deliver_newsletter_path(newsletter)
|
|
156
|
+
perform_enqueued_jobs do
|
|
157
|
+
within(".newsletter_deliver") do
|
|
158
|
+
uncheck("Send to followers")
|
|
159
|
+
check("Send to participants")
|
|
160
|
+
within ".participatory_processes-block" do
|
|
161
|
+
select translated(component.participatory_space.title), from: :newsletter_participatory_space_types_participatory_processes__ids
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
within ".button--double" do
|
|
166
|
+
accept_confirm { find("*", text: "Deliver").click }
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
wait_redirect
|
|
170
|
+
expect(page).to have_content("Newsletters")
|
|
171
|
+
expect(page).to have_admin_callout("successfully")
|
|
172
|
+
expect(page).to have_content("Has been sent to")
|
|
173
|
+
within "tbody" do
|
|
174
|
+
expect(page).to have_content("5 / 5")
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
context "when selecting both followers and participants" do
|
|
181
|
+
let!(:participatory_process) { create(:participatory_process, organization: organization, area: area) }
|
|
182
|
+
let!(:component) { create(:dummy_component, organization: newsletter.organization, participatory_space: participatory_process) }
|
|
183
|
+
|
|
184
|
+
let!(:followers) do
|
|
185
|
+
deliverable_users.each do |follower|
|
|
186
|
+
create(:follow, followable: component.participatory_space, user: follower)
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
before do
|
|
191
|
+
deliverable_users.each do |participant|
|
|
192
|
+
create(:dummy_resource, component: component, author: participant, published_at: Time.current)
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it "sends to participants" do
|
|
197
|
+
visit decidim_admin.select_recipients_to_deliver_newsletter_path(newsletter)
|
|
198
|
+
perform_enqueued_jobs do
|
|
199
|
+
within(".newsletter_deliver") do
|
|
200
|
+
check("Send to followers")
|
|
201
|
+
check("Send to participants")
|
|
202
|
+
within ".participatory_processes-block" do
|
|
203
|
+
select translated(component.participatory_space.title), from: :newsletter_participatory_space_types_participatory_processes__ids
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
within ".button--double" do
|
|
208
|
+
accept_confirm { find("*", text: "Deliver").click }
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
wait_redirect
|
|
212
|
+
expect(page).to have_content("Newsletters")
|
|
213
|
+
expect(page).to have_admin_callout("successfully")
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
within "tbody" do
|
|
217
|
+
expect(page).to have_content("5 / 5")
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
context "when deleting a newsletter" do
|
|
224
|
+
let!(:newsletter) { create(:newsletter, organization: organization, author: department_admin) }
|
|
225
|
+
|
|
226
|
+
it "deletes a newsletter" do
|
|
227
|
+
visit decidim_admin.newsletters_path
|
|
228
|
+
|
|
229
|
+
within("tr[data-newsletter-id=\"#{newsletter.id}\"]") do
|
|
230
|
+
accept_confirm { click_link "Delete" }
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
expect(page).to have_content("successfully")
|
|
234
|
+
expect(page).to have_no_css("tr[data-newsletter-id=\"#{newsletter.id}\"]")
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Department admin should be able to access Admin Dashboard", type: :system do
|
|
6
|
+
let(:organization) { create(:organization) }
|
|
7
|
+
let(:area) { create(:area) }
|
|
8
|
+
let(:department_admin) { create(:department_admin, :confirmed, organization: organization, area: area, accepted_tos_version: Time.current) }
|
|
9
|
+
let!(:process) { create(:participatory_process, :published, organization: organization, area: area) }
|
|
10
|
+
|
|
11
|
+
before do
|
|
12
|
+
switch_to_host(organization.host)
|
|
13
|
+
login_as department_admin, scope: :user
|
|
14
|
+
visit decidim_admin.root_path
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "is able to access the admin Dashboard" do
|
|
18
|
+
expect(page).to have_content("Dashboard")
|
|
19
|
+
expect(page).to have_content("Welcome to the Admin Panel.")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context "when accessing the dashboard some left menu elements should be accessible" do
|
|
23
|
+
it "is able to access 'Processes'" do
|
|
24
|
+
expect(page).to have_content("Processes")
|
|
25
|
+
click_link "Processes"
|
|
26
|
+
expect(page).to have_current_path "/admin/participatory_processes"
|
|
27
|
+
expect(page).to have_content("Participatory processes")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "is able to access 'Assemblies'" do
|
|
31
|
+
expect(page).to have_content("Assemblies")
|
|
32
|
+
click_link "Assemblies"
|
|
33
|
+
expect(page).to have_current_path "/admin/assemblies"
|
|
34
|
+
expect(page).to have_content("New assembly")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "is able to access 'Participants'" do
|
|
38
|
+
expect(page).to have_content("Participants")
|
|
39
|
+
click_link "Participants"
|
|
40
|
+
expect(page).to have_current_path "/admin/users"
|
|
41
|
+
expect(page).to have_content("New admin")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "is able to access 'Newsletter'" do
|
|
45
|
+
expect(page).to have_content("Newsletter")
|
|
46
|
+
click_link "Newsletter"
|
|
47
|
+
expect(page).to have_current_path "/admin/newsletters"
|
|
48
|
+
expect(page).to have_content("New newsletter")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "is able to access 'Conferences'" do
|
|
52
|
+
expect(page).to have_content("Conferences")
|
|
53
|
+
click_link "Conferences"
|
|
54
|
+
expect(page).to have_current_path "/admin/conferences"
|
|
55
|
+
expect(page).to have_content("New Conference")
|
|
56
|
+
end
|
|
57
|
+
# TODO: not supported at the moment
|
|
58
|
+
# it "should be able to access 'Initiatives'"
|
|
59
|
+
# it "should be able to access 'Consultations'"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
context "when accessing the dashboard some left menu elements should NOT be accessible" do
|
|
63
|
+
it "is not able to access 'Pages'" do
|
|
64
|
+
expect(page).not_to have_content("Pages")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "is not able to access 'Settings'" do
|
|
68
|
+
expect(page).not_to have_content("Settings")
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "is not able to access 'Admin Activity Log'" do
|
|
72
|
+
expect(page).not_to have_content("Admin activity log")
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Admin manages assemblies", versioning: true, type: :system do
|
|
6
|
+
let(:organization) { create(:organization) }
|
|
7
|
+
let(:area) { create(:area, organization: organization) }
|
|
8
|
+
let(:department_admin) { create(:department_admin, :confirmed, organization: organization, area: area) }
|
|
9
|
+
|
|
10
|
+
before do
|
|
11
|
+
switch_to_host(organization.host)
|
|
12
|
+
login_as department_admin, scope: :user
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
shared_examples "creating an assembly" do
|
|
16
|
+
let(:image1_filename) { "city.jpeg" }
|
|
17
|
+
let(:image1_path) { Decidim::Dev.asset(image1_filename) }
|
|
18
|
+
|
|
19
|
+
let(:image2_filename) { "city2.jpeg" }
|
|
20
|
+
let(:image2_path) { Decidim::Dev.asset(image2_filename) }
|
|
21
|
+
let(:attributes) { attributes_for(:assembly, organization: organization) }
|
|
22
|
+
|
|
23
|
+
before do
|
|
24
|
+
visit decidim_admin_assemblies.assemblies_path
|
|
25
|
+
click_link "New assembly"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "creates a new assembly" do
|
|
29
|
+
within ".new_assembly" do
|
|
30
|
+
fill_in_i18n(:assembly_title, "#assembly-title-tabs", **attributes[:title].except("machine_translations"))
|
|
31
|
+
fill_in_i18n(:assembly_subtitle, "#assembly-subtitle-tabs", **attributes[:subtitle].except("machine_translations"))
|
|
32
|
+
fill_in_i18n_editor(:assembly_short_description, "#assembly-short_description-tabs", **attributes[:short_description].except("machine_translations"))
|
|
33
|
+
fill_in_i18n_editor(:assembly_description, "#assembly-description-tabs", **attributes[:description].except("machine_translations"))
|
|
34
|
+
fill_in_i18n_editor(:assembly_purpose_of_action, "#assembly-purpose_of_action-tabs", **attributes[:purpose_of_action].except("machine_translations"))
|
|
35
|
+
fill_in_i18n_editor(:assembly_composition, "#assembly-composition-tabs", **attributes[:composition].except("machine_translations"))
|
|
36
|
+
fill_in_i18n_editor(:assembly_internal_organisation, "#assembly-internal_organisation-tabs", **attributes[:internal_organisation].except("machine_translations"))
|
|
37
|
+
fill_in_i18n_editor(:assembly_announcement, "#assembly-announcement-tabs", **attributes[:announcement].except("machine_translations"))
|
|
38
|
+
fill_in_i18n_editor(:assembly_closing_date_reason, "#assembly-closing_date_reason-tabs", **attributes[:closing_date_reason].except("machine_translations"))
|
|
39
|
+
|
|
40
|
+
fill_in_i18n(:assembly_participatory_scope, "#assembly-participatory_scope-tabs", **attributes[:participatory_scope].except("machine_translations"))
|
|
41
|
+
fill_in_i18n(:assembly_participatory_structure, "#assembly-participatory_structure-tabs", **attributes[:participatory_structure].except("machine_translations"))
|
|
42
|
+
fill_in_i18n(:assembly_meta_scope, "#assembly-meta_scope-tabs", **attributes[:meta_scope].except("machine_translations"))
|
|
43
|
+
fill_in_i18n(:assembly_local_area, "#assembly-local_area-tabs", **attributes[:local_area].except("machine_translations"))
|
|
44
|
+
fill_in_i18n(:assembly_target, "#assembly-target-tabs", **attributes[:target].except("machine_translations"))
|
|
45
|
+
|
|
46
|
+
fill_in :assembly_slug, with: "slug"
|
|
47
|
+
fill_in :assembly_hashtag, with: "#hashtag"
|
|
48
|
+
fill_in :assembly_weight, with: 1
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
dynamically_attach_file(:assembly_hero_image, image1_path)
|
|
52
|
+
dynamically_attach_file(:assembly_banner_image, image2_path)
|
|
53
|
+
|
|
54
|
+
within ".new_assembly" do
|
|
55
|
+
find("*[type=submit]").click
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
expect(page).to have_admin_callout("successfully")
|
|
59
|
+
expect(Decidim::Assembly.last.area).to eq(area)
|
|
60
|
+
|
|
61
|
+
within ".container" do
|
|
62
|
+
# expect(page).to have_current_path decidim_admin_assemblies.assemblies_path(q: { parent_id_eq: parent_assembly&.id })
|
|
63
|
+
expect(page).to have_content(translated(attributes[:title]))
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context "when managing parent assemblies" do
|
|
69
|
+
let(:parent_assembly) { nil }
|
|
70
|
+
let!(:assembly) { create :assembly, organization: organization }
|
|
71
|
+
|
|
72
|
+
before do
|
|
73
|
+
switch_to_host(organization.host)
|
|
74
|
+
login_as department_admin, scope: :user
|
|
75
|
+
visit decidim_admin_assemblies.assemblies_path
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# it_behaves_like "manage assemblies"
|
|
79
|
+
it_behaves_like "creating an assembly"
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
context "when managing child assemblies" do
|
|
83
|
+
let!(:parent_assembly) { create :assembly, organization: organization, area: area }
|
|
84
|
+
let!(:child_assembly) { create :assembly, organization: organization, parent: parent_assembly, area: area }
|
|
85
|
+
let(:assembly) { child_assembly }
|
|
86
|
+
|
|
87
|
+
before do
|
|
88
|
+
switch_to_host(organization.host)
|
|
89
|
+
login_as department_admin, scope: :user
|
|
90
|
+
visit decidim_admin_assemblies.assemblies_path
|
|
91
|
+
within find("tr", text: translated(parent_assembly.title)) do
|
|
92
|
+
click_link "Assemblies"
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# it_behaves_like "manage assemblies"
|
|
97
|
+
it_behaves_like "creating an assembly"
|
|
98
|
+
end
|
|
99
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Admin manages conferences", versioning: true, type: :system do
|
|
6
|
+
let(:organization) { create(:organization) }
|
|
7
|
+
let(:area) { create(:area, organization: organization) }
|
|
8
|
+
let(:department_admin) { create(:department_admin, :confirmed, organization: organization, area: area) }
|
|
9
|
+
|
|
10
|
+
before do
|
|
11
|
+
switch_to_host(organization.host)
|
|
12
|
+
login_as department_admin, scope: :user
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
shared_examples "creating an conference" do
|
|
16
|
+
let(:image1_filename) { "city.jpeg" }
|
|
17
|
+
let(:image1_path) { Decidim::Dev.asset(image1_filename) }
|
|
18
|
+
|
|
19
|
+
let(:image2_filename) { "city2.jpeg" }
|
|
20
|
+
let(:image2_path) { Decidim::Dev.asset(image2_filename) }
|
|
21
|
+
|
|
22
|
+
before do
|
|
23
|
+
visit decidim_admin_conferences.assemblies_path
|
|
24
|
+
click_link "New conference"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "creates a new conference" do
|
|
28
|
+
within ".new_conference" do
|
|
29
|
+
fill_in_i18n(
|
|
30
|
+
:conference_title,
|
|
31
|
+
"#conference-title-tabs",
|
|
32
|
+
en: "My conference",
|
|
33
|
+
es: "Mi conferencia",
|
|
34
|
+
ca: "Mi jornada"
|
|
35
|
+
)
|
|
36
|
+
fill_in_i18n(
|
|
37
|
+
:conference_subtitle,
|
|
38
|
+
"#conference-subtitle-tabs",
|
|
39
|
+
en: "Subtitle",
|
|
40
|
+
es: "Subtítulo",
|
|
41
|
+
ca: "Subtítol"
|
|
42
|
+
)
|
|
43
|
+
fill_in_i18n_editor(
|
|
44
|
+
:conference_short_description,
|
|
45
|
+
"#conference-short_description-tabs",
|
|
46
|
+
en: "Short description",
|
|
47
|
+
es: "Descripción corta",
|
|
48
|
+
ca: "Descripció curta"
|
|
49
|
+
)
|
|
50
|
+
fill_in_i18n_editor(
|
|
51
|
+
:conference_description,
|
|
52
|
+
"#conference-description-tabs",
|
|
53
|
+
en: "A longer description",
|
|
54
|
+
es: "Descripción más larga",
|
|
55
|
+
ca: "Descripció més llarga"
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
fill_in :conference_slug, with: "slug"
|
|
59
|
+
fill_in :conference_hashtag, with: "#hashtag"
|
|
60
|
+
attach_file :conference_hero_image, image1_path
|
|
61
|
+
attach_file :conference_banner_image, image2_path
|
|
62
|
+
|
|
63
|
+
find("*[type=submit]").click
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
expect(page).to have_admin_callout("successfully")
|
|
67
|
+
expect(Decidim::Conference.last.area).to eq(area)
|
|
68
|
+
|
|
69
|
+
within ".container" do
|
|
70
|
+
expect(page).to have_content("My conference")
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|