From c4554d72e4e201ee6d4c67fdaea80e1c5c11d2c4 Mon Sep 17 00:00:00 2001
From: antopalidi
Date: Fri, 16 Sep 2022 11:17:31 +0200
Subject: [PATCH 01/10] improve email: add link to admin of the resource
---
decidim-core/app/mailers/decidim/reported_mailer.rb | 8 +++++++-
.../app/views/decidim/reported_mailer/report.html.erb | 2 +-
decidim-core/config/locales/en.yml | 1 +
decidim-core/spec/mailers/reported_mailer_spec.rb | 4 ++++
4 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/decidim-core/app/mailers/decidim/reported_mailer.rb b/decidim-core/app/mailers/decidim/reported_mailer.rb
index f0d96b8a5de0a..f4522ee7527b6 100644
--- a/decidim-core/app/mailers/decidim/reported_mailer.rb
+++ b/decidim-core/app/mailers/decidim/reported_mailer.rb
@@ -5,8 +5,10 @@ module Decidim
class ReportedMailer < Decidim::ApplicationMailer
helper Decidim::ResourceHelper
helper Decidim::TranslationsHelper
+ helper Decidim::ComponentPathHelper
- helper_method :reported_content_url, :report_url, :manage_moderations_url, :author_profile_url, :reported_content_cell
+ helper_method :reported_content_url, :report_url, :manage_moderations_url, :author_profile_url,
+ :reported_content_cell, :proposal_component_url
def report(user, report)
with_user(user) do
@@ -48,6 +50,10 @@ def report_url
@report_url ||= EngineRouter.admin_proxy(@participatory_space).moderation_report_url(host: @organization.host, moderation_id: @report.moderation.id, id: @report.id)
end
+ def proposal_component_url
+ @proposal_component_url ||= EngineRouter.admin_proxy(@reportable.component).proposal_url(@reportable)
+ end
+
def manage_moderations_url
@manage_moderations_url ||= EngineRouter.admin_proxy(@participatory_space).moderations_url(host: @organization.host)
end
diff --git a/decidim-core/app/views/decidim/reported_mailer/report.html.erb b/decidim-core/app/views/decidim/reported_mailer/report.html.erb
index 009a570c87ceb..f398c46335dbe 100644
--- a/decidim-core/app/views/decidim/reported_mailer/report.html.erb
+++ b/decidim-core/app/views/decidim/reported_mailer/report.html.erb
@@ -4,7 +4,7 @@
<%= t(".report_html", { url: reported_content_url }) %>
-
+<%= link_to t('.admin_resource'), proposal_component_url, target: '_blank' %>
<%= t(".date") %>
<%= l @report.created_at, format: :short %>
diff --git a/decidim-core/config/locales/en.yml b/decidim-core/config/locales/en.yml
index 705d88a8abafb..0923a336b0df4 100644
--- a/decidim-core/config/locales/en.yml
+++ b/decidim-core/config/locales/en.yml
@@ -1223,6 +1223,7 @@ en:
report_html: The following content has been hidden automatically.
subject: A resource has been hidden automatically
report:
+ admin_resource: Admin of this resource
authors: Authors
content: Reported content
content_original_language: Content original language
diff --git a/decidim-core/spec/mailers/reported_mailer_spec.rb b/decidim-core/spec/mailers/reported_mailer_spec.rb
index f42db242b8f96..b8ff7f9cc8d9b 100644
--- a/decidim-core/spec/mailers/reported_mailer_spec.rb
+++ b/decidim-core/spec/mailers/reported_mailer_spec.rb
@@ -31,6 +31,10 @@ module Decidim
expect(email_body(mail)).to match(moderation.participatory_space.title["en"])
end
+ it "includes link to admin this resource" do
+ expect(email_body(mail)).to have_link(href: EngineRouter.admin_proxy(reportable.component).proposal_url(reportable))
+ end
+
it "includes the report's reason" do
expect(email_body(mail)).to match(I18n.t(report.reason, scope: "decidim.shared.flag_modal"))
end
From f7fbedb2e73542f552ad5219e251f671f77ba487 Mon Sep 17 00:00:00 2001
From: antopalidi
Date: Fri, 16 Sep 2022 11:27:31 +0200
Subject: [PATCH 02/10] change translate
---
decidim-core/config/locales/en.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/decidim-core/config/locales/en.yml b/decidim-core/config/locales/en.yml
index 0923a336b0df4..4c8fe994319ff 100644
--- a/decidim-core/config/locales/en.yml
+++ b/decidim-core/config/locales/en.yml
@@ -1223,7 +1223,7 @@ en:
report_html: The following content has been hidden automatically.
subject: A resource has been hidden automatically
report:
- admin_resource: Admin of this resource
+ admin_resource: Admin this resource
authors: Authors
content: Reported content
content_original_language: Content original language
From 4ffa7100e701ac97fb279c33474727ffcaf872ec Mon Sep 17 00:00:00 2001
From: antopalidi
Date: Fri, 16 Sep 2022 11:43:57 +0200
Subject: [PATCH 03/10] fix lint
---
decidim-core/app/views/decidim/reported_mailer/report.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/decidim-core/app/views/decidim/reported_mailer/report.html.erb b/decidim-core/app/views/decidim/reported_mailer/report.html.erb
index f398c46335dbe..1ee187d5db414 100644
--- a/decidim-core/app/views/decidim/reported_mailer/report.html.erb
+++ b/decidim-core/app/views/decidim/reported_mailer/report.html.erb
@@ -4,7 +4,7 @@
<%= t(".report_html", { url: reported_content_url }) %>
-<%= link_to t('.admin_resource'), proposal_component_url, target: '_blank' %>
+<%= link_to t(".admin_resource"), proposal_component_url, target: '_blank' %>
<%= t(".date") %>
<%= l @report.created_at, format: :short %>
From 083d2793006edad23293bf8a0076130f2fef22cb Mon Sep 17 00:00:00 2001
From: antopalidi
Date: Fri, 16 Sep 2022 12:10:39 +0200
Subject: [PATCH 04/10] fix lint
---
decidim-core/app/views/decidim/reported_mailer/report.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/decidim-core/app/views/decidim/reported_mailer/report.html.erb b/decidim-core/app/views/decidim/reported_mailer/report.html.erb
index 1ee187d5db414..0109f0ce8b7ba 100644
--- a/decidim-core/app/views/decidim/reported_mailer/report.html.erb
+++ b/decidim-core/app/views/decidim/reported_mailer/report.html.erb
@@ -4,7 +4,7 @@
<%= t(".report_html", { url: reported_content_url }) %>
-<%= link_to t(".admin_resource"), proposal_component_url, target: '_blank' %>
+<%= link_to t(".admin_resource"), proposal_component_url, target: "_blank" %>
<%= t(".date") %>
<%= l @report.created_at, format: :short %>
From c343093839e44cea8f581d46660584940993e491 Mon Sep 17 00:00:00 2001
From: antopalidi
Date: Fri, 16 Sep 2022 15:51:56 +0200
Subject: [PATCH 05/10] refactoring: improve the ResourceLocatorPresenter
---
decidim-core/app/mailers/decidim/reported_mailer.rb | 6 +++---
.../presenters/decidim/resource_locator_presenter.rb | 10 ++++++++++
.../app/views/decidim/reported_mailer/report.html.erb | 2 +-
decidim-core/spec/mailers/reported_mailer_spec.rb | 2 +-
4 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/decidim-core/app/mailers/decidim/reported_mailer.rb b/decidim-core/app/mailers/decidim/reported_mailer.rb
index f4522ee7527b6..8c161e4165080 100644
--- a/decidim-core/app/mailers/decidim/reported_mailer.rb
+++ b/decidim-core/app/mailers/decidim/reported_mailer.rb
@@ -8,7 +8,7 @@ class ReportedMailer < Decidim::ApplicationMailer
helper Decidim::ComponentPathHelper
helper_method :reported_content_url, :report_url, :manage_moderations_url, :author_profile_url,
- :reported_content_cell, :proposal_component_url
+ :reported_content_cell, :resource_admin_url
def report(user, report)
with_user(user) do
@@ -50,8 +50,8 @@ def report_url
@report_url ||= EngineRouter.admin_proxy(@participatory_space).moderation_report_url(host: @organization.host, moderation_id: @report.moderation.id, id: @report.id)
end
- def proposal_component_url
- @proposal_component_url ||= EngineRouter.admin_proxy(@reportable.component).proposal_url(@reportable)
+ def resource_admin_url
+ @resource_admin_url ||= Decidim::ResourceLocatorPresenter.new(@reportable).admin_url
end
def manage_moderations_url
diff --git a/decidim-core/app/presenters/decidim/resource_locator_presenter.rb b/decidim-core/app/presenters/decidim/resource_locator_presenter.rb
index 5379f345454d0..a08fece479e11 100644
--- a/decidim-core/app/presenters/decidim/resource_locator_presenter.rb
+++ b/decidim-core/app/presenters/decidim/resource_locator_presenter.rb
@@ -70,6 +70,16 @@ def edit(options = {})
admin_route_proxy.send("edit_#{member_route_name}_path", target, options)
end
+ def admin_url(options = {})
+ admin_member_route("url", options.merge(host: root_resource.organization.host))
+ end
+
+ def admin_member_route(route_type, options)
+ options.merge!(options_for_polymorphic)
+
+ admin_route_proxy.send("#{member_route_name}_#{route_type}", target, options)
+ end
+
private
def polymorphic?
diff --git a/decidim-core/app/views/decidim/reported_mailer/report.html.erb b/decidim-core/app/views/decidim/reported_mailer/report.html.erb
index 0109f0ce8b7ba..970f307d5790c 100644
--- a/decidim-core/app/views/decidim/reported_mailer/report.html.erb
+++ b/decidim-core/app/views/decidim/reported_mailer/report.html.erb
@@ -4,7 +4,7 @@
<%= t(".report_html", { url: reported_content_url }) %>
-<%= link_to t(".admin_resource"), proposal_component_url, target: "_blank" %>
+<%= link_to t(".admin_resource"), resource_admin_url, target: "_blank" %>
<%= t(".date") %>
<%= l @report.created_at, format: :short %>
diff --git a/decidim-core/spec/mailers/reported_mailer_spec.rb b/decidim-core/spec/mailers/reported_mailer_spec.rb
index b8ff7f9cc8d9b..6635d444ef873 100644
--- a/decidim-core/spec/mailers/reported_mailer_spec.rb
+++ b/decidim-core/spec/mailers/reported_mailer_spec.rb
@@ -32,7 +32,7 @@ module Decidim
end
it "includes link to admin this resource" do
- expect(email_body(mail)).to have_link(href: EngineRouter.admin_proxy(reportable.component).proposal_url(reportable))
+ expect(email_body(mail)).to have_link(href: Decidim::ResourceLocatorPresenter.new(reportable).admin_url)
end
it "includes the report's reason" do
From a9ac28f281363017b85d55f300282bb91e914260 Mon Sep 17 00:00:00 2001
From: antopalidi
Date: Fri, 16 Sep 2022 16:06:39 +0200
Subject: [PATCH 06/10] move the method to private
---
.../presenters/decidim/resource_locator_presenter.rb | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/decidim-core/app/presenters/decidim/resource_locator_presenter.rb b/decidim-core/app/presenters/decidim/resource_locator_presenter.rb
index a08fece479e11..bdc1c5216e89e 100644
--- a/decidim-core/app/presenters/decidim/resource_locator_presenter.rb
+++ b/decidim-core/app/presenters/decidim/resource_locator_presenter.rb
@@ -74,12 +74,6 @@ def admin_url(options = {})
admin_member_route("url", options.merge(host: root_resource.organization.host))
end
- def admin_member_route(route_type, options)
- options.merge!(options_for_polymorphic)
-
- admin_route_proxy.send("#{member_route_name}_#{route_type}", target, options)
- end
-
private
def polymorphic?
@@ -171,5 +165,11 @@ def route_proxy
def admin_route_proxy
@admin_route_proxy ||= EngineRouter.admin_proxy(component || target)
end
+
+ def admin_member_route(route_type, options)
+ options.merge!(options_for_polymorphic)
+
+ admin_route_proxy.send("#{member_route_name}_#{route_type}", target, options)
+ end
end
end
From 631c4b7163625d3f4a491f5e149c92de2e8f9294 Mon Sep 17 00:00:00 2001
From: antopalidi
Date: Fri, 16 Sep 2022 16:27:40 +0200
Subject: [PATCH 07/10] add tests #admin_url
---
.../decidim/resource_locator_presenter_spec.rb | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/decidim-core/spec/presenters/decidim/resource_locator_presenter_spec.rb b/decidim-core/spec/presenters/decidim/resource_locator_presenter_spec.rb
index d3c31da54c6cb..ec4074e2c1067 100644
--- a/decidim-core/spec/presenters/decidim/resource_locator_presenter_spec.rb
+++ b/decidim-core/spec/presenters/decidim/resource_locator_presenter_spec.rb
@@ -52,6 +52,12 @@ module Decidim
it { is_expected.to start_with("/admin/participatory_processes/my-process/edit") }
end
+
+ describe "#admin_url" do
+ subject { described_class.new(resource).admin_url }
+
+ it { is_expected.to eq("http://1.lvh.me/admin/participatory_processes/my-process/components/1/manage/dummy_resources/1") }
+ end
end
context "with a polymorphic resource" do
@@ -104,6 +110,12 @@ module Decidim
it { is_expected.to start_with("/admin/participatory_processes/my-process/components/1/manage/dummy_resources/1/nested_dummy_resources/1/edit") }
end
+
+ describe "#admin_url" do
+ subject { described_class.new([resource, nested_resource]).admin_url }
+
+ it { is_expected.to eq("http://1.lvh.me/admin/participatory_processes/my-process/components/1/manage/dummy_resources/1/nested_dummy_resources/1") }
+ end
end
context "with a participatory_space" do
@@ -118,6 +130,12 @@ module Decidim
it { is_expected.to start_with("/processes/my-process") }
end
+
+ describe "#admin_url" do
+ subject { described_class.new(participatory_process).admin_url }
+
+ it { is_expected.to start_with("http://1.lvh.me/admin/participatory_processes/my-process") }
+ end
end
end
end
From 4810753f1eaa5f5a33ed3575056dfa5bf789c86c Mon Sep 17 00:00:00 2001
From: antopalidi
Date: Mon, 19 Sep 2022 19:00:15 +0200
Subject: [PATCH 08/10] add: resource without a admin url
---
.../decidim/resource_locator_presenter.rb | 15 ++++++++++++++-
.../views/decidim/reported_mailer/report.html.erb | 4 +++-
decidim-core/lib/decidim/resource_manifest.rb | 9 +++++++++
decidim-core/spec/mailers/reported_mailer_spec.rb | 9 +++++++++
.../lib/decidim/proposals/component.rb | 1 +
5 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/decidim-core/app/presenters/decidim/resource_locator_presenter.rb b/decidim-core/app/presenters/decidim/resource_locator_presenter.rb
index bdc1c5216e89e..176822f554a5a 100644
--- a/decidim-core/app/presenters/decidim/resource_locator_presenter.rb
+++ b/decidim-core/app/presenters/decidim/resource_locator_presenter.rb
@@ -168,8 +168,21 @@ def admin_route_proxy
def admin_member_route(route_type, options)
options.merge!(options_for_polymorphic)
+ admin_route_proxy.send("#{admin_member_route_name}_#{route_type}", target, options)
+ end
+
+ def admin_member_route_name
+ if polymorphic?
+ admin_polymorphic_member_route_name
+ else
+ manifest_for(target).admin_route_name
+ end
+ end
+
+ def admin_polymorphic_member_route_name
+ return unless polymorphic?
- admin_route_proxy.send("#{member_route_name}_#{route_type}", target, options)
+ resource.map { |record| manifest_for(record).admin_route_name }.join("_")
end
end
end
diff --git a/decidim-core/app/views/decidim/reported_mailer/report.html.erb b/decidim-core/app/views/decidim/reported_mailer/report.html.erb
index 970f307d5790c..90463f2d0ee6a 100644
--- a/decidim-core/app/views/decidim/reported_mailer/report.html.erb
+++ b/decidim-core/app/views/decidim/reported_mailer/report.html.erb
@@ -4,7 +4,9 @@
<%= t(".report_html", { url: reported_content_url }) %>
-<%= link_to t(".admin_resource"), resource_admin_url, target: "_blank" %>
+<% if resource_admin_url.present? %>
+ <%= link_to t(".admin_resource"), resource_admin_url, target: "_blank" %>
+<% end %>
<%= t(".date") %>
<%= l @report.created_at, format: :short %>
diff --git a/decidim-core/lib/decidim/resource_manifest.rb b/decidim-core/lib/decidim/resource_manifest.rb
index a289652eb319f..8306cff52da52 100644
--- a/decidim-core/lib/decidim/resource_manifest.rb
+++ b/decidim-core/lib/decidim/resource_manifest.rb
@@ -30,6 +30,8 @@ class ResourceManifest
# When not explicitly set, it will use the model name.
attribute :route_name, String
+ attribute :admin_route_name, String
+
# The template to use to render the collection of the resource.
attribute :template, String
@@ -99,5 +101,12 @@ def permissions_class
def route_name
super || model_class_name.demodulize.underscore
end
+
+ # The name of the named Rails route to create the url to the admin resource.
+ #
+ # Returns a String.
+ def admin_route_name
+ super || model_class_name.demodulize.underscore
+ end
end
end
diff --git a/decidim-core/spec/mailers/reported_mailer_spec.rb b/decidim-core/spec/mailers/reported_mailer_spec.rb
index 6635d444ef873..befa207eed1d6 100644
--- a/decidim-core/spec/mailers/reported_mailer_spec.rb
+++ b/decidim-core/spec/mailers/reported_mailer_spec.rb
@@ -35,6 +35,15 @@ module Decidim
expect(email_body(mail)).to have_link(href: Decidim::ResourceLocatorPresenter.new(reportable).admin_url)
end
+ context "when the reported content is a resource without a admin url " do
+ let(:meetings_component) { create :component, manifest_name: "meetings" }
+ let(:meeting) { create :meeting, component: meetings_component }
+
+ it " doesn't have the admin url" do
+ expect(email_body(mail)).not_to have_link(href: Decidim::ResourceLocatorPresenter.new(meeting).admin_url)
+ end
+ end
+
it "includes the report's reason" do
expect(email_body(mail)).to match(I18n.t(report.reason, scope: "decidim.shared.flag_modal"))
end
diff --git a/decidim-proposals/lib/decidim/proposals/component.rb b/decidim-proposals/lib/decidim/proposals/component.rb
index ea39e57c3d224..97fee44e01106 100644
--- a/decidim-proposals/lib/decidim/proposals/component.rb
+++ b/decidim-proposals/lib/decidim/proposals/component.rb
@@ -89,6 +89,7 @@
resource.reported_content_cell = "decidim/proposals/reported_content"
resource.actions = %w(endorse vote amend comment vote_comment)
resource.searchable = true
+ resource.admin_route_name = "proposal"
end
component.register_resource(:collaborative_draft) do |resource|
From 9460db0d01eb78ec0c422e5fac9808809b6f78e1 Mon Sep 17 00:00:00 2001
From: antopalidi
Date: Tue, 20 Sep 2022 08:59:06 +0200
Subject: [PATCH 09/10] fix test'
---
decidim-core/spec/mailers/reported_mailer_spec.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/decidim-core/spec/mailers/reported_mailer_spec.rb b/decidim-core/spec/mailers/reported_mailer_spec.rb
index befa207eed1d6..3d5d885192c72 100644
--- a/decidim-core/spec/mailers/reported_mailer_spec.rb
+++ b/decidim-core/spec/mailers/reported_mailer_spec.rb
@@ -38,8 +38,9 @@ module Decidim
context "when the reported content is a resource without a admin url " do
let(:meetings_component) { create :component, manifest_name: "meetings" }
let(:meeting) { create :meeting, component: meetings_component }
+ let(:moderation) { create(:moderation, reportable: meeting, participatory_space: meetings_component.participatory_space, report_count: 1) }
- it " doesn't have the admin url" do
+ it "doesn't have the admin url" do
expect(email_body(mail)).not_to have_link(href: Decidim::ResourceLocatorPresenter.new(meeting).admin_url)
end
end
From e2e95848a0157d17032004ba9c7ea68ada97eb1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ivan=20Verg=C3=A9s?=
Date: Tue, 20 Sep 2022 11:49:57 +0200
Subject: [PATCH 10/10] fix detecting admin route name
---
.../decidim/resource_locator_presenter.rb | 5 ++-
decidim-core/lib/decidim/resource_manifest.rb | 10 ++----
.../resource_locator_presenter_spec.rb | 31 +++++++++++++++++--
3 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/decidim-core/app/presenters/decidim/resource_locator_presenter.rb b/decidim-core/app/presenters/decidim/resource_locator_presenter.rb
index 176822f554a5a..b0b08944c8d39 100644
--- a/decidim-core/app/presenters/decidim/resource_locator_presenter.rb
+++ b/decidim-core/app/presenters/decidim/resource_locator_presenter.rb
@@ -66,10 +66,11 @@ def show(options = {})
# Returns a String.
def edit(options = {})
options.merge!(options_for_polymorphic)
-
admin_route_proxy.send("edit_#{member_route_name}_path", target, options)
end
+ # Generates and admin url only if the manifest has the property :admin_route_name defined
+ # this allows to distinct from resources that can be administrated from those that are not
def admin_url(options = {})
admin_member_route("url", options.merge(host: root_resource.organization.host))
end
@@ -167,6 +168,8 @@ def admin_route_proxy
end
def admin_member_route(route_type, options)
+ return if manifest_for(target).admin_route_name.blank?
+
options.merge!(options_for_polymorphic)
admin_route_proxy.send("#{admin_member_route_name}_#{route_type}", target, options)
end
diff --git a/decidim-core/lib/decidim/resource_manifest.rb b/decidim-core/lib/decidim/resource_manifest.rb
index 8306cff52da52..c3411fb60d93b 100644
--- a/decidim-core/lib/decidim/resource_manifest.rb
+++ b/decidim-core/lib/decidim/resource_manifest.rb
@@ -30,6 +30,9 @@ class ResourceManifest
# When not explicitly set, it will use the model name.
attribute :route_name, String
+ # The name of the named Rails route to create the url to admin the resource
+ # If it is not defined, the resource will be considered non-administrable
+ # and no link will be generated in some places
attribute :admin_route_name, String
# The template to use to render the collection of the resource.
@@ -101,12 +104,5 @@ def permissions_class
def route_name
super || model_class_name.demodulize.underscore
end
-
- # The name of the named Rails route to create the url to the admin resource.
- #
- # Returns a String.
- def admin_route_name
- super || model_class_name.demodulize.underscore
- end
end
end
diff --git a/decidim-core/spec/presenters/decidim/resource_locator_presenter_spec.rb b/decidim-core/spec/presenters/decidim/resource_locator_presenter_spec.rb
index ec4074e2c1067..85917c1213491 100644
--- a/decidim-core/spec/presenters/decidim/resource_locator_presenter_spec.rb
+++ b/decidim-core/spec/presenters/decidim/resource_locator_presenter_spec.rb
@@ -56,7 +56,15 @@ module Decidim
describe "#admin_url" do
subject { described_class.new(resource).admin_url }
- it { is_expected.to eq("http://1.lvh.me/admin/participatory_processes/my-process/components/1/manage/dummy_resources/1") }
+ it { is_expected.to be_nil }
+
+ context "when admin_route_name is defined" do
+ before do
+ allow(resource.resource_manifest).to receive(:admin_route_name).and_return("dummy_resource")
+ end
+
+ it { is_expected.to eq("http://1.lvh.me/admin/participatory_processes/my-process/components/1/manage/dummy_resources/1") }
+ end
end
end
@@ -114,7 +122,16 @@ module Decidim
describe "#admin_url" do
subject { described_class.new([resource, nested_resource]).admin_url }
- it { is_expected.to eq("http://1.lvh.me/admin/participatory_processes/my-process/components/1/manage/dummy_resources/1/nested_dummy_resources/1") }
+ it { is_expected.to be_nil }
+
+ context "when admin_route_name is defined" do
+ before do
+ allow(resource.resource_manifest).to receive(:admin_route_name).and_return("dummy_resource")
+ allow(nested_resource.resource_manifest).to receive(:admin_route_name).and_return("nested_dummy_resource")
+ end
+
+ it { is_expected.to eq("http://1.lvh.me/admin/participatory_processes/my-process/components/1/manage/dummy_resources/1/nested_dummy_resources/1") }
+ end
end
end
@@ -134,7 +151,15 @@ module Decidim
describe "#admin_url" do
subject { described_class.new(participatory_process).admin_url }
- it { is_expected.to start_with("http://1.lvh.me/admin/participatory_processes/my-process") }
+ it { is_expected.to be_nil }
+
+ context "when admin_route_name is defined" do
+ before do
+ allow(participatory_process.resource_manifest).to receive(:admin_route_name).and_return("participatory_process")
+ end
+
+ it { is_expected.to start_with("http://1.lvh.me/admin/participatory_processes/my-process") }
+ end
end
end
end