Skip to content

Commit

Permalink
simplify routing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Jul 30, 2024
1 parent 33f9642 commit acdf2a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ def last_updated_at
end

def path
locale = I18n.locale == I18n.default_locale ? nil : I18n.locale
Rails.application.routes.url_helpers.person_path(self, locale: locale)
Rails.application.routes.url_helpers.person_path(self, locale: I18n.locale)
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/views/skills/_header.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%div.d-flex.flex-column.bg-white{"data-controller": "skillset-selected"}
= form_with(url: skills_path, method: :get, data: { turbo_frame: 'skills' }) do |form|
%div.d-flex.flex-row.mt-2
= form.text_field :title, class: "form-control skills-search-field rounded-end-0", placeholder: "#{ti('filter.search', target: Skill.model_name.human(count:2))}", oninput: "this.form.requestSubmit()", include_blank: true
= form.text_field :title, class: "form-control skills-search-field rounded-end-0", placeholder: "#{ti('filter.search', target: Skill.model_name.human)}", oninput: "this.form.requestSubmit()", include_blank: true
%div.border.d-flex.rounded-end.bg-white
%img.pointer.p-2{src: "/assets/search.svg"}
%div.d-flex.flex-row.mt-3.flex-wrap.gap-2
Expand All @@ -21,6 +21,6 @@
%span.d-flex.align-items-center.flex-wrap
%span.text-gray.me-1
= "#{Category.model_name.human}:"
= form.collection_select :category, Category.all_parents.order(:title), :id, :title, {include_blank: "Select a category"}, class: "form-select fit-content", onchange: 'this.form.requestSubmit();'
= form.collection_select :category, Category.all_parents.order(:title), :id, :title, {prompt: true}, class: "form-select fit-content", onchange: 'this.form.requestSubmit();'
= export_action_link export_skills_path
= add_action_link_modal
4 changes: 2 additions & 2 deletions spec/features/people_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
visit people_path
bob = people(:bob)
select_from_slim_select("#person_id_person", bob.name)
expect(page).to have_current_path(person_path(bob, locale: nil))
expect(page).to have_current_path(person_path(bob))
end

it 'redirect to the first entry' do
visit people_path
sorted_list = people_list.sort_by { |item| item.name.downcase }
ss_select_index("#person_id_person", 1)
expect(page).to have_current_path(person_path(sorted_list.first.id, locale: nil))
expect(page).to have_current_path(person_path(sorted_list.first.id))
end

it 'should only display matched people' do
Expand Down

0 comments on commit acdf2a0

Please sign in to comment.