Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor malformed titles in admin logs (part 1) #12702

Merged
merged 43 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f39b9fc
Fix admin logs
alecslupu Apr 17, 2024
fb04f74
Properly escape log entries
alecslupu Apr 17, 2024
fbd9706
Add debates Presenter
alecslupu Apr 17, 2024
ed08779
Remove AdminLog::DebatePresenter
alecslupu Apr 17, 2024
f488500
Fix presenter usage
alecslupu Apr 17, 2024
e875100
More cleanup
alecslupu Apr 17, 2024
1502c0d
Running linters
alecslupu Apr 17, 2024
02f5927
Fix specs
alecslupu Apr 17, 2024
2754e8f
Running linters
alecslupu Apr 17, 2024
8be3c94
Merge branch 'develop' of github.com:decidim/decidim into fix/admin-logs
alecslupu May 10, 2024
9147a80
Add admin log entries
alecslupu May 10, 2024
468a80b
Add admin logs specs
alecslupu May 10, 2024
5b1725e
Fix specs
alecslupu May 10, 2024
08821c1
Proposals and sortitions
alecslupu May 10, 2024
b7d5c2d
Fix pipeline
alecslupu May 10, 2024
8c49d49
Fix pipeline
alecslupu May 10, 2024
b713423
Merge branch 'develop' of github.com:decidim/decidim into fix/admin-logs
alecslupu May 12, 2024
e305a3f
Add participatory process pages
alecslupu May 13, 2024
dea9b4d
More logs
alecslupu May 14, 2024
3ac8ef2
Refactor
alecslupu May 17, 2024
75522d0
lint
alecslupu May 17, 2024
9650781
Refactor
alecslupu May 18, 2024
1991ef8
Merge branch 'develop' of github.com:decidim/decidim into fix/admin-logs
alecslupu May 18, 2024
42cb9ad
Finalize the assembly types
alecslupu May 18, 2024
ce54d08
more refactor
alecslupu May 19, 2024
95721a2
Fix blogs
alecslupu May 19, 2024
86321f1
fix decidim-conferences
alecslupu May 19, 2024
cd3eeca
Reformat the code
alecslupu May 19, 2024
81f438d
update specs
alecslupu May 20, 2024
c4445c2
Refactor
alecslupu May 20, 2024
e1cb5d1
Running rubocops
alecslupu May 26, 2024
4ebb7dd
Merge branch 'develop' of github.com:decidim/decidim into fix/admin-logs
alecslupu May 28, 2024
ebf348a
Merge branch 'develop' of github.com:decidim/decidim into fix/admin-logs
alecslupu May 28, 2024
dbe1ebb
Fix meetings specs
alecslupu May 28, 2024
7d5ac34
Merge branch 'develop' of github.com:decidim/decidim into fix/admin-logs
alecslupu Jun 17, 2024
9b7aaa2
Apply suggestions from code review
alecslupu Jun 17, 2024
21f959b
Apply review recommendation
alecslupu Jun 17, 2024
ddaa1a8
Merge branch 'fix/admin-logs' of github.com:decidim/decidim into fix/…
alecslupu Jun 17, 2024
8ff656d
Fix spec
alecslupu Jun 17, 2024
d443137
Fix specs
alecslupu Jun 17, 2024
3ecb47d
Fix blogs specs
alecslupu Jun 17, 2024
8f97add
Apply suggestions from code review
alecslupu Jun 17, 2024
d00a76c
Lint
alecslupu Jun 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 14 additions & 11 deletions decidim-accountability/spec/shared/manage_results_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
context "when having existing proposals" do
let!(:proposal_component) { create(:proposal_component, participatory_space:) }
let!(:proposals) { create_list(:proposal, 5, component: proposal_component) }
let(:attributes) { attributes_for(:result, component: current_component) }

it "updates a result" do
within "tr", text: translated(result.title) do
Expand All @@ -41,9 +42,7 @@
fill_in_i18n(
:result_title,
"#result-title-tabs",
en: "My new title",
es: "Mi nuevo título",
ca: "El meu nou títol"
**attributes[:title].except("machine_translations")
)

tom_select("#proposals_list", option_id: proposals.first(2).map(&:id))
Expand All @@ -54,8 +53,12 @@
expect(page).to have_admin_callout("successfully")

within "table" do
expect(page).to have_content("My new title")
expect(page).to have_content(translated(attributes[:title]))
end

visit decidim_admin.root_path
expect(page).to have_content("updated result")
expect(page).to have_content(translated(attributes[:title]))
end

it "creates a new result", :slow do
Expand All @@ -65,16 +68,12 @@
fill_in_i18n(
:result_title,
"#result-title-tabs",
en: "My result",
es: "Mi result",
ca: "El meu result"
**attributes[:title].except("machine_translations")
)
fill_in_i18n_editor(
:result_description,
"#result-description-tabs",
en: "A longer description",
es: "Descripción más larga",
ca: "Descripció més llarga"
**attributes[:description].except("machine_translations")
)

tom_select("#proposals_list", option_id: proposals.first(2).map(&:id))
Expand All @@ -88,8 +87,12 @@
expect(page).to have_admin_callout("successfully")

within "table" do
expect(page).to have_content("My result")
expect(page).to have_content(translated(attributes[:title]))
end

visit decidim_admin.root_path
expect(page).to have_content("created result")
expect(page).to have_content(attributes[:title]["en"])
end
end

Expand Down
33 changes: 13 additions & 20 deletions decidim-accountability/spec/shared/manage_statuses_examples.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

RSpec.shared_examples "manage statuses" do
let(:attributes) { attributes_for(:status) }

it "updates a status" do
within "tr", text: status.key do
click_on "Edit"
Expand All @@ -10,9 +12,7 @@
fill_in_i18n(
:status_name,
"#status-name-tabs",
en: "My new name",
es: "Mi nuevo nombre",
ca: "El meu nou nom"
**attributes[:name].except("machine_translations")
)

find("*[type=submit]").click
Expand All @@ -21,8 +21,11 @@
expect(page).to have_admin_callout("successfully")

within "table" do
expect(page).to have_content("My new name")
expect(page).to have_content(translated(attributes[:name]))
end

visit decidim_admin.root_path
expect(page).to have_content("updated the #{translated(attributes[:name])} status")
end

it "creates a new status" do
Expand All @@ -31,21 +34,8 @@
within ".new_status" do
fill_in :status_key, with: "status_key_1"

fill_in_i18n(
:status_name,
"#status-name-tabs",
en: "A longer name",
es: "Nombre más larga",
ca: "Nom més llarga"
)

fill_in_i18n(
:status_description,
"#status-description-tabs",
en: "A longer description",
es: "Descripción más larga",
ca: "Descripció més llarga"
)
fill_in_i18n(:status_name, "#status-name-tabs", **attributes[:name].except("machine_translations"))
fill_in_i18n(:status_description, "#status-description-tabs", **attributes[:description].except("machine_translations"))

fill_in :status_progress, with: 75

Expand All @@ -56,8 +46,11 @@

within "table" do
expect(page).to have_content("status_key_1")
expect(page).to have_content("A longer name")
expect(page).to have_content(translated(attributes[:name]))
end

visit decidim_admin.root_path
expect(page).to have_content("created the #{translated(attributes[:name])} status")
end

describe "deleting a result" do
Expand Down
48 changes: 48 additions & 0 deletions decidim-accountability/spec/shared/manage_timeline_examples.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# frozen_string_literal: true

RSpec.shared_examples "manage timeline" do
let(:attributes) { attributes_for(:timeline_entry, result:) }

it "updates a timeline entry", versioning: true do
visit current_path
click_on "Edit", match: :first

within ".edit_timeline_entry" do
fill_in :timeline_entry_entry_date_date, with: Date.current.strftime("%d/%m/%Y")
fill_in_i18n(:timeline_entry_title, "#timeline_entry-title-tabs", **attributes[:title].except("machine_translations"))
fill_in_i18n_editor(:timeline_entry_description, "#timeline_entry-description-tabs", **attributes[:description].except("machine_translations"))

find("*[type=submit]").click
end

expect(page).to have_admin_callout("successfully")

within "table" do
expect(page).to have_content(translated(attributes[:title]))
end

visit decidim_admin.root_path
expect(page).to have_content("updated the #{translated(attributes[:title])} timeline entry")
end

it "creates a timeline entry", versioning: true do
click_on "New timeline entry", match: :first

within ".new_timeline_entry" do
fill_in :timeline_entry_entry_date_date, with: Date.current.strftime("%d/%m/%Y")
fill_in_i18n(:timeline_entry_title, "#timeline_entry-title-tabs", **attributes[:title].except("machine_translations"))
fill_in_i18n_editor(:timeline_entry_description, "#timeline_entry-description-tabs", **attributes[:description].except("machine_translations"))

find("*[type=submit]").click
end

expect(page).to have_admin_callout("successfully")

within "table" do
expect(page).to have_content(translated(attributes[:title]))
end

visit decidim_admin.root_path
expect(page).to have_content("created the #{translated(attributes[:title])} timeline entry")
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,17 @@

it_behaves_like "manage statuses"
end

describe "timeline" do
before do
visit_component_admin
within "tr", text: translated(result.title) do
click_on "Project evolution"
end
end

let!(:timeline_entry) { create(:timeline_entry, result:) }

it_behaves_like "manage timeline"
end
end
28 changes: 20 additions & 8 deletions decidim-assemblies/spec/shared/manage_assemblies_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,33 @@
let(:image3_path) { Decidim::Dev.asset(image3_filename) }

let(:assembly_parent_id_options) { page.find_by_id("assembly_parent_id").find_all("option").map(&:value) }
let(:attributes) { attributes_for(:assembly, :with_content_blocks, organization:, blocks_manifests: [:announcement]) }

before do
click_on "Configure"
end

it "updates an assembly" do
fill_in_i18n(
:assembly_title,
"#assembly-title-tabs",
en: "My new title",
es: "Mi nuevo título",
ca: "El meu nou títol"
)
fill_in_i18n(:assembly_title, "#assembly-title-tabs", **attributes[:title].except("machine_translations"))

dynamically_attach_file(:assembly_banner_image, image3_path, remove_before: true)

within ".edit_assembly" do
expect(assembly_parent_id_options).not_to include(assembly.id)
fill_in_i18n(:assembly_subtitle, "#assembly-subtitle-tabs", **attributes[:subtitle].except("machine_translations"))
fill_in_i18n_editor(:assembly_short_description, "#assembly-short_description-tabs", **attributes[:short_description].except("machine_translations"))
fill_in_i18n_editor(:assembly_description, "#assembly-description-tabs", **attributes[:description].except("machine_translations"))
fill_in_i18n_editor(:assembly_purpose_of_action, "#assembly-purpose_of_action-tabs", **attributes[:purpose_of_action].except("machine_translations"))
fill_in_i18n_editor(:assembly_composition, "#assembly-composition-tabs", **attributes[:composition].except("machine_translations"))
fill_in_i18n_editor(:assembly_internal_organisation, "#assembly-internal_organisation-tabs", **attributes[:internal_organisation].except("machine_translations"))
fill_in_i18n_editor(:assembly_announcement, "#assembly-announcement-tabs", **attributes[:announcement].except("machine_translations"))
fill_in_i18n_editor(:assembly_closing_date_reason, "#assembly-closing_date_reason-tabs", **attributes[:closing_date_reason].except("machine_translations"))

fill_in_i18n(:assembly_participatory_scope, "#assembly-participatory_scope-tabs", **attributes[:participatory_scope].except("machine_translations"))
fill_in_i18n(:assembly_participatory_structure, "#assembly-participatory_structure-tabs", **attributes[:participatory_structure].except("machine_translations"))
fill_in_i18n(:assembly_meta_scope, "#assembly-meta_scope-tabs", **attributes[:meta_scope].except("machine_translations"))
fill_in_i18n(:assembly_local_area, "#assembly-local_area-tabs", **attributes[:local_area].except("machine_translations"))
fill_in_i18n(:assembly_target, "#assembly-target-tabs", **attributes[:target].except("machine_translations"))

fill_in :assembly_creation_date_date, with: nil, fill_options: { clear: :backspace }
fill_in :assembly_included_at_date, with: nil, fill_options: { clear: :backspace }
Expand All @@ -39,13 +48,16 @@
expect(page).to have_admin_callout("successfully")

within "[data-content]" do
expect(page).to have_css("input[value='My new title']")
expect(page).to have_css("input[value='#{translated(attributes[:title])}']")
expect(page).to have_css("img[src*='#{image3_filename}']")
expect(page).to have_field(:assembly_creation_date_date, with: Date.yesterday.strftime("%d/%m/%Y").to_s)
expect(page).to have_field(:assembly_included_at_date, with: Date.current.strftime("%d/%m/%Y").to_s)
expect(page).to have_field(:assembly_duration_date, with: Date.tomorrow.strftime("%d/%m/%Y").to_s)
expect(page).to have_field(:assembly_closing_date_date, with: Date.tomorrow.strftime("%d/%m/%Y").to_s)
end

visit decidim_admin.root_path
expect(page).to have_content("updated the #{translated(attributes[:title])} assembly")
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

shared_examples "manage assembly admins examples" do
let(:other_user) { create(:user, organization:, email: "my_email@example.org") }
let(:attributes) { attributes_for(:user, organization:) }

let!(:assembly_admin) do
create(:assembly_admin,
Expand All @@ -25,12 +26,12 @@
end
end

it "creates a new assembly admin" do
it "creates a new assembly admin", versioning: true do
click_on "New assembly admin"

within ".new_assembly_user_role" do
fill_in :assembly_user_role_email, with: other_user.email
fill_in :assembly_user_role_name, with: "John Doe"
fill_in :assembly_user_role_name, with: attributes[:name]
select "Administrator", from: :assembly_user_role_role

find("*[type=submit]").click
Expand All @@ -41,6 +42,9 @@
within "#assembly_admins table" do
expect(page).to have_content(other_user.email)
end

visit decidim_admin.root_path
expect(page).to have_content("invited #{other_user.name} to the #{translated(assembly.title)} assembly")
end

describe "when managing different users" do
Expand All @@ -49,7 +53,7 @@
visit current_path
end

it "updates an assembly admin" do
it "updates an assembly admin", versioning: true do
within "#assembly_admins" do
within "#assembly_admins tr", text: other_user.email do
click_on "Edit"
Expand All @@ -67,6 +71,8 @@
within "#assembly_admins table" do
expect(page).to have_content("Collaborator")
end
visit decidim_admin.root_path
expect(page).to have_content("changed the role of #{other_user.name} in the #{translated(assembly.title)} assembly")
end

it "deletes an assembly_user_role" do
Expand Down
30 changes: 18 additions & 12 deletions decidim-assemblies/spec/shared/manage_assembly_members_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@

context "without existing user" do
let!(:assembly_member) { create(:assembly_member, assembly:) }
let(:attributes) { attributes_for(:assembly_member, assembly:) }

it "creates a new assembly member" do
it "creates a new assembly member", versioning: true do
click_on "New assembly member"

fill_in_datepicker :assembly_member_designation_date_date, with: Time.current.strftime("%d/%m/%Y")

within ".new_assembly_member" do
fill_in(
:assembly_member_full_name,
with: "Daisy O'connor"
)
fill_in(:assembly_member_full_name, with: attributes[:full_name])
fill_in(:assembly_member_gender, with: attributes[:gender])
fill_in(:assembly_member_birthplace, with: attributes[:birthplace])
end

dynamically_attach_file(:assembly_member_non_user_avatar, Decidim::Dev.asset("avatar.jpg")) do
Expand All @@ -39,8 +39,11 @@
expect(page).to have_current_path decidim_admin_assemblies.assembly_members_path(assembly)

within "#assembly_members table" do
expect(page).to have_content("Daisy O'connor")
expect(page).to have_content(attributes[:full_name])
end

visit decidim_admin.root_path
expect(page).to have_content("created the #{attributes[:full_name]} member")
end
end

Expand Down Expand Up @@ -98,6 +101,7 @@

describe "when managing other assembly members" do
let!(:assembly_member) { create(:assembly_member, assembly:) }
let(:attributes) { attributes_for(:assembly_member, assembly:) }

before do
visit current_path
Expand All @@ -109,16 +113,15 @@
end
end

it "updates an assembly member" do
it "updates an assembly member", versioning: true do
within "#assembly_members tr", text: assembly_member.full_name do
click_on "Edit"
end

within ".edit_assembly_member" do
fill_in(
:assembly_member_full_name,
with: "Alicia O'connor"
)
fill_in(:assembly_member_full_name, with: attributes[:full_name])
fill_in(:assembly_member_gender, with: attributes[:gender])
fill_in(:assembly_member_birthplace, with: attributes[:birthplace])

find("*[type=submit]").click
end
Expand All @@ -127,8 +130,11 @@
expect(page).to have_current_path decidim_admin_assemblies.assembly_members_path(assembly)

within "#assembly_members table" do
expect(page).to have_content("Alicia O'connor")
expect(page).to have_content(attributes[:full_name])
end

visit decidim_admin.root_path
expect(page).to have_content("updated the #{assembly_member.full_name} member")
end

it "deletes the assembly member" do
Expand Down