mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-02 11:59:17 -05:00
Support non-english topic titles
This commit is contained in:
parent
5d4efa9100
commit
37b0c168bf
4 changed files with 23 additions and 4 deletions
|
@ -25,7 +25,9 @@ Discourse.Topic = Discourse.Model.extend Discourse.Presence,
|
||||||
).property('categoryName', 'categories')
|
).property('categoryName', 'categories')
|
||||||
|
|
||||||
url: (->
|
url: (->
|
||||||
"/t/#{@get('slug')}/#{@get('id')}"
|
slug = @get('slug')
|
||||||
|
slug = "topic" if slug.isBlank()
|
||||||
|
"/t/#{slug}/#{@get('id')}"
|
||||||
).property('id', 'slug')
|
).property('id', 'slug')
|
||||||
|
|
||||||
# Helper to build a Url with a post number
|
# Helper to build a Url with a post number
|
||||||
|
|
|
@ -129,7 +129,6 @@ class Topic < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def new_version_required?
|
def new_version_required?
|
||||||
return true if title_changed?
|
return true if title_changed?
|
||||||
return true if category_id_changed?
|
return true if category_id_changed?
|
||||||
|
@ -497,7 +496,9 @@ class Topic < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def slug
|
def slug
|
||||||
Slug.for(title)
|
result = Slug.for(title)
|
||||||
|
return "topic" if result.blank?
|
||||||
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def last_post_url
|
def last_post_url
|
||||||
|
|
|
@ -37,7 +37,7 @@ describe ListController do
|
||||||
|
|
||||||
context 'with a link that includes an id' do
|
context 'with a link that includes an id' do
|
||||||
before do
|
before do
|
||||||
xhr :get, :category, category: "#{category.slug}-#{category.id}"
|
xhr :get, :category, category: "#{category.id}-#{category.slug}"
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should respond_with(:success) }
|
it { should respond_with(:success) }
|
||||||
|
|
|
@ -49,6 +49,22 @@ describe Topic do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'slug' do
|
||||||
|
|
||||||
|
let(:title) { "hello world topic" }
|
||||||
|
let(:slug) { "hello-world-slug" }
|
||||||
|
|
||||||
|
it "returns a Slug for a title" do
|
||||||
|
Slug.expects(:for).with(title).returns(slug)
|
||||||
|
Fabricate.build(:topic, title: title).slug.should == slug
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns 'topic' when the slug is empty (say, non-english chars)" do
|
||||||
|
Slug.expects(:for).with(title).returns("")
|
||||||
|
Fabricate.build(:topic, title: title).slug.should == "topic"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
context 'topic title uniqueness' do
|
context 'topic title uniqueness' do
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue