Skip to content

Commit

Permalink
Rubocopify and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
laurajaime committed Aug 26, 2024
1 parent eea76ea commit ce3cc3a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 37 deletions.
3 changes: 1 addition & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ AllCops:
# If a value is specified for TargetRubyVersion then it is used.
# Else if .ruby-version exists and it contains an MRI version it is used.
# Otherwise we fallback to the oldest officially supported Ruby version (2.0).
TargetRubyVersion: 2.7

TargetRubyVersion: 3.0.7
RSpec:
Patterns:
- "(?:^|/)spec/"
Expand Down
6 changes: 1 addition & 5 deletions app/decorators/decidim/admin/users_controller_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ def show
@spaces = []
@user.participatory_processes.each do |process|
type = if process.participatory_process_group
if process.participatory_process_group&.title&.[](locale).blank?
process.participatory_process_group&.title&.[]("ca")
else
process.participatory_process_group&.title&.[](locale)
end
process.participatory_process_group&.title&.[](locale).presence || process.participatory_process_group&.title&.[]("ca")
else
t("models.user.fields.process_type", scope: "decidim.admin")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

let(:image2_filename) { "city2.jpeg" }
let(:image2_path) { Decidim::Dev.asset(image2_filename) }
let(:attributes) { attributes_for(:assembly, organization: organization) }

before do
visit decidim_admin_assemblies.assemblies_path
Expand All @@ -26,37 +27,25 @@

it "creates a new assembly" do
within ".new_assembly" do
fill_in_i18n(
:assembly_title,
"#assembly-title-tabs",
en: "My assembly",
es: "Mi proceso participativo",
ca: "El meu procés participatiu"
)
fill_in_i18n(
:assembly_subtitle,
"#assembly-subtitle-tabs",
en: "Subtitle",
es: "Subtítulo",
ca: "Subtítol"
)
fill_in_i18n_editor(
:assembly_short_description,
"#assembly-short_description-tabs",
en: "Short description",
es: "Descripción corta",
ca: "Descripció curta"
)
fill_in_i18n_editor(
:assembly_description,
"#assembly-description-tabs",
en: "A longer description",
es: "Descripción más larga",
ca: "Descripció més llarga"
)
fill_in_i18n(:assembly_title, "#assembly-title-tabs", **attributes[:title].except("machine_translations"))
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_slug, with: "slug"
fill_in :assembly_hashtag, with: "#hashtag"
fill_in :assembly_weight, with: 1
end

dynamically_attach_file(:assembly_hero_image, image1_path)
Expand All @@ -71,19 +60,22 @@

within ".container" do
expect(page).to have_current_path decidim_admin_assemblies.assemblies_path(q: { parent_id_eq: parent_assembly&.id })
expect(page).to have_content("My assembly")
expect(page).to have_content(translated(attributes[:title]))
end
end
end

context "when managing parent assemblies" do
let(:parent_assembly) { nil }
let!(:assembly) { create :assembly, organization: organization }

before do
switch_to_host(organization.host)
login_as department_admin, scope: :user
visit decidim_admin_assemblies.assemblies_path
end
# it_behaves_like "manage assemblies"

# it_behaves_like "manage assemblies"
it_behaves_like "creating an assembly"
end

Expand All @@ -93,6 +85,8 @@
let(:assembly) { child_assembly }

before do
switch_to_host(organization.host)
login_as department_admin, scope: :user
visit decidim_admin_assemblies.assemblies_path
within find("tr", text: translated(parent_assembly.title)) do
click_link "Assemblies"
Expand Down

0 comments on commit ce3cc3a

Please sign in to comment.