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

CL-4182: Use first language with text for slug #6274

Merged
merged 7 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion back/app/models/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ def self.membership_types
private

def generate_slug
self.slug ||= SlugService.new.generate_slug self, title_multiloc.values.first
self.slug ||= SlugService.new.generate_slug(
self,
title_multiloc.find { |_key, value| value.present? }&.last
)
end

def set_membership_type
Expand Down
9 changes: 9 additions & 0 deletions back/spec/models/group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,13 @@
group.update_memberships_count!
end
end

describe 'generate_slug' do
it 'generates a slug based on the first non-empty locale' do
group = described_class.new
group.title_multiloc = { en: '', 'nl-BE': 'title', 'fr-BE': 'titlefrançais' }
group.send(:generate_slug)
expect(group.slug).to eq('title')
end
end
end