lib/decidim/admin/test/manage_moderations_examples.rb in decidim-admin-0.26.10 vs lib/decidim/admin/test/manage_moderations_examples.rb in decidim-admin-0.27.0.rc1
- old
+ new
@@ -1,7 +1,33 @@
# frozen_string_literal: true
+shared_examples "sorted moderations" do
+ let!(:moderations) do
+ reportables.first(reportables.length - 1).map do |reportable|
+ moderation = create(:moderation, reportable: reportable, report_count: 1, reported_content: reportable.reported_searchable_content_text)
+ create(:report, moderation: moderation)
+ moderation
+ end
+ end
+ let!(:moderation) { moderations.first }
+ let(:moderations_link_text) { "Moderations" }
+
+ before do
+ visit participatory_space_path
+ click_link moderations_link_text
+ end
+
+ it "sorts the most recent first" do
+ within ".pagination" do
+ click_link "Last"
+ end
+ all("tbody tr").each_with_index do |row, _index|
+ expect(row.find("td:first-child")).to have_content(reportables.first.id)
+ end
+ end
+end
+
shared_examples "manage moderations" do
let!(:moderations) do
reportables.first(reportables.length - 1).map do |reportable|
moderation = create(:moderation, reportable: reportable, report_count: 1, reported_content: reportable.reported_searchable_content_text)
create(:report, moderation: moderation)
@@ -108,99 +134,21 @@
visit current_path
expect(page).to have_no_selector("tr[data-id=\"#{moderation.id}\"]")
end
end
-
- context "when the user changes language" do
- around do |example|
- previous_backend = I18n.backend
- I18n.backend = I18n::Backend::Simple.new
- example.run
- I18n.backend = previous_backend
- end
-
- before do
- I18n.backend.store_translations(
- :ca,
- activerecord: {
- models: {
- moderation.reportable.class.name.underscore.to_sym => {
- one: "Objecte informable",
- other: "Objectes informables"
- }
- }
- }
- )
-
- within_language_menu do
- click_link "CatalĂ "
- end
- end
-
- it "renders the reportable types in the selected language" do
- within "tr[data-id=\"#{moderation.id}\"]" do
- expect(page).to have_content("Objecte informable")
- end
- end
- end
end
context "when listing hidden resources" do
- before do
+ it "user can review them" do
within ".card-title" do
click_link "Hidden"
end
- end
- it "user can't unreport them" do
- expect(page).not_to have_css(".action-icon--unreport")
- end
-
- it "user can review them" do
hidden_moderations.each do |moderation|
within "tr[data-id=\"#{moderation.id}\"]" do
expect(page).to have_css("a[href='#{moderation.reportable.reported_content_url}']")
end
end
- end
- end
-
- context "when listing comments for deleted resources" do
- let(:comments) do
- reportables.first(reportables.length - 1).map do |resource|
- create(:comment, commentable: resource)
- end
- end
- let!(:moderations) do
- comments.map do |reportable|
- space = reportable.is_a?(Decidim::Participable) ? reportable : reportable.participatory_space
- moderation = create(:moderation, reportable: reportable, report_count: 1, participatory_space: space, reported_content: reportable.reported_searchable_content_text)
- create(:report, moderation: moderation)
-
- reportable.root_commentable.destroy!
- reportable.reload
-
- moderation
- end
- end
-
- it "user can review them" do
- moderations.each do |moderation|
- within "tr[data-id=\"#{moderation.id}\"]" do
- expect(page).to have_content "Deleted resource"
- expect(page).to have_content "Spam"
- end
- end
- end
-
- it "user can hide them" do
- moderation_id = moderations.first.id
- within "tr[data-id=\"#{moderation_id}\"]" do
- click_link "Hide"
- end
-
- expect(page).to have_admin_callout("Resource successfully hidden")
- expect(page).not_to have_selector("tr[data-id=\"#{moderation_id}\"]")
end
end
end